Skip to content

Commit 95a4749

Browse files
committed
rp2/machine_spi: Improve RX overrun handling.
Need to clear the overrun flag. RX overruns are not a problem if only writing. Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
1 parent 30fb190 commit 95a4749

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

ports/rp2/machine_spi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,16 @@ static void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8
304304
while (spi_is_busy(self->spi_inst) || spi_is_readable(self->spi_inst)) {
305305
}
306306
if (spi_get_const_hw(self->spi_inst)->ris & SPI_SSPRIS_RORRIS_BITS) {
307-
// RX overrun occurred, RX DMA channel needs to be manually aborted
308-
success = false;
307+
// RX overrun occurred. Clear the flag for future transfers
308+
spi_get_hw(self->spi_inst)->icr = SPI_SSPICR_RORIC_BITS;
309+
310+
// RX DMA channel needs to be manually aborted
309311
dma_channel_abort(chan_rx);
312+
313+
// An RX overrun is only a problem if we were actually reading
314+
if (!write_only) {
315+
success = false;
316+
}
310317
}
311318
}
312319

0 commit comments

Comments
 (0)