Versions Compared

Key

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

...

Files

os.h/os_flag.c

Prototype

Code Block
OS_FLAGS  OSFlagPend (OS_FLAG_GRP  *p_grp,
                      OS_FLAGS      flags,
                      OS_TICK       timeout,
                      OS_OPT        opt,
                      CPU_TS       *p_ts,
                      OS_ERR       *p_err)

Arguments

p_grp

is a pointer to the event flag group.

...

specifies whether all bits are to be set/cleared or any of the bits are to be set/cleared. Here are the options:

OS_OPT_PEND_FLAG_CLR_ALL

Check If OS_CFG_FLAG_MODE_CLR_EN is set to DEF_ENABLED in os_cfg.h, check all bits in flags to be clear (0)

OS_OPT_PEND_FLAG_CLR_ANY

Check If OS_CFG_FLAG_MODE_CLR_EN is set to DEF_ENABLED in os_cfg.h, check any bit in flags to be clear (0)

...

OS_ERR_NONE

No error.

OS_ERR_OBJ_DEL

If the event group was deleted.

OS_ERR_OBJ_PTR_NULL

If OS_CFG_ARG_CHK_EN is set to 1 in DEF_ENABLED in os_cfg.h: if p_grp is a NULL pointer.

OS_ERR_OBJ_TYPE

If OS_CFG_OBJ_TYPE_CHK_EN is set to 1 in DEF_ENABLED in os_cfg.h: p_grp is not pointing to an event flag group.

...

If OS_CFG_ARG_CHK_EN is set to 1 in DEF_ENABLED in os_cfg.h: the caller specified an invalid option.

OS_ERR_OS_NOT_RUNNING

If OS_CFG_INVALID_OS_CALLS_CHK_EN is set to DEF_ENABLED in os_cfg.h: if µC/OS-III is not running yet.

OS_ERR_PEND_ABORT

The wait on the flags was aborted by another task that called OSFlagPendAbort().

...

If OS_CFG_CALLED_FROM_ISR_CHK_EN set to 1 in DEF_ENABLED in os_cfg.h: An attempt was made to call OSFlagPend() from an ISR, which is not allowed.

OS_ERR_SCHED_LOCKED

When calling this function while the scheduler was locked.

OS_ERR_PEND_WOULD_BLOCK

If specifying non-blocking but the flags were not available and the call would block if the caller had specified OS_OPT_PEND_BLOCKING.

OS_ERR_SCHED_LOCKED

When calling this function while the scheduler was locked.

OS_ERR_STATUS_INVALID

If the pend status has an invalid value.

OS_ERR_TIMEOUT

The flags are not available within the specified amount of time.

...

The flag(s) that cause the task to be ready, 0 if either if either none of the flags are ready, or indicate an error occurred.

...

OS_CFG_FLAG_EN must be enabledand optionally OS_CFG_FLAG_MODE_CLR_ENin os_cfg.h. Refer  Refer to uCµC-OS-III Configuration Manual.

Callers

Application.

Notes/Warnings

  1. The event flag group must be created before it is used.

Example Usage

 

...

Code Block
titleOSFlagPend() example usage
          #define  ENGINE_OIL_PRES_OK   0x01
          #define  ENGINE_OIL_TEMP_OK   0x02
          #define  ENGINE_START         0x04
           
          OS_FLAG_GRP  EngineStatus;
           
          void Task (void *p_arg)
          {
              OS_ERR    err;
              OS_FLAGS  value;
              CPU_TS    ts;
           
           
              (void)&p_arg;
              while (DEF_ON) {
                  value = OSFlagPend(&EngineStatus,
                                     ENGINE_OIL_PRES_OK   + ENGINE_OIL_TEMP_OK,
                                     OS_FLAG_WAIT_SET_ALL + OS_FLAG_CONSUME,
                                     10,
                                     OS_OPT_PEND_BLOCKING,
                                     &ts,
                                     &err);
                  /* Check "err" */
                  :
                  :
              }
          }