Skip to content

Commit 6468e52

Browse files
committed
change SPI operations order on MT6701SSI driver
1 parent 948a8f5 commit 6468e52

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/encoders/mt6701/MagneticSensorMT6701SSI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ float MagneticSensorMT6701SSI::getSensorAngle() {
3131

3232

3333
uint16_t MagneticSensorMT6701SSI::readRawAngleSSI() {
34+
spi->beginTransaction(settings);
3435
if (nCS >= 0)
3536
digitalWrite(nCS, LOW);
36-
spi->beginTransaction(settings);
3737
uint16_t value = spi->transfer16(0x0000);
38-
spi->endTransaction();
3938
if (nCS >= 0)
4039
digitalWrite(nCS, HIGH);
40+
spi->endTransaction();
4141
return (value>>MT6701_DATA_POS)&0x3FFF;
4242
};

src/encoders/mt6701/MagneticSensorMT6701SSI.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010

1111
#define MT6701_BITORDER MSBFIRST
1212

13-
#if defined(TARGET_RP2040)||defined(ESP_H)||defined(CORE_TEENSY)
1413
#define MT6701_DATA_POS 1
15-
#else
16-
#define MT6701_DATA_POS 2
17-
#endif
1814

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

0 commit comments

Comments
 (0)