1.17.18.6 SPIx_ReadCountGet Function
C
/* x = SPI instance number */
/* SPI slave mode */
size_t SPIx_ReadCountGet(void)
Summary
Returns the number of bytes pending to be read out from the PLIB's internal 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 SPIx_Read API.
Precondition
The SPIx_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 (SPI1_ErrorGet() == SPI_SLAVE_ERROR_NONE) { nBytesAvailable = SPI1_ReadCountGet(); nBytesRead = SPI1_Read(APP_RxData, nBytesAvailable); } else { // Handle error } } SPI1_CallbackRegister(SPIEventHandler, (uintptr_t) 0);
Remarks
None.