Skip to content

Commit a586670

Browse files
author
Richard Unger
committed
fix MT6701 sensor on RP2040
SPI on RP2040 seems to read an extra bit from MT6701, which STM32 does not seem to read.
1 parent 5fa46f3 commit a586670

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/encoders/mt6701/MagneticSensorMT6701SSI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ uint16_t MagneticSensorMT6701SSI::readRawAngleSSI() {
3838
spi->endTransaction();
3939
if (nCS >= 0)
4040
digitalWrite(nCS, HIGH);
41-
return (value>>2)&0x3FFF;
41+
return (value>>MT6701_DATA_POS)&0x3FFF;
4242
};

src/encoders/mt6701/MagneticSensorMT6701SSI.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
#define MT6701_BITORDER MSBFIRST
1111

12+
#if defined(TARGET_RP2040)
13+
#define MT6701_DATA_POS 1
14+
#else
15+
#define MT6701_DATA_POS 2
16+
#endif
1217

1318
// 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.
1419
// SSI frame is 1 bit ignore, 14 bits angle, 4 bit status and 6 bit CRC.

0 commit comments

Comments
 (0)