1.34.27.2 1.35.21.2 USARTx_WriteNotificationEnable Function
C
/* x = USART instance number */
/* Ring buffer mode */
bool USARTx_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
USARTx_Initialize must have been called for the associated 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 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(USART_EVENT event, uintptr_t context ) { txThresholdEventReceived = true; } //----------------------------------------------------------// // Register a callback for write events USART1_WriteCallbackRegister(usartWriteEventHandler, (uintptr_t) NULL); // Set TX threshold - TX buffer is empty USART1_WriteThresholdSet(USART1_WriteBufferSizeGet()); // Enable notifications. Disable persistent notifications. USART1_WriteNotificationEnable(true, false); USART1_Write((uint8_t*)txBuffer, nBytes); if (txThresholdEventReceived == true) { // Transmit buffer is empty }
Remarks
None