...
Application hook functions could be declared as shown in the code below.
It’s also up to a user to set the value of the pointers so that they point to the appropriate functions as shown below. The pointers do not have to be set in main()
but, you can set them after calling OSInit()
.
Note that not every hook function need to be defined, only the ones the user wants to place in the application code.
Also, if you don't intend to extend µC/OS-III’s hook through these application hooks, you can set OS_CFG_APP_HOOKS_EN
to DEF_DISABLED
to save RAM (i.e., the pointers).
OS_CFG_ARG_CHK_EN
OS_CFG_ARG_CHK_EN
determines whether the user wants most of µC/OS-III functions to perform argument checking. When set to DEF_ENABLED
, µC/OS-III ensures that pointers passed to functions are non-NULL
, that arguments passed are within allowable range, that options are valid, and more. When set to DEF_DISABLED
, those arguments are not checked and the amount of code space and processing time required by µC/OS-III is reduced. You would set OS_CFG_ARG_CHK_EN
to DEF_DISABLED
if you are certain that the arguments will always be correct.
µC/OS-III performs argument checking in close to 50 functions. Therefore, you can save a few hundred bytes of code space by disabling this check. However, you should always enable argument checking until you are certain the code can be trusted.
OS_CFG_CALLED_FROM_ISR_CHK_EN
OS_CFG_CALLED_FROM_ISR_CHK_EN
determines whether most of µC/OS-III functions are to confirm that the function is not called from an ISR. In other words, most of the functions from µC/OS-III should be called by task-level code except “post” type functions (which can also be called from ISRs). By setting this DEF_ENABLED
, µC/OS-III is told to make sure that functions that are only supposed to be called by tasks are not called by ISRs. It’s highly recommended to set this to DEF_ENABLED
until you are absolutely sure that the code is behaving correctly and that task-level functions are always called from tasks. You can set this to DEF_DISABLED
to save code space and, of course, processing time.
µC/OS-III performs this check in approximately 50 functions. Therefore, you can save a few hundred bytes of code space by disabling this check.
OS_CFG_DBG_EN
When set to DEF_ENABLED
, this configuration adds ROM constants located in os_dbg.c
to help support kernel aware debuggers. Specifically, a number of named ROM variables can be queried by a debugger to find out about compiled-in options. For example, a debugger can find out the size of a OS_TCB
, µC/OS-III’s version number, the size of an event flag group (OS_FLAG_GRP
), and much more.
OS_CFG_DYN_TICK_EN
When set to DEF_ENABLED
, µC/OS-III will use a dynamic ticking mechanism instead of the traditional continuous tick. This allows µC/OS-III to sleep until a task needs to be awakened, instead of waking up every 1/OS_CFG_TICK_RATE_HZ
seconds to find no that no tasks need to be awakened. This can be used to save power since the scheduler is run only when strictly necessary.
Note that the use of this feature requires a proper Board Support Package (BSP) that implements the API described in Board Support Package.
OS_CFG_INVALID_OS_CALLS_CHK_EN
...
Code Block |
---|
void App_OS_TaskCreateHook (OS_TCB *p_tcb)
{
/* Your code here */
}
void App_OS_TaskDelHook (OS_TCB *p_tcb)
{
/* Your code here */
}
void App_OS_TaskReturnHook (OS_TCB *p_tcb)
{
/* Your code here */
}
void App_OS_IdleTaskHook (void)
{
/* Your code here */
}
void App_OS_StatTaskHook (void)
{
/* Your code here */
}
void App_OS_TaskSwHook (void)
{
/* Your code here */
}
void App_OS_TimeTickHook (void)
{
/* Your code here */
} |
It’s also up to a user to set the value of the pointers so that they point to the appropriate functions as shown below. The pointers do not have to be set in main()
but, you can set them after calling OSInit()
.
Code Block |
---|
void main (void)
{
OS_ERR err;
OSInit(&err);
:
:
OS_AppTaskCreateHookPtr = (OS_APP_HOOK_TCB )App_OS_TaskCreateHook;
OS_AppTaskDelHookPtr = (OS_APP_HOOK_TCB )App_OS_TaskDelHook;
OS_AppTaskReturnHookPtr = (OS_APP_HOOK_TCB )App_OS_TaskReturnHook;
OS_AppIdleTaskHookPtr = (OS_APP_HOOK_VOID)App_OS_IdleTaskHook;
OS_AppStatTaskHookPtr = (OS_APP_HOOK_VOID)App_OS_StatTaskHook;
OS_AppTaskSwHookPtr = (OS_APP_HOOK_VOID)App_OS_TaskSwHook;
OS_AppTimeTickHookPtr = (OS_APP_HOOK_VOID)App_OS_TimeTickHook;
:
:
OSStart(&err);
} |
Note that not every hook function need to be defined, only the ones the user wants to place in the application code.
Also, if you don't intend to extend µC/OS-III’s hook through these application hooks, you can set OS_CFG_APP_HOOKS_EN
to DEF_DISABLED
to save RAM (i.e., the pointers).
OS_CFG_ARG_CHK_EN
OS_CFG_ARG_CHK_EN
determines whether the user wants most of µC/OS-III functions to perform argument checking. When set to DEF_ENABLED
, µC/OS-III ensures that pointers passed to functions are non-NULL
, that arguments passed are within allowable range, that options are valid, and more. When set to DEF_DISABLED
, those arguments are not checked and the amount of code space and processing time required by µC/OS-III is reduced. You would set OS_CFG_ARG_CHK_EN
to DEF_DISABLED
if you are certain that the arguments will always be correct.
µC/OS-III performs argument checking in close to 50 functions. Therefore, you can save a few hundred bytes of code space by disabling this check. However, you should always enable argument checking until you are certain the code can be trusted.
OS_CFG_CALLED_FROM_ISR_CHK_EN
OS_CFG_CALLED_FROM_ISR_CHK_EN
determines whether most of µC/OS-III functions are to confirm that the function is not called from an ISR. In other words, most of the functions from µC/OS-III should be called by task-level code except “post” type functions (which can also be called from ISRs). By setting this DEF_ENABLED
, µC/OS-III is told to make sure that functions that are only supposed to be called by tasks are not called by ISRs. It’s highly recommended to set this to DEF_ENABLED
until you are absolutely sure that the code is behaving correctly and that task-level functions are always called from tasks. You can set this to DEF_DISABLED
to save code space and, of course, processing time.
µC/OS-III performs this check in more than 40 approximately 50 functions. Therefore, you can save a few hundred bytes of code space by disabling this check.
OS_CFG_
...
DBG_EN
Warning, this feature is DEPRECATED and will be removed in a future release of µC/OS-III.
When set to DEF_ENABLED
, OS_CFG_ISR_POST_DEFERRED_EN
reduces interrupt latency since interrupts are not disabled during most critical sections of code within µC/OS-III. Instead, the scheduler is locked during the processing of these critical sections. The advantage of setting this to DEF_ENABLED
is that interrupt latency is lower, however, ISR to task response is slightly higher. It is recommended to set OS_CFG_ISR_POST_DEFERRED_EN
to DEF_ENABLED
when enabling the following services, since setting this to DEF_DISABLED
would potentially make interrupt latency unacceptably high:
µC/OS-III Service | Enabled by |
---|---|
Event Flags | OS_CFG_FLAG_EN |
Multiple Pend | OS_CFG_PEND_MULTI_EN |
OS???Post() with broadcast | |
OS???Del() with OS_OPT_DEL_ALWAYS | |
OS???PendAbort() | OS_CFG_???_PEND_ABORT |
The compromise to make is:
OS_CFG_ISR_POST_DEFERRED_EN
set to DEF_ENABLED
Short interrupt latency, longer ISR-to-task response.
OS_CFG_ISR_POST_DEFERRED_EN
set to DEF_DISABLED
...
When set to DEF_ENABLED
, this configuration adds ROM constants located in os_dbg.c
to help support kernel aware debuggers. Specifically, a number of named ROM variables can be queried by a debugger to find out about compiled-in options. For example, a debugger can find out the size of a OS_TCB
, µC/OS-III’s version number, the size of an event flag group (OS_FLAG_GRP
), and much more.
OS_CFG_DYN_TICK_EN
When set to DEF_ENABLED
, µC/OS-III will use a dynamic ticking mechanism instead of the traditional continuous tick. This allows µC/OS-III to sleep until a task needs to be awakened, instead of waking up every 1/OS_CFG_TICK_RATE_HZ
seconds to find no that no tasks need to be awakened. This can be used to save power since the scheduler is run only when strictly necessary.
Note that the use of this feature requires a proper Board Support Package (BSP) that implements the API described in Board Support Package.
OS_CFG_INVALID_OS_CALLS_CHK_EN
When set to DEF_ENABLED
, µC/OS-III will validate the call and check that the kernel is indeed running before performing the function. You would set OS_CFG_INVALID_OS_CALLS_CHK_EN
to DEF_DISABLED
if you are sure that the OS functions will be called only once OSStart()
has been called.
µC/OS-III performs this check in more than 40 functions. Therefore, you can save a few hundred bytes of code space by disabling this check.
OS_CFG_OBJ_TYPE_CHK_EN
OS_CFG_OBJ_TYPE_CHK_EN
determines whether most of µC/OS-III functions should check to see if the function is manipulating the proper object. In other words, if attempting to post to a semaphore, is the user in fact passing a semaphore object or another object by mistake? It is recommended to set OS_CFG_OBJ_TYPE_CHK_EN
to DEF_ENABLED
until absolutely certain that the code is behaving correctly and the user code is always pointing to the proper objects. You would set this to DEF_DISABLED
to save code space as well as data space.
...
Note that to use the timestamp facilities the µC/CPU Board Support Package should implement the functions described in cpu_bsp.c and cpu_bsp.h.
OS_CFG_PEND_MULTI_EN
Warning, this feature is DEPRECATED and will be removed in a future release of µC/OS-III.
When this option is set to DEF_ENABLED
, it allows the user to pend on multiple objects (message queues and semaphores only) at once_bsp.h.
OS_CFG_PRIO_MAX
OS_CFG_PRIO_MAX
specifies the maximum number of priorities available in the application. Specifying OS_CFG_PRIO_MAX
to just the number of priorities the user intends to use, reduces the amount of RAM needed by µC/OS-III.
...
Priority | Reserved by µC/OS-III for | |
---|---|---|
0 | The ISR Handler Task (OS_IntQTask() ), if used | |
1 | Reserved | |
OS_CFG_PRIO_MAX-2 | Reserved | |
OS_CFG_PRIO_MAX-1 | The Idle Task (OS_IdleTask() ), if used |
...
When OS_CFG_TMR_EN
is set to DEF_ENABLED
, it enables the timer management services. If your application does no require programmable timers, set this option to DEF_DISABLED
to reduce µC/OS-III's required code and data space. to reduce µC/OS-III's required code and data space.
OS_CFG_TMR_DEL_EN
If your application needs to delete timers with OSTmrDel
once they're created, set ()
OS_CFG_TMR_DEL_EN
to DEF_ENABLED
, if not, set this option to DEF_DISABLED
. Critical applications should not delete kernel objects once the kernel is started.
Trace Options
OS_CFG_
...
TRACE_EN
If your application needs to delete timers with OSTmrDel
once they're created, set ()
OS_CFG_TMR_DEL_EN
to DEF_ENABLED
, if notµC/OS-III has built-in trace points throughout the code to record all the kernel events and interrupts in real-time. These trace calls are disabled by default and enabled when this constant is set to DEF_ENABLED
. If you do not require this feature, set this option to DEF_DISABLED
. Critical applications should not delete kernel objects once the kernel is started.
µC/Trace Configuration
TRACE_CFG_EN
Although not specifically part of µC/OS-III, µC/Trace, a Windows-based RTOS Event Analyzer (i.e. tool) that is fully integrated in the latest version of µC/OS-III. µC/Trace functionality is enabled by setting TRACE_CFG_EN
to DEF_ENABLED
. You will need to have purchased the µC/Trace product in order to set TRACE_CFG_EN
to DEF_ENABLED
or else your compiler will complain about missing macros and functions. Consult the Micrium website for details and availability of this highly useful tool to not only reduce the required code and data space but also to eliminate the inherent overhead.
OS_CFG_TRACE_API_ENTER_EN
When this constant is set to DEF_ENABLED
the beginning of each API call in µC/OS-III will be recorded as part of the trace (it applies to SEGGER's SystemView only).
OS_CFG_TRACE_API_EXIT_EN
When this constant is set to DEF_ENABLED
the end of each API call in µC/OS-III will be recorded as part of the trace (it applies to SEGGER's SystemView only).