1.2.21.41 1.3.25.41 1.4.21.41 1.5.25.41 1.6.22.41 1.7.23.41 1.9.19.41 1.29.23.41 1.30.18.41 1.31.18.41 1.32.26.41 1.33.16.41 1.37.18.41 1.38.21.41 1.39.18.41 1.40.20.41 SERCOMx_SPI_Ready Function
C
/* x = SERCOM instance number */
/* SPI slave mode */
void SERCOMx_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 SERCOMx_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 (SERCOM0_SPI_ErrorGet() == SPI_SLAVE_ERROR_NONE) { nBytesRead = SERCOM0_SPI_Read(APP_RxData, SERCOM0_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 SERCOM0_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. SERCOM0_SPI_Ready(); } } }
Remarks
This API is available only if the Busy signal feature is enabled in MHC.