909-FreeRTOS202212 - xTaskNotifyStateClear() 与 xTaskNotifyStateClearIndexed()

909-FreeRTOS202212 - xTaskNotifyStateClear() 与 xTaskNotifyStateClearIndexed()_第1张图片


#define xTaskNotifyStateClear( xTask ) \
    	xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
#define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
	xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )

/*-----------------------------------------------------------*/

#if ( configUSE_TASK_NOTIFICATIONS == 1 )

	BaseType_t xTaskGenericNotifyStateClear( 	TaskHandle_t 	xTask,			/* 要通知的任务的句柄 */
                                             	UBaseType_t 	uxIndexToClear )	/* 任务通知数组的索引值(任务通知相关数组下标) */
    	{
        	TCB_t * pxTCB;
        	BaseType_t xReturn;

        	configASSERT( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES );

        	/* If null is passed in here then it is the calling task that is having its notification state cleared. */
		/*如果在这里传递了null,那么它是正在清除通知状态的调用任务*/
        	pxTCB = prvGetTCBFromHandle( xTask );

        	taskENTER_CRITICAL();
        	{
            		if( pxTCB->ucNotifyState[ uxIndexToClear ] == taskNOTIFICATION_RECEIVED )
            		{
                		pxTCB->ucNotifyState[ uxIndexToClear ] = taskNOT_WAITING_NOTIFICATION;
                		xReturn = pdPASS;
            		}
            		else
            		{
                		xReturn = pdFAIL;
            		}
        	}
        	taskEXIT_CRITICAL();

        	return xReturn;
    	}

#endif /* configUSE_TASK_NOTIFICATIONS */

你可能感兴趣的:(FreeRTOS,学习手记,09,-,直达任务通知,c语言)