aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYannic Schroeder <schroeder@ibr.cs.tu-bs.de>2018-12-12 15:25:07 +0100
committerKevin O'Connor <kevin@koconnor.net>2018-12-14 12:25:35 -0500
commitf100d75c19709e92fd07423217e76031acbad8a6 (patch)
treef90a6aeb3838847ae3d80024a5b2fd72b3d84398
parentef4f84e3aecc469486e6560db27e94d9ab37f123 (diff)
downloadkutter-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>
-rw-r--r--src/stm32f1/spi.c5
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++;
}