1.1.13.20 1.8.24.1 1.10.23.3 1.11.23.3 1.12.24.3 1.13.22.3 1.14.17.3 1.15.18.3 1.16.25.3 1.17.20.3 1.18.21.3 1.19.21.3 1.20.25.3 1.21.26.3 1.22.28.3 1.23.27.3 1.24.23.3 1.27.26.1 1.34.26.1 1.35.20.1 UARTx_WriteThresholdSet Function
C
/* x = UART instance number */
/* Ring buffer mode */
void UARTx_WriteThresholdSet(uint32_t nBytesThreshold)
Summary
This API allows the application to set a threshold level on the number of free space available in the transmit buffer
Description
This API allows the application to set a threshold level on the number of free space available in the transmit 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 free space in the transmit buffer afterwhich a notification must be given |
Returns
None
Example
uint8_t txBuffer[10]; volatile bool txThresholdEventReceived = false; void usartWriteEventHandler(UART_EVENT event, uintptr_t context ) { txThresholdEventReceived = true; } //----------------------------------------------------------// // Register a callback for write events UART1_WriteCallbackRegister(usartWriteEventHandler, (uintptr_t) NULL); // Set TX threshold - 10 or more bytes of free space in the transmit buffer UART1_WriteThresholdSet(10); // Enable notifications. Disable persistent notifications. UART1_WriteNotificationEnable(true, false); // First time transmit 5 bytes UART1_Write((uint8_t*)txBuffer, 5); if (txThresholdEventReceived == true) { // Transmit buffer has space for 10 or more characters UART1_Write((uint8_t*)txBuffer, 10); }
Remarks
None