Merge pull request #7673 from gamblor21/atmel-spi-tx-len-fix

Fix for long length SPI writes on ATMEL
This commit is contained in:
Jeff Epler 2023-03-04 09:21:27 -06:00 committed by GitHub
commit 4e169bb956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);