Skip to content

run background tasks during multi-part DMA #7701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ports/atmel-samd/common-hal/busio/SPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down