Versions Compared

Key

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

...

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

Files

os.h/os_core.c

Prototype

Code Block
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.

...

initialization was successful.

OS_ERR_INT_Q

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

OS_ERR_INT_Q_SIZE

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

OS_ERR_INT_Q_STK_INVALID

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

OS_ERR_INT_Q_STK_SIZE_INVALID

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

OS_ERR_MSG_POOL_EMPTY

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

OS_ERR_MSG_POOL_NULL_PTR

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

OS_ERR_STAT_PRIO_INVALID

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

OS_ERR_STAT_STK_INVALID

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

OS_ERR_STAT_STK_SIZE_INVALID

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

OS_ERR_TICK_PRIO_INVALID

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

OS_ERR_TICK_STK_INVALID

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

OS_ERR_TICK_STK_SIZE_INVALID

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

OS_ERR_TMR_PRIO_INVALID

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

OS_ERR_TMR_STK_INVALID

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

OS_ERR_TMR_STK_SIZE_INVALID

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

Returned Values

None

...

Application.

Notes/Warnings

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

Example Usage

Code Block
titleOSInit() 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! */
              :
              :
          }