Quality RTOS & Embedded Software

AWS Reference Integrations
FreeRTOS security certification:
Embedded World track keynote:

xTaskNotifyFromISR / xTaskNotifyIndexedFromISR
[RTOS Task Notification API]


 BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify,
                                uint32_t ulValue,
                                eNotifyAction eAction,
                                BaseType_t *pxHigherPriorityTaskWoken );

BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );

Versions of xTaskNotify() and xTaskNotifyIndexed() that can be used from an interrupt service routine (ISR). See the documentation page for the xTaskNotify() API function for a description of their operation and the necessary configuration parameters, as well as backward compatibility information.

xTaskToNotify   The handle of the RTOS task being notified. This is the target task.



uxIndexToNotify   The index within the target task's array of notification values to which the notification is to be sent.

uxIndexToNotify must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.

xTaskNotifyFromISR() does not have this parameter and always sends notifications to index 0.

ulValue   Used to update the notification value of the target task. See the description of the eAction parameter below.
pxHigherPriorityTaskWoken   *pxHigherPriorityTaskWoken must be initialised to 0.



pxHigherPriorityTaskWoken is an optional parameter and can be set to NULL.

eAction Setting Action Performed
eNoAction The target task receives the event, but its notification value is not updated. In this case ulValue is not used.

eSetBits The notification value of the target task will be bitwise ORed with ulValue. For example, if ulValue is set to 0x01, then bit 0 will get set within the target task's notification value. Likewise if ulValue is 0x04 then bit 2 will get set in the target task's notification value. In this way the RTOS task notification mechanism can be used as a light weight alternative to an event group.

eIncrement The notification value of the target task will be incremented by one, making the call to xTaskNotifyFromISR() equivalent to a call to vTaskNotifyGiveFromISR(). In this case ulValue is not used.
eSetValueWithOverwrite The notification value of the target task is unconditionally set to ulValue. In this way the RTOS task notification mechanism is being used as a light weight alternative to xQueueOverwrite().
eSetValueWithoutOverwrite If the target task does not already have a notification pending then its notification value will be set to ulValue.



pdPASS is returned in all cases other than when eAction is set to eSetValueWithoutOverwrite and the target task's notification value cannot be updated because the target task already had a notification pending.

Example usage:



notification. */

void vANInterruptHandler( void )
BaseType_t xHigherPriorityTaskWoken;
uint32_t ulStatusRegister;


ulStatusRegister = ulReadPeripheralInterruptStatus();

/* Clear the interrupts. */
vClearPeripheralInterruptStatus( ulStatusRegister );

/* xHigherPriorityTaskWoken must be initialised to pdFALSE. If calling
xTaskNotifyFromISR() unblocks the handling task, and the priority of
then xHigherPriorityTaskWoken will automatically get set to pdTRUE. */

xHigherPriorityTaskWoken = pdFALSE;

when the task was created. The handling task's 0th notification value
set are not overwritten. */

xTaskNotifyIndexedFromISR( xHandlingTask,
&xHigherPriorityTaskWoken );


portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

do so. */

void vHandlingTask( void *pvParameters )
uint32_t ulInterruptStatus;

for( ;; )
should not block indefinitely, but instead time out occasionally in order
to handle error conditions that may prevent the interrupt from sending
any more notifications. */

xTaskNotifyWaitIndexed( 0, /* Wait for 0th Notificaition */
ULONG_MAX, /* Clear all bits on exit. */
&ulInterruptStatus, /* Receives the notification value. */
portMAX_DELAY ); /* Block indefinitely. */

and bit 3 for a buffer overrun interrupt. */

if( ( ulInterruptStatus & 0x01 ) != 0x00 )

if( ( ulInterruptStatus & 0x02 ) != 0x00 )

if( ( ulInterruptStatus & 0x04 ) != 0x00 )
