...
Files
os.h/os_flag.c
Prototype
Code Block |
---|
OS_FLAGS OSFlagPost (OS_FLAG_GRP *p_grp,
OS_FLAGS flags,
OS_OPT opt,
OS_ERR *p_err) |
Arguments
p_grp
is a pointer to the event flag group.
...
the call is successful.
OS_ERR_FLAGOBJ_INVALIDPTR_OPTNULL
If OS_CFG_ARG_CHK_EN
is set to 1
in DEF_ENABLED
in os_cfg.h
: if you specified an invalid optionthe caller passed a NULL
pointer.
OS_ERR_OBJ_PTR_NULLTYPE
If OS_CFG_OBJ_ARGTYPE_CHK_EN
is set to 1
in 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 the caller passed a NULL
pointeryou specified an invalid option.
OS_ERR_OS_OBJNOT_TYPERUNNING
If If OS_CFG_INVALID_OBJOS_TYPECALLS_CHK_EN
is set to 1
in is set to DEF_ENABLED
in os_cfg.h
: p_grp
is not pointing to an event flag groupif µC/OS-III is not running yet.
Returned Value
The new value of the event flags.
...
OS_CFG_FLAG_EN
must be enabled in os_cfg.h
. Refer to uCµC-OS-III Configuration Manual.
Callers
Application and ISRs.
...
- Event flag groups must be created before they are used.
- 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.
- Although the example below shows that we are posting from a task,
OSFlagPost()
can also be called from an ISR.
Example
...
...
Usage
Code Block | ||
---|---|---|
| ||
#define ENGINE_OIL_PRES_OK 0x01
#define ENGINE_OIL_TEMP_OK 0x02
#define ENGINE_START 0x04
OS_FLAG_GRP EngineStatusFlags;
void TaskX (void *p_arg)
{
OS_ERR err;
OS_FLAGS flags;
(void)&p_arg;
while (DEF_ON) {
:
:
flags = OSFlagPost(&EngineStatusFlags,
ENGINE_START,
OS_OPT_POST_FLAG_SET,
&err);
/* Check 'err" */
:
:
}
} |