...
os.h/os_cpu_c.c and os_app_hooks.c
Prototype
Code Block |
---|
void OSTaskReturnHook (OS_TCB *p_tcb) |
Arguments
p_tcb
is a pointer to the TCB of the task that is not behaving as expected. Note that the OS_TCB
is validated by OS_TaskReturn()
, and is guaranteed to not be a NULL
pointer when OSTaskReturnHook()
is called.
...
The code below calls an application-specific hook that the application programmer can define. For this, the user can simply set the value of OS_AppTaskReturnHookPtr
to point to the desired hook function as shown in the example. If a task returns and forgets to call OSTaskDel((OS_TCB *)0, &err)
then µC/OS-III will call OSTaskReturnHook()
which in turns calls App_OS_TaskReturnHook()
through OS_AppTaskReturnHookPtr
. When called, the application hook is passed the address of the OS_TCB
of the task returning.
Code Block | ||
---|---|---|
| ||
void App_OS_TaskReturnHook (OS_TCB *p_tcb) /* os_app_hooks.c */ { /* Your code goes here! */ } void App_OS_SetAllHooks (void) /* os_app_hooks.c */ { CPU_SR_ALLOC(); CPU_CRITICAL_ENTER(); : OS_AppTaskReturnHookPtr = App_OS_TaskReturnHook; : CPU_CRITICAL_EXIT(); } void OSTaskReturnHook (OS_TCB *p_tcb) /* os_cpu_c.c */ { #if OS_CFG_APP_HOOKS_EN > 0u if (OS_AppTaskReturnHookPtr != (OS_APP_HOOK_TCB)0) { /* Call application hook */ (*OS_AppTaskReturnHookPtr)(p_tcb); } #endif } |