Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Current »

Description

Sets or clears event flag bits. The bits set or cleared are specified in a bit mask (i.e., the flags argument). OSFlagPost() readies each task that has its desired bits satisfied by this call. The caller can set or clear bits that are already set or cleared.

Files

os.h/os_flag.c

Prototype

Arguments

p_grp

is a pointer to the event flag group.

flags

specifies which bits to be set or cleared. If opt is OS_OPT_POST_FLAG_SET, each bit that is set in flags will set the corresponding bit in the event flag group. For example to set bits 0, 4, and 5, you would set flags to 0x31 (note that bit 0 is the least significant bit). If opt is OS_OPT_POST_FLAG_CLR, each bit that is set in flags will clear the corresponding bit in the event flag group. For example to clear bits 0, 4, and 5, you would specify flags as 0x31 (again, bit 0 is the least significant bit).

opt

indicates whether the flags are set (OS_OPT_POST_FLAG_SET) or cleared (OS_OPT_POST_FLAG_CLR).

The caller may also “add” OS_OPT_POST_NO_SCHED so that µC/OS-III will not call the scheduler after the post.

p_err

is a pointer to an error code and can be:

OS_ERR_NONE

the call is successful.

OS_ERR_OBJ_PTR_NULL

If OS_CFG_ARG_CHK_EN is set to DEF_ENABLED in os_cfg.h: if the caller passed a NULL pointer.

OS_ERR_OBJ_TYPE

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

OS_ERR_OPT_INVALID

If OS_CFG_ARG_CHK_EN is set to DEF_ENABLED in os_cfg.h: if you 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.

Returned Value

The new value of the event flags.

Required Configuration

OS_CFG_FLAG_EN must be enabled in os_cfg.h. Refer to µC-OS-III Configuration Manual.

Callers

Application and ISRs.

Notes/Warnings

  1. Event flag groups must be created before they are used.
  2. The execution time of this function depends on the number of tasks waiting on the event flag group. However, the execution time is still deterministic.
  3. Although the example below shows that we are posting from a task, OSFlagPost() can also be called from an ISR.

Example Usage

 

 

  • No labels