stm32_common/spi: fix receive after transmit-only error

This commit is contained in:
Koen Zandberg 2017-03-20 09:33:34 +01:00
parent 1b2b5d9df9
commit 465f2710c6

View File

@ -172,6 +172,7 @@ void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
*DR = outbuf[i]; *DR = outbuf[i];
} }
/* wait until everything is finished and empty the receive buffer */ /* wait until everything is finished and empty the receive buffer */
while (!(dev(bus)->SR & SPI_SR_TXE)) {}
while (dev(bus)->SR & SPI_SR_BSY) {} while (dev(bus)->SR & SPI_SR_BSY) {}
while (dev(bus)->SR & SPI_SR_RXNE) { while (dev(bus)->SR & SPI_SR_RXNE) {
dev(bus)->DR; /* we might just read 2 bytes at once here */ dev(bus)->DR; /* we might just read 2 bytes at once here */