mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 07:51:19 +01:00
cpu/cc2538: spi: fix spi_transfer_bytes() with in_buf = NULL
We have to read the DR for every byte that we write. Just reading DR while SPI is busy in a loop can lead to bytes being left in the fifo, corrupting subsequent reads.
This commit is contained in:
parent
5e9733645f
commit
68b2c57d2d
@ -139,9 +139,7 @@ void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
while (!(dev(bus)->SR & SSI_SR_TNF)) {}
|
||||
dev(bus)->DR = out_buf[i];
|
||||
}
|
||||
/* flush RX FIFO while busy*/
|
||||
while ((dev(bus)->SR & SSI_SR_BSY)) {
|
||||
while (!(dev(bus)->SR & SSI_SR_RNE)) {}
|
||||
dev(bus)->DR;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user