diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index eba66a879..702f25fb7 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -1017,6 +1017,25 @@ #define traceTASK_NOTIFY_WAIT( uxIndexToWait ) #endif +#ifndef traceTASK_NOTIFY_WAIT_EXT + +/* Extended version of traceTASK_NOTIFY_WAIT that also exposes value of + * ulBitsToClearOnExit, informing the tracer of the state of this task + * notification after it has been taken. Note that this hook, unlike + * traceTASK_NOTIFY_WAIT, is only called if the notification was successfully + * taken. */ + #define traceTASK_NOTIFY_WAIT_EXT( uxIndexToWait, ulBitsToClearOnExit ) traceTASK_NOTIFY_WAIT( uxIndexToWait ) +#endif + +#ifndef traceTASK_NOTIFY_WAIT_FAILED + +/* Task notification wait failed. For backwards-compatability, this macro falls + * back on traceTASK_NOTIFY_WAIT which was always called, no matter if + * successfull or not. */ + #define traceTASK_NOTIFY_WAIT_FAILED( uxIndexToWait ) traceTASK_NOTIFY_WAIT( uxIndexToWait ) +#endif + + #ifndef traceTASK_NOTIFY #define traceTASK_NOTIFY( uxIndexToNotify ) #endif diff --git a/tasks.c b/tasks.c index e8387be94..c407bf8e9 100644 --- a/tasks.c +++ b/tasks.c @@ -7741,6 +7741,8 @@ TickType_t uxTaskResetEventItemValue( void ) /* Only block if a notification is not already pending. */ if( pxCurrentTCB->ucNotifyState[ uxIndexToWaitOn ] != taskNOTIFICATION_RECEIVED ) { + traceTASK_NOTIFY_VALUE_CLEAR( pxCurrentTCB, uxIndexToWaitOn, ulBitsToClearOnEntry ); + /* 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. */ @@ -7792,8 +7794,6 @@ TickType_t uxTaskResetEventItemValue( void ) taskENTER_CRITICAL(); { - traceTASK_NOTIFY_WAIT( uxIndexToWaitOn ); - if( pulNotificationValue != NULL ) { /* Output the current notification value, which may or may not @@ -7808,12 +7808,14 @@ TickType_t uxTaskResetEventItemValue( void ) if( pxCurrentTCB->ucNotifyState[ uxIndexToWaitOn ] != taskNOTIFICATION_RECEIVED ) { /* A notification was not received. */ + traceTASK_NOTIFY_WAIT_FAILED( uxIndexToWaitOn ); xReturn = pdFALSE; } else { /* A notification was already pending or a notification was * received while the task was waiting. */ + traceTASK_NOTIFY_WAIT_EXT( uxIndexToWaitOn, ulBitsToClearOnExit ); pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] &= ~ulBitsToClearOnExit; xReturn = pdTRUE; }