1.1.13.24 1.8.24.13 1.10.23.15 1.11.23.15 1.12.24.15 1.13.22.15 1.14.17.15 1.15.18.15 1.16.25.15 1.17.20.15 1.18.21.15 1.19.21.15 1.20.25.15 1.21.26.15 1.22.28.15 1.23.27.15 1.24.23.15 1.27.26.13 1.34.26.13 1.35.20.13 UARTx_ReadThresholdSet Function

C

/* x = UART instance number */

/* Ring buffer mode */
void UARTx_ReadThresholdSet(uint32_t nBytesThreshold)

Summary

This API allows the application to set a threshold level on the number of bytes of data available in the receive buffer

Description

This API allows the application to set a threshold level on the number of bytes of data available in the receive buffer. Once the threshold is reached a notification is given to the application if it is enabled.

Precondition

UARTx_Initialize must have been called for the associated UART instance.

Parameters

Param Description
nBytesThreshold Threshold value for number of bytes available in the receive buffer after which a notification must be given

Returns

None

Example

uint8_t rxBuffer[50];
uint32_t nBytes;

void usartReadEventHandler(UART_EVENT event, uintptr_t context )
{
    uint32_t nBytesAvailable = 0;
    
    if (event == UART_EVENT_READ_THRESHOLD_REACHED)
    {
        // Receiver should have the thershold number of bytes in the ring buffer
        nBytesAvailable = UART1_ReadCountGet();
        
        nBytesRead += UART1_Read((uint8_t*)&rxBuffer[nBytesRead], nBytesAvailable);
    }
}

//----------------------------------------------------------//

// Register a callback for read events
UART1_ReadCallbackRegister(usartReadEventHandler, (uintptr_t) NULL);

// Set a threshold value to receive a callback after every 10 characters are received
UART1_ReadThresholdSet(10);

// Enable RX event notifications
UART1_ReadNotificationEnable(true, false);

Remarks

None