OSTimeTickHook
Description
This function is called by OSTimeTick()
, which is assumed to be called from an ISR. OSTimeTickHook()
is called at the very beginning of OSTimeTick()
to give priority to user or port-specific code when the tick interrupt occurs.
If the #define
OS_CFG_APP_HOOKS_EN
is set to DEF_ENABLED
in os_cfg.h
, OSTimeTickHook()
will call App_OS_TimeTickHook()
.
OSTimeTickHook()
is part of the CPU port code and the function must not be called by the application code. OSTimeTickHook()
is actually used by the µC/OS-III port developer.
Files
os.h/os_cpu_c.c
Prototype
void OSTimeTickHook (void);
Arguments
None
Returned Value
None
Required Configuration
OS_CFG_APP_HOOKS_EN
must be enabled in os_cfg.h
. Refer to µC-OS-III Configuration Manual.
Callers
None
Notes/Warnings
- Do not call this function from the application.
Example Usage
The code below calls an application-specific hook that the application programmer can define. The user can simply set the value of OS_AppTimeTickHookPtr
to point to the desired hook function OSTimeTickHook()
is called by OSTimeTick()
which in turn calls App_OS_TimeTickHook()
through the pointer OS_AppTimeTickHookPtr
.
void App_OS_TimeTickHook (void) /* os_app_hooks.c */ { /* Your code goes here! */ } void App_OS_SetAllHooks (void) /* os_app_hooks.c */ { CPU_SR_ALLOC(); CPU_CRITICAL_ENTER(); : OS_AppTimeTickHookPtr = App_OS_TimeTickHook; : CPU_CRITICAL_EXIT(); } void OSTimeTickHook (void) /* os_cpu_c.c */ { #if OS_CFG_APP_HOOKS_EN > 0u if (OS_AppTimeTickHookPtr != (OS_APP_HOOK_VOID)0) { /* Call application hook */ (*OS_AppTimeTickHookPtr)(); } #endif }