mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 00:57:44 -04:00
Change the previously single ulNotifiedValue and ucNotifyState members of the TCB into an array dimensioned by the new configNUMBER_OF_TASK_NOTIFICATIONS, after which each task can optionally have zero or more task notifications values and states that can be used individually.
Default configNUMBER_OF_TASK_NOTIFICATIONS to 1 if it is left undefined so the default behaviour is to have one task notification, as per previous versions of code. Update all the task notification API functions to accept the index of the task notification being used. This has required the introduction of 'generic' versions of some functions, with the pre-exisitng API functions being converted to macros that call the generic version of the API function with the index set to 0 for backward compatibility. Not yet added functions that can use anything other than the first task notification slot.
This commit is contained in:
parent
9dbc7afd4c
commit
a0906b60e5
3 changed files with 121 additions and 77 deletions
|
@ -834,6 +834,10 @@ hold explicit before calling the code. */
|
|||
#define configUSE_TASK_NOTIFICATIONS 1
|
||||
#endif
|
||||
|
||||
#ifndef configNUMBER_OF_TASK_NOTIFICATIONS
|
||||
#define configNUMBER_OF_TASK_NOTIFICATIONS 1
|
||||
#endif
|
||||
|
||||
#ifndef configUSE_POSIX_ERRNO
|
||||
#define configUSE_POSIX_ERRNO 0
|
||||
#endif
|
||||
|
|
|
@ -56,6 +56,13 @@ extern "C" {
|
|||
#define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL )
|
||||
#define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL )
|
||||
|
||||
/* The direct to task notification feature used to have only a single notification
|
||||
per task. Now there is an array of notifications per task that is dimensioned by
|
||||
configNUMBER_OF_TASK_NOTIFICATIONS. For backward compatibility, any use of the
|
||||
original direct to task notification defaults to using the first index in the
|
||||
array. */
|
||||
#define tskDEFAULT_INDEX_TO_NOTIFY ( 0 )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
*
|
||||
|
@ -1850,9 +1857,9 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
|
|||
* \defgroup xTaskNotify xTaskNotify
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
|
||||
#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
|
||||
#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
|
||||
BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
|
||||
#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
|
||||
#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -1941,9 +1948,9 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo
|
|||
* \defgroup xTaskNotify xTaskNotify
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
|
||||
#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
|
||||
BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
|
||||
#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -2018,7 +2025,8 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulVal
|
|||
* \defgroup xTaskNotifyWait xTaskNotifyWait
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWait, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
#define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -2064,7 +2072,7 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea
|
|||
* \defgroup xTaskNotifyGive xTaskNotifyGive
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )
|
||||
#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -2119,7 +2127,8 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClea
|
|||
* \defgroup xTaskNotifyWait xTaskNotifyWait
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
|
||||
#define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -2188,7 +2197,8 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri
|
|||
* \defgroup ulTaskNotifyTake ulTaskNotifyTake
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWait, BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
|
||||
#define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -2204,7 +2214,8 @@ uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait
|
|||
* \defgroup xTaskNotifyStateClear xTaskNotifyStateClear
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
|
||||
BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
|
||||
#define xTaskNotifyStateClear( xTask ) xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
|
||||
|
||||
/**
|
||||
* task. h
|
||||
|
@ -2232,7 +2243,8 @@ BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
|
|||
* \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
|
||||
* \ingroup TaskNotifications
|
||||
*/
|
||||
uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
|
||||
#define ulTaskNotifyValueClear( xTask, ulBitsToClear ) ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
|
||||
|
||||
/**
|
||||
* task.h
|
||||
|
|
158
tasks.c
158
tasks.c
|
@ -65,7 +65,7 @@ functions but without including stdio.h here. */
|
|||
#endif
|
||||
|
||||
/* Values that can be assigned to the ucNotifyState member of the TCB. */
|
||||
#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 )
|
||||
#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 ) /* Must be zero as it is the initialised value. */
|
||||
#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 )
|
||||
#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 )
|
||||
|
||||
|
@ -308,8 +308,8 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to pr
|
|||
#endif
|
||||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
volatile uint32_t ulNotifiedValue;
|
||||
volatile uint8_t ucNotifyState;
|
||||
volatile uint32_t ulNotifiedValue[ configNUMBER_OF_TASK_NOTIFICATIONS ];
|
||||
volatile uint8_t ucNotifyState[ configNUMBER_OF_TASK_NOTIFICATIONS ];
|
||||
#endif
|
||||
|
||||
/* See the comments in FreeRTOS.h with the definition of
|
||||
|
@ -980,17 +980,14 @@ UBaseType_t x;
|
|||
|
||||
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
|
||||
{
|
||||
for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ )
|
||||
{
|
||||
pxNewTCB->pvThreadLocalStoragePointers[ x ] = NULL;
|
||||
}
|
||||
memset( ( void * ) &( pxNewTCB->pvThreadLocalStoragePointers[ 0 ] ), 0x00, sizeof( pxNewTCB->pvThreadLocalStoragePointers ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
{
|
||||
pxNewTCB->ulNotifiedValue = 0;
|
||||
pxNewTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;
|
||||
memset( ( void * ) &( pxNewTCB->ulNotifiedValue[ 0 ] ), 0x00, sizeof( pxNewTCB->ulNotifiedValue ) );
|
||||
memset( ( void * ) &( pxNewTCB->ucNotifyState[ 0 ] ), 0x00, sizeof( pxNewTCB->ucNotifyState ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1423,17 +1420,21 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
|
|||
{
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
{
|
||||
BaseType_t x;
|
||||
|
||||
/* The task does not appear on the event list item of
|
||||
and of the RTOS objects, but could still be in the
|
||||
blocked state if it is waiting on its notification
|
||||
rather than waiting on an object. */
|
||||
if( pxTCB->ucNotifyState == taskWAITING_NOTIFICATION )
|
||||
rather than waiting on an object. If not, is
|
||||
suspended. */
|
||||
eReturn = eSuspended;
|
||||
for( x = 0; x < configNUMBER_OF_TASK_NOTIFICATIONS; x++ )
|
||||
{
|
||||
eReturn = eBlocked;
|
||||
}
|
||||
else
|
||||
{
|
||||
eReturn = eSuspended;
|
||||
if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION )
|
||||
{
|
||||
eReturn = eBlocked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -1738,11 +1739,16 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
{
|
||||
if( pxTCB->ucNotifyState == taskWAITING_NOTIFICATION )
|
||||
BaseType_t x;
|
||||
|
||||
for( x = 0; x < configNUMBER_OF_TASK_NOTIFICATIONS; x++ )
|
||||
{
|
||||
/* The task was blocked to wait for a notification, but is
|
||||
now suspended, so no notification was received. */
|
||||
pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;
|
||||
if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION )
|
||||
{
|
||||
/* The task was blocked to wait for a notification, but is
|
||||
now suspended, so no notification was received. */
|
||||
pxTCB->ucNotifyState[ x ] = taskNOT_WAITING_NOTIFICATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -4635,17 +4641,19 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )
|
||||
uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWait, BaseType_t xClearCountOnExit, TickType_t xTicksToWait )
|
||||
{
|
||||
uint32_t ulReturn;
|
||||
|
||||
configASSERT( uxIndexToWait < configNUMBER_OF_TASK_NOTIFICATIONS );
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
/* Only block if the notification count is not already non-zero. */
|
||||
if( pxCurrentTCB->ulNotifiedValue == 0UL )
|
||||
if( pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] == 0UL )
|
||||
{
|
||||
/* Mark this task as waiting for a notification. */
|
||||
pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION;
|
||||
pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskWAITING_NOTIFICATION;
|
||||
|
||||
if( xTicksToWait > ( TickType_t ) 0 )
|
||||
{
|
||||
|
@ -4672,18 +4680,18 @@ TickType_t uxReturn;
|
|||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
traceTASK_NOTIFY_TAKE();
|
||||
ulReturn = pxCurrentTCB->ulNotifiedValue;
|
||||
traceTASK_NOTIFY_TAKE( uxIndexToWait );
|
||||
ulReturn = pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ];
|
||||
|
||||
if( ulReturn != 0UL )
|
||||
{
|
||||
if( xClearCountOnExit != pdFALSE )
|
||||
{
|
||||
pxCurrentTCB->ulNotifiedValue = 0UL;
|
||||
pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] = 0UL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pxCurrentTCB->ulNotifiedValue = ulReturn - ( uint32_t ) 1;
|
||||
pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] = ulReturn - ( uint32_t ) 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -4691,7 +4699,7 @@ TickType_t uxReturn;
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;
|
||||
pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskNOT_WAITING_NOTIFICATION;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
|
@ -4703,22 +4711,28 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait )
|
||||
BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWait,
|
||||
uint32_t ulBitsToClearOnEntry,
|
||||
uint32_t ulBitsToClearOnExit,
|
||||
uint32_t *pulNotificationValue,
|
||||
TickType_t xTicksToWait )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
configASSERT( uxIndexToWait < configNUMBER_OF_TASK_NOTIFICATIONS );
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
/* Only block if a notification is not already pending. */
|
||||
if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED )
|
||||
if( pxCurrentTCB->ucNotifyState[ uxIndexToWait ] != taskNOTIFICATION_RECEIVED )
|
||||
{
|
||||
/* Clear bits in the task's notification value as bits may get
|
||||
set by the notifying task or interrupt. This can be used to
|
||||
clear the value to zero. */
|
||||
pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry;
|
||||
pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] &= ~ulBitsToClearOnEntry;
|
||||
|
||||
/* Mark this task as waiting for a notification. */
|
||||
pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION;
|
||||
pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskWAITING_NOTIFICATION;
|
||||
|
||||
if( xTicksToWait > ( TickType_t ) 0 )
|
||||
{
|
||||
|
@ -4745,20 +4759,20 @@ TickType_t uxReturn;
|
|||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
traceTASK_NOTIFY_WAIT();
|
||||
traceTASK_NOTIFY_WAIT( uxIndexToWait );
|
||||
|
||||
if( pulNotificationValue != NULL )
|
||||
{
|
||||
/* Output the current notification value, which may or may not
|
||||
have changed. */
|
||||
*pulNotificationValue = pxCurrentTCB->ulNotifiedValue;
|
||||
*pulNotificationValue = pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ];
|
||||
}
|
||||
|
||||
/* If ucNotifyValue is set then either the task never entered the
|
||||
blocked state (because a notification was already pending) or the
|
||||
task unblocked because of a notification. Otherwise the task
|
||||
unblocked because of a timeout. */
|
||||
if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED )
|
||||
if( pxCurrentTCB->ucNotifyState[ uxIndexToWait ] != taskNOTIFICATION_RECEIVED )
|
||||
{
|
||||
/* A notification was not received. */
|
||||
xReturn = pdFALSE;
|
||||
|
@ -4767,11 +4781,11 @@ TickType_t uxReturn;
|
|||
{
|
||||
/* A notification was already pending or a notification was
|
||||
received while the task was waiting. */
|
||||
pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnExit;
|
||||
pxCurrentTCB->ulNotifiedValue[ uxIndexToWait ] &= ~ulBitsToClearOnExit;
|
||||
xReturn = pdTRUE;
|
||||
}
|
||||
|
||||
pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;
|
||||
pxCurrentTCB->ucNotifyState[ uxIndexToWait ] = taskNOT_WAITING_NOTIFICATION;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
|
@ -4783,12 +4797,17 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue )
|
||||
BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
|
||||
UBaseType_t uxIndexToNotify,
|
||||
uint32_t ulValue,
|
||||
eNotifyAction eAction,
|
||||
uint32_t *pulPreviousNotificationValue )
|
||||
{
|
||||
TCB_t * pxTCB;
|
||||
BaseType_t xReturn = pdPASS;
|
||||
uint8_t ucOriginalNotifyState;
|
||||
|
||||
configASSERT( uxIndexToNotify < configNUMBER_OF_TASK_NOTIFICATIONS );
|
||||
configASSERT( xTaskToNotify );
|
||||
pxTCB = xTaskToNotify;
|
||||
|
||||
|
@ -4796,31 +4815,31 @@ TickType_t uxReturn;
|
|||
{
|
||||
if( pulPreviousNotificationValue != NULL )
|
||||
{
|
||||
*pulPreviousNotificationValue = pxTCB->ulNotifiedValue;
|
||||
*pulPreviousNotificationValue = pxTCB->ulNotifiedValue[ uxIndexToNotify ];
|
||||
}
|
||||
|
||||
ucOriginalNotifyState = pxTCB->ucNotifyState;
|
||||
ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ];
|
||||
|
||||
pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;
|
||||
pxTCB->ucNotifyState[ uxIndexToNotify ] = taskNOTIFICATION_RECEIVED;
|
||||
|
||||
switch( eAction )
|
||||
{
|
||||
case eSetBits :
|
||||
pxTCB->ulNotifiedValue |= ulValue;
|
||||
pxTCB->ulNotifiedValue[ uxIndexToNotify ] |= ulValue;
|
||||
break;
|
||||
|
||||
case eIncrement :
|
||||
( pxTCB->ulNotifiedValue )++;
|
||||
( pxTCB->ulNotifiedValue[ uxIndexToNotify ] )++;
|
||||
break;
|
||||
|
||||
case eSetValueWithOverwrite :
|
||||
pxTCB->ulNotifiedValue = ulValue;
|
||||
pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue;
|
||||
break;
|
||||
|
||||
case eSetValueWithoutOverwrite :
|
||||
if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED )
|
||||
{
|
||||
pxTCB->ulNotifiedValue = ulValue;
|
||||
pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4838,7 +4857,7 @@ TickType_t uxReturn;
|
|||
/* Should not get here if all enums are handled.
|
||||
Artificially force an assert by testing a value the
|
||||
compiler can't assume is const. */
|
||||
configASSERT( pxTCB->ulNotifiedValue == ~0UL );
|
||||
configASSERT( pxTCB->ulNotifiedValue[ uxIndexToNotify ] == ~0UL );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -4897,7 +4916,12 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken )
|
||||
BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
|
||||
UBaseType_t uxIndexToNotify,
|
||||
uint32_t ulValue,
|
||||
eNotifyAction eAction,
|
||||
uint32_t *pulPreviousNotificationValue,
|
||||
BaseType_t *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
TCB_t * pxTCB;
|
||||
uint8_t ucOriginalNotifyState;
|
||||
|
@ -4905,6 +4929,7 @@ TickType_t uxReturn;
|
|||
UBaseType_t uxSavedInterruptStatus;
|
||||
|
||||
configASSERT( xTaskToNotify );
|
||||
configASSERT( uxIndexToNotify < configNUMBER_OF_TASK_NOTIFICATIONS );
|
||||
|
||||
/* RTOS ports that support interrupt nesting have the concept of a
|
||||
maximum system call (or maximum API call) interrupt priority.
|
||||
|
@ -4930,30 +4955,30 @@ TickType_t uxReturn;
|
|||
{
|
||||
if( pulPreviousNotificationValue != NULL )
|
||||
{
|
||||
*pulPreviousNotificationValue = pxTCB->ulNotifiedValue;
|
||||
*pulPreviousNotificationValue = pxTCB->ulNotifiedValue[ uxIndexToNotify ];
|
||||
}
|
||||
|
||||
ucOriginalNotifyState = pxTCB->ucNotifyState;
|
||||
pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;
|
||||
ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ];
|
||||
pxTCB->ucNotifyState[ uxIndexToNotify ] = taskNOTIFICATION_RECEIVED;
|
||||
|
||||
switch( eAction )
|
||||
{
|
||||
case eSetBits :
|
||||
pxTCB->ulNotifiedValue |= ulValue;
|
||||
pxTCB->ulNotifiedValue[ uxIndexToNotify ] |= ulValue;
|
||||
break;
|
||||
|
||||
case eIncrement :
|
||||
( pxTCB->ulNotifiedValue )++;
|
||||
( pxTCB->ulNotifiedValue[ uxIndexToNotify ] )++;
|
||||
break;
|
||||
|
||||
case eSetValueWithOverwrite :
|
||||
pxTCB->ulNotifiedValue = ulValue;
|
||||
pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue;
|
||||
break;
|
||||
|
||||
case eSetValueWithoutOverwrite :
|
||||
if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED )
|
||||
{
|
||||
pxTCB->ulNotifiedValue = ulValue;
|
||||
pxTCB->ulNotifiedValue[ uxIndexToNotify ] = ulValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4971,7 +4996,7 @@ TickType_t uxReturn;
|
|||
/* Should not get here if all enums are handled.
|
||||
Artificially force an assert by testing a value the
|
||||
compiler can't assume is const. */
|
||||
configASSERT( pxTCB->ulNotifiedValue == ~0UL );
|
||||
configASSERT( pxTCB->ulNotifiedValue[ uxIndexToNotify ] == ~0UL );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -5026,13 +5051,14 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken )
|
||||
void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken )
|
||||
{
|
||||
TCB_t * pxTCB;
|
||||
uint8_t ucOriginalNotifyState;
|
||||
UBaseType_t uxSavedInterruptStatus;
|
||||
|
||||
configASSERT( xTaskToNotify );
|
||||
configASSERT( uxIndexToNotify < configNUMBER_OF_TASK_NOTIFICATIONS );
|
||||
|
||||
/* RTOS ports that support interrupt nesting have the concept of a
|
||||
maximum system call (or maximum API call) interrupt priority.
|
||||
|
@ -5056,12 +5082,12 @@ TickType_t uxReturn;
|
|||
|
||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||
{
|
||||
ucOriginalNotifyState = pxTCB->ucNotifyState;
|
||||
pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;
|
||||
ucOriginalNotifyState = pxTCB->ucNotifyState[ uxIndexToNotify ];
|
||||
pxTCB->ucNotifyState[ uxIndexToNotify ] = taskNOTIFICATION_RECEIVED;
|
||||
|
||||
/* 'Giving' is equivalent to incrementing a count in a counting
|
||||
semaphore. */
|
||||
( pxTCB->ulNotifiedValue )++;
|
||||
( pxTCB->ulNotifiedValue[ uxIndexToNotify ] )++;
|
||||
|
||||
traceTASK_NOTIFY_GIVE_FROM_ISR();
|
||||
|
||||
|
@ -5112,20 +5138,22 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask )
|
||||
BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask, UBaseType_t uxIndexToClear )
|
||||
{
|
||||
TCB_t *pxTCB;
|
||||
BaseType_t xReturn;
|
||||
|
||||
configASSERT( uxIndexToClear < configNUMBER_OF_TASK_NOTIFICATIONS );
|
||||
|
||||
/* If null is passed in here then it is the calling task that is having
|
||||
its notification state cleared. */
|
||||
pxTCB = prvGetTCBFromHandle( xTask );
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( pxTCB->ucNotifyState == taskNOTIFICATION_RECEIVED )
|
||||
if( pxTCB->ucNotifyState[ uxIndexToClear ] == taskNOTIFICATION_RECEIVED )
|
||||
{
|
||||
pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;
|
||||
pxTCB->ucNotifyState[ uxIndexToClear ] = taskNOT_WAITING_NOTIFICATION;
|
||||
xReturn = pdPASS;
|
||||
}
|
||||
else
|
||||
|
@ -5143,7 +5171,7 @@ TickType_t uxReturn;
|
|||
|
||||
#if( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
|
||||
uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear )
|
||||
uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear )
|
||||
{
|
||||
TCB_t *pxTCB;
|
||||
uint32_t ulReturn;
|
||||
|
@ -5156,8 +5184,8 @@ TickType_t uxReturn;
|
|||
{
|
||||
/* Return the notification as it was before the bits were cleared,
|
||||
then clear the bit mask. */
|
||||
ulReturn = pxCurrentTCB->ulNotifiedValue;
|
||||
pxTCB->ulNotifiedValue &= ~ulBitsToClear;
|
||||
ulReturn = pxCurrentTCB->ulNotifiedValue[ uxIndexToClear ];
|
||||
pxTCB->ulNotifiedValue[ uxIndexToClear ] &= ~ulBitsToClear;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue