#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE\r
\r
\r
-/*\r
- * Default a definitions for backwards compatibility with old\r
- * portmacro.h files.\r
- */\r
-#ifndef configMAX_TASK_NAME_LEN\r
- #define configMAX_TASK_NAME_LEN 16\r
-#endif\r
-\r
-#ifndef configIDLE_SHOULD_YIELD\r
- #define configIDLE_SHOULD_YIELD 1\r
-#endif\r
-\r
-#if configMAX_TASK_NAME_LEN < 1\r
- #undef configMAX_TASK_NAME_LEN\r
- #define configMAX_TASK_NAME_LEN 1\r
-#endif\r
-\r
-#ifndef INCLUDE_xTaskResumeFromISR\r
- #define INCLUDE_xTaskResumeFromISR 1\r
-#endif\r
-\r
-#ifndef INCLUDE_xTaskGetSchedulerState\r
- #define INCLUDE_xTaskGetSchedulerState 0\r
-#endif\r
-\r
/*\r
* Task control block. A task control block (TCB) is allocated to each task,\r
* and stores the context of the task.\r
#if ( configUSE_MUTEXES == 1 )\r
unsigned portBASE_TYPE uxBasePriority;\r
#endif\r
+\r
+ #if ( configUSE_APPLICATION_TASK_HOOK == 1 )\r
+ pdTASK_HOOK_CODE pxTaskHook;\r
+ #endif\r
\r
} tskTCB;\r
\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
+#if ( configUSE_APPLICATION_TASK_HOOK == 1 )\r
+\r
+ void vTaskSetApplicationTaskHook( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction )\r
+ {\r
+ tskTCB *xTCB;\r
+\r
+ /* If xTask is NULL then we are setting our own task hook. */\r
+ if( xTask == NULL )\r
+ {\r
+ xTCB = ( tskTCB * ) pxCurrentTCB;\r
+ }\r
+ else\r
+ {\r
+ xTCB = ( tskTCB * ) xTask;\r
+ }\r
+ \r
+ /* Save the hook function in the TCB. */\r
+ xTCB->pxTaskHook = pxHookFunction;\r
+ }\r
+ \r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_APPLICATION_TASK_HOOK == 1 )\r
+\r
+ portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter )\r
+ {\r
+ tskTCB *xTCB;\r
+ portBASE_TYPE xReturn;\r
+\r
+ /* If xTask is NULL then we are calling our own task hook. */\r
+ if( xTask == NULL )\r
+ {\r
+ xTCB = ( tskTCB * ) pxCurrentTCB;\r
+ }\r
+ else\r
+ {\r
+ xTCB = ( tskTCB * ) xTask;\r
+ }\r
+\r
+ if( xTCB->pxTaskHook != NULL )\r
+ {\r
+ xReturn = xTCB->pxTaskHook( pvParameter );\r
+ }\r
+ else\r
+ {\r
+ xReturn = pdFAIL;\r
+ }\r
+\r
+ return xReturn;\r
+ }\r
+ \r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
void vTaskSwitchContext( void )\r
{\r
traceTASK_SWITCHED_OUT();\r
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned portSHORT ) configMAX_TASK_NAME_LEN );\r
pxTCB->pcTaskName[ ( unsigned portSHORT ) configMAX_TASK_NAME_LEN - ( unsigned portSHORT ) 1 ] = '\0';\r
\r
- #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
- {\r
- pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0;\r
- }\r
- #endif\r
-\r
/* This is used as an array index so must ensure it's not too large. */\r
if( uxPriority >= configMAX_PRIORITIES )\r
{\r
/* Event lists are always in priority order. */\r
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority );\r
listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB );\r
+\r
+ #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
+ {\r
+ pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0;\r
+ }\r
+ #endif\r
+\r
+ #if ( configUSE_APPLICATION_TASK_HOOK == 1 )\r
+ {\r
+ pxTCB->pxTaskHook = NULL;\r
+ }\r
+ #endif \r
}\r
/*-----------------------------------------------------------*/\r
\r