mimxrt10xx: Factor out "transfer_common"
.. and set the "MasterPcsContinuous" flag, which removes some of the gap between bytes of a single SPI transaction
This commit is contained in:
parent
ffb70a8737
commit
1d48054aea
|
@ -283,6 +283,21 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
|
||||||
self->has_lock = false;
|
self->has_lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static status_t transfer_common(busio_spi_obj_t *self, lpspi_transfer_t *xfer) {
|
||||||
|
xfer->configFlags = kLPSPI_MasterPcsContinuous;
|
||||||
|
|
||||||
|
status_t status;
|
||||||
|
int retries = MAX_SPI_BUSY_RETRIES;
|
||||||
|
do {
|
||||||
|
status = LPSPI_MasterTransferBlocking(self->spi, xfer);
|
||||||
|
} while (status == kStatus_LPSPI_Busy && --retries > 0);
|
||||||
|
|
||||||
|
if (status != kStatus_Success) {
|
||||||
|
printf("%s: status %ld\r\n", __func__, status);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
||||||
const uint8_t *data, size_t len) {
|
const uint8_t *data, size_t len) {
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
@ -295,17 +310,8 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
||||||
lpspi_transfer_t xfer = { 0 };
|
lpspi_transfer_t xfer = { 0 };
|
||||||
xfer.txData = (uint8_t *)data;
|
xfer.txData = (uint8_t *)data;
|
||||||
xfer.dataSize = len;
|
xfer.dataSize = len;
|
||||||
xfer.configFlags = kLPSPI_MasterPcs0;
|
|
||||||
|
|
||||||
status_t status;
|
status_t status = transfer_common(self, &xfer);
|
||||||
int retries = MAX_SPI_BUSY_RETRIES;
|
|
||||||
do {
|
|
||||||
status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
|
|
||||||
} while (status == kStatus_LPSPI_Busy && --retries > 0);
|
|
||||||
|
|
||||||
if (status != kStatus_Success) {
|
|
||||||
printf("%s: status %ld\r\n", __func__, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return status == kStatus_Success;
|
return status == kStatus_Success;
|
||||||
}
|
}
|
||||||
|
@ -325,15 +331,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
|
||||||
xfer.rxData = data;
|
xfer.rxData = data;
|
||||||
xfer.dataSize = len;
|
xfer.dataSize = len;
|
||||||
|
|
||||||
status_t status;
|
status_t status = transfer_common(self, &xfer);
|
||||||
int retries = MAX_SPI_BUSY_RETRIES;
|
|
||||||
do {
|
|
||||||
status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
|
|
||||||
} while (status == kStatus_LPSPI_Busy && --retries > 0);
|
|
||||||
|
|
||||||
if (status != kStatus_Success) {
|
|
||||||
printf("%s: status %ld\r\n", __func__, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return status == kStatus_Success;
|
return status == kStatus_Success;
|
||||||
}
|
}
|
||||||
|
@ -353,15 +351,7 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_ou
|
||||||
xfer.rxData = data_in;
|
xfer.rxData = data_in;
|
||||||
xfer.dataSize = len;
|
xfer.dataSize = len;
|
||||||
|
|
||||||
status_t status;
|
status_t status = transfer_common(self, &xfer);
|
||||||
int retries = MAX_SPI_BUSY_RETRIES;
|
|
||||||
do {
|
|
||||||
status = LPSPI_MasterTransferBlocking(self->spi, &xfer);
|
|
||||||
} while (status == kStatus_LPSPI_Busy && --retries > 0);
|
|
||||||
|
|
||||||
if (status != kStatus_Success) {
|
|
||||||
printf("%s: status %ld\r\n", __func__, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return status == kStatus_Success;
|
return status == kStatus_Success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue