1.8.7.40 1.25.6.40 1.26.5.40 1.27.5.40 1.28.6.40 1.36.7.38 1.41.5.40 1.42.3.40 FLEXCOMx_SPI_ReadCountGet Function
C
/* x = FLEXCOM instance number */
/* SPI slave mode */
size_t FLEXCOMx_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 FLEXCOMx_SPI_Read API.
Precondition
The FLEXCOMx_SPI_Initialize function must have been called
Parameters
None
Returns
size_t - Number of bytes available in the PLIB's internal receive buffer. If 16/32 bit modes are supported, the return value is specified in terms of 16/32 bit words.
Example
uint8_t APP_RxData[10]; size_t nBytesAvailable; size_t nBytesRead; void SPIEventHandler(uintptr_t context ) { if (FLEXCOM0_SPI_ErrorGet() == SPI_SLAVE_ERROR_NONE) { nBytesAvailable = FLEXCOM0_SPI_ReadCountGet(); nBytesRead = FLEXCOM0_SPI_Read(APP_RxData, nBytesAvailable); } else { // Handle error } } FLEXCOM0_SPI_CallbackRegister(SPIEventHandler, (uintptr_t) 0);
Remarks
None.