1.25.5.14 1.26.4.14 DBGU_ReadNotificationEnable Function
C
/* Ring buffer mode */
bool DBGU_ReadNotificationEnable(bool isEnabled, bool isPersistent)
Summary
This API lets the application turn the receive notifications on/off
Description
This API allows the application to enable or disable receive notifications. Further the application can choose to get notified persistently until the threshold condition is true. For example, if the receive threshold is set to 5, a notification is given when the internal receive buffer has 5 bytes. If persistent notification is turned off, the application is notified only once when there are 5 unread bytes in the receive buffer. However, if persistent notification is turned on, the application is notified every time a byte is received and the receive buffer has 5 or more unread characters. In this case, the notification will be stopped, when the application reads data out from the receive buffer and the number of bytes pedning in the receive buffer becomes less than 5.
Precondition
DBGU_Initialize must have been called for the associated DBGU 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 rxBuffer[50]; uint32_t nBytes; void usartReadEventHandler(DBGU_EVENT event, uintptr_t context ) { uint32_t nBytesAvailable = 0; if (event == DBGU_EVENT_READ_THRESHOLD_REACHED) { // Receiver should have the thershold number of bytes in the receive buffer nBytesAvailable = DBGU_ReadCountGet(); nBytesRead += DBGU_Read((uint8_t*)&rxBuffer[nBytesRead], nBytesAvailable); } } //----------------------------------------------------------// // Register a callback for read events DBGU_ReadCallbackRegister(usartReadEventHandler, (uintptr_t) NULL); // Set a threshold value to receive a callback after every 10 characters are received DBGU_ReadThresholdSet(10); // Enable RX event notifications DBGU_ReadNotificationEnable(true, false);
Remarks
None