-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathMagneticSensorMT6701SSI.h
More file actions
39 lines (24 loc) · 984 Bytes
/
MagneticSensorMT6701SSI.h
File metadata and controls
39 lines (24 loc) · 984 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
35
36
37
38
39
#ifndef __MAGNETIC_SENSOR_MT6701_SSI_H__
#define __MAGNETIC_SENSOR_MT6701_SSI_H__
#include "Arduino.h"
#include "SPI.h"
#include "common/base_classes/Sensor.h"
#define MT6701_CPR 16384.0f
#define MT6701_BITORDER MSBFIRST
#define MT6701_DATA_POS 1
// Use SPI mode 2, capture on falling edge. First bit is not valid data, so have to read 25 bits to get a full SSI frame.
// SSI frame is 1 bit ignore, 14 bits angle, 4 bit status and 6 bit CRC.
static SPISettings MT6701SSISettings(1000000, MT6701_BITORDER, SPI_MODE2); // @suppress("Invalid arguments")
class MagneticSensorMT6701SSI : public Sensor {
public:
MagneticSensorMT6701SSI(int nCS = -1, SPISettings settings = MT6701SSISettings);
virtual ~MagneticSensorMT6701SSI();
virtual void init(SPIClass* _spi = &SPI);
float getSensorAngle() override; // angle in radians, return current value
protected:
uint16_t readRawAngleSSI();
SPISettings settings;
SPIClass* spi;
int nCS = -1;
};
#endif