OSInit

Description

Initializes µC/OS-III and it must be called prior to calling any other µC/OS-III function. Including OSStart() which will start multitasking. OSInit() returns as soon as an error is detected.

Files

os.h/os_core.c

Prototype

void  OSInit (OS_ERR *p_err);

Arguments

p_err

is a pointer to an error code. Some of the error codes below are issued only if the associated feature is enabled.

OS_ERR_NONE

initialization was successful.

OS_ERR_INT_Q

If OS_CFG_ISR_POST_DEFERRED_EN is set to DEF_ENABLED in os_cfg.hOSCfg_IntQBasePtr is NULL. The error is detected by OS_IntQTaskInit() in os_int.c.

OS_ERR_INT_Q_SIZE

If OS_CFG_ISR_POST_DEFERRED_EN is set to DEF_ENABLED  in os_cfg.hOSCfg_IntQSize must have at least 2 elements. The error is detected by OS_IntQTaskInit() in os_int.c.

OS_ERR_INT_Q_STK_INVALID

If OS_CFG_ISR_POST_DEFERRED_EN is set to DEF_ENABLED  in os_cfg.hOSCfg_IntQTaskStkBasePtr is NULL. The error is detected by OS_IntQTaskInit() in os_int.c

OS_ERR_INT_Q_STK_SIZE_INVALID

If OS_CFG_ISR_POST_DEFERRED_EN is set to DEF_ENABLED  in os_cfg.hOSCfg_IntQTaskStkSize is less than OSCfg_StkSizeMin. The error is detected by OS_IntQTaskInit() in os_int.c.

OS_ERR_MSG_POOL_EMPTY

If OS_CFG_ARG_CHK_EN and OS_CFG_Q_EN or OS_CFG_TASK_Q_EN are set to DEF_ENABLED  in os_cfg.h: OSCfg_MsgPoolSize is zero. The error is detected by OS_MsgPoolInit() in os_msg.c.

OS_ERR_MSG_POOL_NULL_PTR

If OS_CFG_ARG_CHK_EN and OS_CFG_Q_EN or OS_CFG_TASK_Q_EN are set to DEF_ENABLED  in os_cfg.h: OSCfg_MsgPoolBasePtr is NULL in os_msg.c. The error is detected by OS_MsgPoolInit() in os_msg.c.

OS_ERR_STAT_PRIO_INVALID

If OS_CFG_STAT_TASK_EN is set to DEF_ENABLED in os_cfg.h: OSCfg_StatTaskPrio is invalid. The error is detected by OS_StatTaskInit() in os_stat.c.

OS_ERR_STAT_STK_INVALID

If OS_CFG_STAT_TASK_EN is set to DEF_ENABLED in os_cfg.hOSCfg_StatTaskStkBasePtr is NULL. The error is detected by OS_StatTaskInit() in os_stat.c.

OS_ERR_STAT_STK_SIZE_INVALID

IfOS_CFG_STAT_TASK_EN is set to DEF_ENABLED in os_cfg.hOSCfg_StatTaskStkSize is less than OSCfg_StkSizeMin. The error is detected by OS_StatTaskInit() in os_stat.c.

OS_ERR_TICK_PRIO_INVALID

If OSCfg_TickTaskPrio is invalid, The error is detected by OS_TickTaskInit() in os_tick.c.

OS_ERR_TICK_STK_INVALID

OSCfg_TickTaskStkBasePtr is NULL. The error is detected by OS_TickTaskInit() in os_tick.c.

OS_ERR_TICK_STK_SIZE_INVALID

OSCfg_TickTaskStkSize is less than OSCfg_StkSizeMin. This error was detected by OS_TickTaskInit() in os_tick.c.

OS_ERR_TMR_PRIO_INVALID

If OS_CFG_TMR_EN is set to DEF_ENABLED in os_cfg.h: OSCfg_TmrTaskPrio is invalid. The error is detected by see OS_TmrInit() in os_tmr.c.

OS_ERR_TMR_STK_INVALID

If OS_CFG_TMR_EN is set to DEF_ENABLED in os_cfg.hOSCfg_TmrTaskBasePtr is pointing at NULL. The error is detected by OS_TmrInit() in os_tmr.c.

OS_ERR_TMR_STK_SIZE_INVALID

If OS_CFG_TMR_EN is set to DEF_ENABLED in os_cfg.hOSCfg_TmrTaskStkSize is less than OSCfg_StkSizeMin. The error is detected by OS_TmrInit() in os_tmr.c.

Returned Values

None

Required Configuration

None

Callers

Application.

Notes/Warnings

  1. OSInit() must be called before OSStart().
  2. OSInit() returns as soon as it detects an error in any of the sub-functions it calls. For example, if OSInit() encounters a problem initializing the task manager, an appropriate error code will be returned and OSInit() will not go any further. It is therefore important that the user checks the error code before starting multitasking.

Example Usage

OSInit() example usage
          void main (void)
          {
              OS_ERR  err;
             
                 : 
              OSInit(&err);                   /* Initialize µC/OS-III              */
              /* Check "err" */
              :
              :
              OSStart(&err);                  /* Start Multitasking                */
              /* Check "err" */               /* Code not supposed to end up here! */
              :
              :
          }