1.10.21.6 1.11.21.6 1.12.22.6 1.13.20.6 1.14.15.6 1.15.16.6 1.16.22.6 1.17.18.6 1.18.18.6 1.19.18.6 1.20.22.6 1.21.23.6 1.22.25.6 1.23.23.6 1.24.20.6 1.27.22.6 1.34.20.6 1.35.13.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.