Skip to content

Commit 353411a

Browse files
authored
Merge pull request adafruit#7701 from dhalbert/background-task-for-7673
run background tasks during multi-part DMA
2 parents fe40035 + 96e2a72 commit 353411a

File tree

1 file changed

+8
-1
lines changed
  • ports/atmel-samd/common-hal/busio

1 file changed

+8
-1
lines changed

ports/atmel-samd/common-hal/busio/SPI.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,17 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
271271
size_t bytes_remaining = len;
272272

273273
// Maximum DMA transfer is 65535
274-
while (bytes_remaining > 0) {
274+
while (1) {
275275
size_t to_send = (bytes_remaining > 65535) ? 65535 : bytes_remaining;
276276
status = sercom_dma_write(self->spi_desc.dev.prvt, data + (len - bytes_remaining), to_send);
277277
bytes_remaining -= to_send;
278+
if (bytes_remaining > 0) {
279+
// Multi-part transfer; let other things run before doing the next chunk.
280+
RUN_BACKGROUND_TASKS;
281+
} else {
282+
// All done.
283+
break;
284+
}
278285
}
279286
} else {
280287
struct io_descriptor *spi_io;

0 commit comments

Comments
 (0)