1.36.7.2 FLEXCOMx_USART_WriteNotificationEnable Function

C

/* x = FLEXCOM instance number */

/* Ring buffer mode */

bool FLEXCOMx_USART_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

FLEXCOMx_USART_Initialize must have been called for the associated FLEXCOM_USART 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 disables persistent 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(FLEXCOM_USART_EVENT event, uintptr_t context )
{
    txThresholdEventReceived = true;
}

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

// Register a callback for write events
FLEXCOM0_USART_WriteCallbackRegister(usartWriteEventHandler, (uintptr_t) NULL);

// Set TX threshold - TX buffer is empty
FLEXCOM0_USART_WriteThresholdSet(FLEXCOM0_USART_WriteBufferSizeGet());

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

FLEXCOM0_USART_Write((uint8_t*)txBuffer, nBytes);

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

Remarks

None