19.6.4.5.5 Function spi_transceive_wait()

Sends and reads a single SPI character.

enum status_code spi_transceive_wait( struct spi_module *const module, uint16_t tx_data, uint16_t * rx_data)

This function will transfer a single SPI character via SPI and return the SPI character that is shifted into the shift register.

In master mode the SPI character will be sent immediately and the received SPI character will be read as soon as the shifting of the data is complete.

In slave mode this function will place the data to be sent into the transmit buffer. It will then block until an SPI master has shifted a complete SPI character, and the received data is available.

Note: The data to be sent might not be sent before the next transfer, as loading of the shift register is dependent on SCK.
Note: If address matching is enabled for the slave, the first character received and placed in the buffer will be the address.
Table 19-35. Parameters
Data directionParameter nameDescription

[in]

module

Pointer to the software instance struct

[in]

tx_data

SPI character to transmit

[out]

rx_data

Pointer to store the received SPI character

Returns

Status of the operation.

Table 19-36. Return Values
Return valueDescription

STATUS_OK

If the operation was completed

STATUS_ERR_TIMEOUT

If the operation was not completed within the timeout in slave mode

STATUS_ERR_DENIED

If the receiver is not enabled

STATUS_ERR_OVERFLOW

If the incoming data is overflown