From 465f2710c610ad0b889d4ffaaed18805c552b2cb Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Mon, 20 Mar 2017 09:33:34 +0100 Subject: [PATCH] stm32_common/spi: fix receive after transmit-only error --- cpu/stm32_common/periph/spi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/stm32_common/periph/spi.c b/cpu/stm32_common/periph/spi.c index 60f0a85924..ccad7bcef8 100644 --- a/cpu/stm32_common/periph/spi.c +++ b/cpu/stm32_common/periph/spi.c @@ -172,6 +172,7 @@ void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont, *DR = outbuf[i]; } /* 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_RXNE) { dev(bus)->DR; /* we might just read 2 bytes at once here */