Synopsis
CTL_STATUS_t ctl_spi_exchange(CTL_SPI_DEVICE_t *self,
                              const void *tx,
                              void *rx,
                              size_t items);
Description

ctl_spi_exchange simultaneously writes to and reads from the SPI device self which must have been selected onto the bus by ctl_spi_select_device.

If the selected frame width for the device self is eight bits or narrower, items bytes are written from tx and items bytes are read from the SPI bus to rx. If the transfer width is nine bits or wider then shorts are used rather than bytes.

If tx is zero, the set idle-pattern is written to the SPI device (if the the underlying driver supports such a null transfer). Note that some SPI drivers which use DMA may not support null transfers.

If rx is zero, data are read from the SPI bus and discarded if the underlying driver supports such a null transfer. Note that some SPI drivers which use DMA may not support null transfers.