1.8.7.39 1.25.6.39 1.26.5.39 1.27.5.39 1.28.6.39 1.36.7.37 1.41.5.39 1.42.3.39 FLEXCOMx_SPI_Ready Function
C
/* x = FLEXCOM instance number */
/* SPI slave mode */
void FLEXCOMx_SPI_Ready(void)
Summary
Drives the SPI slave busy line to ready (not busy) state
Description
This function drives the SPI slave busy line to ready state. The slave busy line is driven to active state (busy) when the chip select is driven active by the SPI master. When the data transfer is complete, the chip select is driven inactive and a callback is given to the application. The application can parse the received data and prepare a response for the SPI master. Once the response is ready, the SPI slave can release the busy line by calling this API which drives the busy line to inactive state (not busy). All this while the SPI master must wait for the busy line to become inactive (not busy) before initiating a new transfer with the SPI slave.
Precondition
The FLEXCOMx_SPI_Initialize() should have been called.
Parameters
None
Returns
None
Example
uint8_t APP_TxData[10]; size_t nBytesRead; void SPIEventHandler(uintptr_t context ) { if (FLEXCOM0_SPI_ErrorGet() == FLEXCOM_SPI_SLAVE_ERROR_NONE) { nBytesRead = FLEXCOM0_SPI_Read(APP_RxData, FLEXCOM0_SPI_ReadCountGet()); switch(APP_RxData[0]) { case APP_CMD_WRITE: // SPI master is writing data to SPI slave // Keep the busy line asserted until the write operation is complete // Busy line will be de-asserted later when the write operation is complete appData.status.busy = 1; // Change the state to perform write operation state = APP_STATE_WRITE; break; case APP_CMD_READ: // SPI master is reading data from SPI slave // Provide the requested data and drive the busy line inactive FLEXCOM0_SPI_Write(APP_TxData, 10); break; } if (appData.status.busy == 0) { // Indicate to SPI Master that slave is ready for data transfer // This if condition will be executed for the APP_CMD_READ case. FLEXCOM0_SPI_Ready(); } } }
Remarks
This API is available only if the Busy signal feature is enabled in MHC.