Skip to content

Commit 127cc62

Browse files
committed
adds: idle loop to wait for SPI not busy (mimxrt10xx)
1 parent a10ce39 commit 127cc62

File tree

1 file changed

+15
-3
lines changed
  • ports/mimxrt10xx/common-hal/busio

1 file changed

+15
-3
lines changed

ports/mimxrt10xx/common-hal/busio/SPI.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
289289
xfer.dataSize = len;
290290
xfer.configFlags = kLPSPI_MasterPcs0;
291291

292-
const status_t status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
292+
status_t status;
293+
do {
294+
status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
295+
} while (status == kStatus_LPSPI_Busy);
296+
293297
if (status != kStatus_Success)
294298
printf("%s: status %ld\r\n", __func__, status);
295299

@@ -311,7 +315,11 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
311315
xfer.rxData = data;
312316
xfer.dataSize = len;
313317

314-
const status_t status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
318+
status_t status;
319+
do {
320+
status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
321+
} while (status == kStatus_LPSPI_Busy);
322+
315323
if (status != kStatus_Success)
316324
printf("%s: status %ld\r\n", __func__, status);
317325

@@ -333,7 +341,11 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_ou
333341
xfer.rxData = data_in;
334342
xfer.dataSize = len;
335343

336-
const status_t status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
344+
status_t status;
345+
do {
346+
status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
347+
} while (status == kStatus_LPSPI_Busy);
348+
337349
if (status != kStatus_Success)
338350
printf("%s: status %ld\r\n", __func__, status);
339351

0 commit comments

Comments
 (0)