...
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_CFG_FLAG_EN
must be enabled, and optionally OS_CFG_FLAG_MODE_CLR_EN
, in os_cfg.h
. Refer Refer to µC-OS-III Configuration Manual.
...
- The event flag group must be created before it is used.
Example Usage
...
Code Block | ||
---|---|---|
| ||
#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" */
:
:
}
} |