run background tasks during multi-part DMA

This commit is contained in:
Dan Halbert 2023-03-09 11:53:16 -05:00
parent 21305e3e1c
commit 96e2a72d71
1 changed files with 8 additions and 1 deletions

View File

@ -271,10 +271,17 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
size_t bytes_remaining = len;
// Maximum DMA transfer is 65535
while (bytes_remaining > 0) {
while (1) {
size_t to_send = (bytes_remaining > 65535) ? 65535 : bytes_remaining;
status = sercom_dma_write(self->spi_desc.dev.prvt, data + (len - bytes_remaining), to_send);
bytes_remaining -= to_send;
if (bytes_remaining > 0) {
// Multi-part transfer; let other things run before doing the next chunk.
RUN_BACKGROUND_TASKS;
} else {
// All done.
break;
}
}
} else {
struct io_descriptor *spi_io;