1.1.13.8 1.8.24.17 1.10.23.19 1.11.23.19 1.12.24.19 1.13.22.19 1.14.17.19 1.15.18.19 1.16.25.19 1.17.20.19 1.18.21.19 1.19.21.19 1.20.25.19 1.21.26.19 1.22.28.19 1.23.27.19 1.24.23.19 1.27.26.17 1.34.26.17 1.35.20.17 UARTx_ReadCountGet Function
C
/* x = UART instance number */
/* Non-blocking and ring buffer mode */
size_t UARTx_ReadCountGet( void )
Summary
Non-blocking mode
Gets the byte count of processed bytes for a given UART read operation
Ring buffer mode
Returns the number of bytes available in the internal receive buffer of the PLIB
Description
Non-blocking mode
This function gets the count of processed bytes for an on-going or last completed UART Read operation. This function can be used to track the progress of the non-blocking read operation. In case of an error, this function can be used to track the number of bytes that were received before the error occurred.
Ring buffer mode
This function returns the number of bytes available in the receive buffer
Precondition
UARTx_Initialize must have been called for the associated UART instance.
Parameters
None.
Returns
Non-blocking mode
Returns count of bytes completed/processed to the current Receive buffer. In 9-bit mode, it returns the number of 9-bit data processed.
Ring buffer mode
The API returns the number of bytes pending to be read out from the receive buffer. If 9-bit mode is enabled, then the API returns the number of 9-bit data pending to be read out from the receive buffer.
Example
Non-blocking mode
size_t count; count = UART1_ReadCountGet(); if(count < COUNT_EXPECTED) { //More bytes are expected, wait }
Ring buffer mode
uint8_t rxBuffer[100]; uint32_t nBytesAvailable; nBytesAvailable = UART1_ReadCountGet(); if (nBytesAvailable != 0) { UART1_Read((uint8_t*)rxBuffer, nBytesAvailable) }
Remarks
None