FreeRTOS Tetris
|
Group that contains macros & functions for task notifications. More...
Modules | |
xTaskNotify | |
xTaskNotifyWait | |
xTaskNotifyGive | |
ulTaskNotifyTake | |
xTaskNotifyStateClear | |
Macros | |
#define | xTaskNotify(xTaskToNotify, ulValue, eAction) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) |
Send an event directly to and potentially unblock an RTOS task, and optionally update one of the receiving task’s notification values. More... | |
#define | xTaskNotifyAndQuery(xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) |
Performs the same operation as xTaskNotify() with the addition that it also returns the target task's prior notification value (the notification value as it was at the time the function is called, rather than when the function returns) in the additional pulPreviousNotifyValue parameter. More... | |
Functions | |
BaseType_t | xTaskGenericNotify (TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue) PRIVILEGED_FUNCTION |
Group that contains macros & functions for task notifications.
#define xTaskNotify | ( | xTaskToNotify, | |
ulValue, | |||
eAction | |||
) | xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL ) |
#include <task.h>
Send an event directly to and potentially unblock an RTOS task, and optionally update one of the receiving task’s notification values.
Each task has an array of 'task notifications' (or just 'notifications'), each of which has a state and a 32-bit value. A direct to task notification is an event sent directly to a task that can unblock the receiving task, and optionally update one of the receiving task’s notification values in a number of different ways. For example, a notification may overwrite one of the receiving task's notification values, or just set one or more bits in one of the receiving task's notification values.
xTaskNotify() is used to send an event directly to and potentially unblock an RTOS task, and optionally update one of the receiving task’s notification values in one of the following ways:
xTaskToNotify | The handle of the task being notified. The handle to a task can be returned from the xTaskCreate() API function used to create the task, and the handle of the currently running task can be obtained by calling xTaskGetCurrentTaskHandle(). |
ulValue | Data that can be sent with the notification. How the data is used depends on the value of the eAction parameter. |
eAction | Specifies how the notification updates the task's notification value, if at all. Valid values for eAction are as follows:
|
Example Usage:
#define xTaskNotifyAndQuery | ( | xTaskToNotify, | |
ulValue, | |||
eAction, | |||
pulPreviousNotifyValue | |||
) | xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) ) |
#include <task.h>
Performs the same operation as xTaskNotify() with the addition that it also returns the target task's prior notification value (the notification value as it was at the time the function is called, rather than when the function returns) in the additional pulPreviousNotifyValue
parameter.
xTaskToNotify | The handle of the task being notified. The handle to a task can be returned from the xTaskCreate() API function used to create the task, and the handle of the currently running task can be obtained by calling xTaskGetCurrentTaskHandle(). |
ulValue | Data that can be sent with the notification. How the data is used depends on the value of the eAction parameter. |
eAction | Specifies how the notification updates the task's notification value, if at all. Valid values for eAction are as follows:
|
pulPreviousNotificationValue | Can be used to pass out the subject task's notification value before any bits are modified by the notify function. |
Example Usage:
BaseType_t xTaskGenericNotify | ( | TaskHandle_t | xTaskToNotify, |
uint32_t | ulValue, | ||
eNotifyAction | eAction, | ||
uint32_t * | pulPreviousNotificationValue | ||
) |
#include <task.h>
When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private "notification value", which is a 32-bit unsigned integer (uint32_t).
Events can be sent to a task using an intermediary object. Examples of such objects are queues, semaphores, mutexes and event groups. Task notifications are a method of sending an event directly to a task without the need for such an intermediary object.
A notification sent to a task can optionally perform an action, such as update, overwrite or increment the task's notification value. In that way task notifications can be used to send data to a task, or be used as light weight and fast binary or counting semaphores.
A notification sent to a task will remain pending until it is cleared by the task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was already in the Blocked state to wait for a notification when the notification arrives then the task will automatically be removed from the Blocked state (unblocked) and the notification cleared.
A task can use xTaskNotifyWait() to [optionally] block to wait for a notification to be pending, or ulTaskNotifyTake() to [optionally] block to wait for its notification value to have a non-zero value. The task does not consume any CPU time while it is in the Blocked state.
xTaskToNotify | The handle of the task being notified. The handle to a task can be returned from the xTaskCreate() API function used to create the task, and the handle of the currently running task can be obtained by calling xTaskGetCurrentTaskHandle(). |
ulValue | Data that can be sent with the notification. How the data is used depends on the value of the eAction parameter. |
eAction | Specifies how the notification updates the task's notification value, if at all. Valid values for eAction are as follows:
|
pulPreviousNotificationValue | Can be used to pass out the subject task's notification value before any bits are modified by the notify function. |
eAction
parameter.