1.2.21.42 1.3.25.42 1.4.21.42 1.5.25.42 1.6.22.42 1.7.23.42 1.9.19.42 1.29.23.42 1.30.18.42 1.31.18.42 1.32.26.42 1.33.16.42 1.37.18.42 1.38.21.42 1.39.18.42 1.40.20.42 SERCOMx_SPI_ReadCountGet Function
C
/* x = SERCOM instance number */
/* SPI slave mode */
size_t SERCOMx_SPI_ReadCountGet(void)
Summary
Returns the number of bytes pending to be read out from the PLIB's internal receive buffer
Description
This function returns the number of unread bytes availabe in the SPI slave PLIB's internal receive buffer. Application can call this API to know the bytes available in PLIBs internal buffer before calling the SERCOMx_SPI_Read API.
Precondition
The SERCOMx_SPI_Initialize function must have been called
Parameters
None
Returns
size_t - Number of bytes available in the PLIB's internal receive buffer
Example
uint8_t APP_RxData[10]; size_t nBytesAvailable; size_t nBytesRead; void SPIEventHandler(uintptr_t context ) { if (SERCOM0_SPI_ErrorGet() == SPI_SLAVE_ERROR_NONE) { nBytesAvailable = SERCOM0_SPI_ReadCountGet(); nBytesRead = SERCOM0_SPI_Read(APP_RxData, nBytesAvailable); } else { // Handle error } } SERCOM0_SPI_CallbackRegister(SPIEventHandler, (uintptr_t) 0);
Remarks
None.