Skip to content

Commit

Permalink
fix bug with SPI mode 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Unger committed Nov 2, 2023
1 parent 8a4d287 commit c66b9db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/encoders/mt6835/MT6835.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ uint32_t MT6835::readRawAngle21(){
data[3] = 0;
data[4] = 0;
data[5] = 0;
spi->beginTransaction(settings);
if (nCS >= 0)
digitalWrite(nCS, LOW);
spi->beginTransaction(settings);
spi->transfer(data, 6);
spi->endTransaction();
if (nCS >= 0)
digitalWrite(nCS, HIGH);
spi->endTransaction();
laststatus = data[4]&0x07;
return (data[2] << 13) | (data[3] << 5) | (data[4] >> 3);
};
Expand Down Expand Up @@ -252,13 +252,13 @@ uint32_t swap_bytes(uint32_t net)

void MT6835::transfer24(MT6835Command* outValue) {
uint32_t buff = swap_bytes(outValue->val);
spi->beginTransaction(settings);
if (nCS >= 0)
digitalWrite(nCS, LOW);
spi->beginTransaction(settings);
spi->transfer(&buff, 3);
spi->endTransaction();
if (nCS >= 0)
digitalWrite(nCS, HIGH);
spi->endTransaction();
outValue->val = swap_bytes(buff);
};
uint8_t MT6835::readRegister(uint16_t reg) {
Expand Down

0 comments on commit c66b9db

Please sign in to comment.