diff options
author | Yannic Schroeder <schroeder@ibr.cs.tu-bs.de> | 2018-12-12 15:25:07 +0100 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-12-14 12:25:35 -0500 |
commit | f100d75c19709e92fd07423217e76031acbad8a6 (patch) | |
tree | f90a6aeb3838847ae3d80024a5b2fd72b3d84398 /src | |
parent | ef4f84e3aecc469486e6560db27e94d9ab37f123 (diff) | |
download | kutter-f100d75c19709e92fd07423217e76031acbad8a6.tar.gz kutter-f100d75c19709e92fd07423217e76031acbad8a6.tar.xz kutter-f100d75c19709e92fd07423217e76031acbad8a6.zip |
stm32f1: Always read SPI receive buffer
Otherwise the first byte read via SPI may be the last byte
of the previous transfer
Signed-off-by: Yannic Schroeder <schroeder@ibr.cs.tu-bs.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/stm32f1/spi.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/stm32f1/spi.c b/src/stm32f1/spi.c index 7bea6cb5..a90a030a 100644 --- a/src/stm32f1/spi.c +++ b/src/stm32f1/spi.c @@ -97,9 +97,10 @@ spi_transfer(struct spi_config config, uint8_t receive_data, while (len--) { LL_SPI_TransmitData8(SPI2, *data); while (!LL_SPI_IsActiveFlag_TXE(SPI2)); + while (!LL_SPI_IsActiveFlag_RXNE(SPI2)); + uint8_t rdata = LL_SPI_ReceiveData8(SPI2); if (receive_data) { - while (!LL_SPI_IsActiveFlag_RXNE(SPI2)); - *data = LL_SPI_ReceiveData8(SPI2); + *data = rdata; } data++; } |