Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

os.h/os_cpu_c.c and os_app_hooks.c

Prototype

Code Block
void  OSTaskCreateHook (OS_TCB  *p_tcb)

Arguments

p_tcb

is a pointer to the TCB of the task being created. Note that the OS_TCB has been validated by OSTaskCreate() and is guaranteed to not be a NULL pointer when OSTaskCreateHook() is called.

...

The code below calls an application-specific hook that the application programmer can define. The user can simply set the value of OS_AppTaskCreateHookPtr to point to the desired hook function as shown in the example. OSTaskCreate() calls OSTaskCreateHook() which in turns calls App_OS_TaskCreateHook() through OS_AppTaskCreateHookPtr. As can be seen, when called, the application hook is passed the address of the OS_TCB of the newly created task.

Code Block
titleOSTaskCreateHook() example usage
          void  App_OS_TaskCreateHook (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_AppTaskCreateHookPtr = App_OS_TaskCreateHook;
              :
              CPU_CRITICAL_EXIT();
          }
           
           
          void  OSTaskCreateHook (OS_TCB *p_tcb)                      /* os_cpu_c.c             */
          {
          #if OS_CFG_APP_HOOKS_EN > 0u
              if (OS_AppTaskCreateHookPtr != (OS_APP_HOOK_TCB)0) {    /* Call application hook  */
                  (*OS_AppTaskCreateHookPtr)(p_tcb);
              }
          #endif
          }