mimxrt/machine_spi: Ignore transfers with len=0.
It was treated as an error before. The error surfaced when using the NINAW10 drivers for WiFi support. Even if this is a bad behavior of the NINA driver, machine_spi can be forgiving in that situation.
This commit is contained in:
parent
d2a02dcee3
commit
14b862f70f
@ -240,17 +240,19 @@ STATIC void machine_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj
|
||||
STATIC void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
|
||||
machine_spi_obj_t *self = (machine_spi_obj_t *)self_in;
|
||||
|
||||
// Wait a short while for the previous transfer to finish, but not forever
|
||||
for (volatile int j = 0; (j < 5000) && ((self->spi_inst->SR & kLPSPI_ModuleBusyFlag) != 0); j++) {}
|
||||
if (len > 0) {
|
||||
// Wait a short while for the previous transfer to finish, but not forever
|
||||
for (volatile int j = 0; (j < 5000) && ((self->spi_inst->SR & kLPSPI_ModuleBusyFlag) != 0); j++) {}
|
||||
|
||||
lpspi_transfer_t masterXfer;
|
||||
masterXfer.txData = (uint8_t *)src;
|
||||
masterXfer.rxData = (uint8_t *)dest;
|
||||
masterXfer.dataSize = len;
|
||||
masterXfer.configFlags = (self->master_config->whichPcs << LPSPI_MASTER_PCS_SHIFT) | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;
|
||||
lpspi_transfer_t masterXfer;
|
||||
masterXfer.txData = (uint8_t *)src;
|
||||
masterXfer.rxData = (uint8_t *)dest;
|
||||
masterXfer.dataSize = len;
|
||||
masterXfer.configFlags = (self->master_config->whichPcs << LPSPI_MASTER_PCS_SHIFT) | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;
|
||||
|
||||
if (LPSPI_MasterTransferBlocking(self->spi_inst, &masterXfer) != kStatus_Success) {
|
||||
mp_raise_OSError(EIO);
|
||||
if (LPSPI_MasterTransferBlocking(self->spi_inst, &masterXfer) != kStatus_Success) {
|
||||
mp_raise_OSError(EIO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user