1.1.13.19 1.8.24.2 1.10.23.4 1.11.23.4 1.12.24.4 1.13.22.4 1.14.17.4 1.15.18.4 1.16.25.4 1.17.20.4 1.18.21.4 1.19.21.4 1.20.25.4 1.21.26.4 1.22.28.4 1.23.27.4 1.24.23.4 1.27.26.2 1.34.26.2 1.35.20.2 UARTx_WriteNotificationEnable Function

C

/* x = UART instance number */

/* Ring buffer mode */
bool UARTx_WriteNotificationEnable(bool isEnabled, bool isPersistent)

Summary

This API lets the application turn the transmit notifications on/off

Description

This API allows the application to enable or disable transmit notifications. Further the application can choose to get notified persistently until the threshold condition is true. For example, if the transmit threshold is set to 5, which means a notification is given when the internal transmit buffer has free space for at-least 5 characters. If persistent notification is turned off, the application is notified only once when there is free space for 5 characters in the transmit buffer. However, if persistent notification is turned on, the application is notified every time a byte is transmitted out and the transmit buffer has free space for 5 or more characters.

Precondition

UARTx_Initialize must have been called for the associated UART instance.

Parameters

Param Description
isEnabled A true value turns on notification, false value turns off notification
isPersistent A true value turns on persistent notification. A false value disablespersistent notifications

Returns

The API returns the previous state of notifications. A true value indicates notifications were previously enabled; false value indicates notifications were perviously disabled.

Example

uint8_t txBuffer[50];
uint32_t nBytes;

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 - TX buffer is empty
UART1_WriteThresholdSet(UART1_WriteBufferSizeGet());

// Enable notifications. Disable persistent notifications.
UART1_WriteNotificationEnable(true, false);

UART1_Write((uint8_t*)txBuffer, nBytes);

if (txThresholdEventReceived == true)
{
    // Transmit buffer is empty
}

Remarks

None