forked from simplefoc/Arduino-FOC-drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagneticSensorMA730SSI.cpp
More file actions
34 lines (25 loc) · 870 Bytes
/
MagneticSensorMA730SSI.cpp
File metadata and controls
34 lines (25 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "./MagneticSensorMA730SSI.h"
#include "common/foc_utils.h"
#include "common/time_utils.h"
MagneticSensorMA730SSI::MagneticSensorMA730SSI(SPISettings settings) : settings(settings) {
}
MagneticSensorMA730SSI::~MagneticSensorMA730SSI() {
}
void MagneticSensorMA730SSI::init(SPIClass* _spi) {
this->spi=_spi;
this->Sensor::init();
}
// check 40us delay between each read?
float MagneticSensorMA730SSI::getSensorAngle() {
float angle_data = readRawAngleSSI();
angle_data = ( angle_data / (float)MA730_CPR ) * _2PI;
// return the shaft angle
return angle_data;
}
uint16_t MagneticSensorMA730SSI::readRawAngleSSI() {
spi->beginTransaction(settings);
uint16_t value = spi->transfer16(0x0000);
//uint16_t parity = spi->transfer(0x00);
spi->endTransaction();
return (value<<1); //>>1)&0x3FFF;
}; // 14bit angle value