Fix for long length writes

This commit is contained in:
gamblor21 2023-03-02 21:55:21 -06:00
parent 763d7e4c5b
commit 6987d3d752
1 changed files with 8 additions and 1 deletions

View File

@ -268,7 +268,14 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
}
int32_t status;
if (len >= 16) {
status = sercom_dma_write(self->spi_desc.dev.prvt, data, len);
size_t bytes_remaining = len;
// Maximum DMA transfer is 65535
while (bytes_remaining > 0) {
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;
}
} else {
struct io_descriptor *spi_io;
spi_m_sync_get_io_descriptor(&self->spi_desc, &spi_io);