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>
This commit is contained in:
Yannic Schroeder 2018-12-12 15:25:07 +01:00 committed by Kevin O'Connor
parent ef4f84e3ae
commit f100d75c19
1 changed files with 3 additions and 2 deletions

View File

@ -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++;
}