Versions Compared

Key

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

...

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. Anchor10003351000335 Arguments Anchor10003361000336 p_grp Anchor10003371000337

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.

...

flagsanchor10003391000339

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).

...

optanchor10003411000341

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 Anchor10003441000344

is a pointer to an error code and can be:

...

classWebWorks_Indent_1

...

...

OS_ERR_NONE

...

...

the call is successful.

...

classWebWorks_Indent_1

...

OS_ERR_

...

OBJ_

...

PTR_

...

classWebWorks_Indent_2

...

NULL

If OS_CFG_ARG_CHK_EN is set to

...

DEF_ENABLED in os_cfg.h: if

...

classWebWorks_Indent_1

...

classWebWorks_Indent_2

...

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

...

classWebWorks_Indent_1

...

you specified an invalid option.

OS_ERR_

...

classWebWorks_Indent_2

...

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

Anchor10003541000354The new value of the event flags. Anchor10003551000355

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. 10003561000356Event flag groups must be created before they are used.anchor10003571000357
  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. Anchor10003581000358
  3. 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 #define
   0x01
          #define  ENGINE_OIL_TEMP_OK
0x02 #define ENGINE_START 0x04  
   0x02
          #define  ENGINE_START         0x04
           
          OS_FLAG_GRP
EngineStatusFlags;     void TaskX (void *p_arg) { OS_ERR err; OS_FLAGS flags;    
  EngineStatusFlags;
           
           
          void  TaskX (void *p_arg)
          {
              OS_ERR    err;
              OS_FLAGS  flags;
           
           
              (void)&p_arg;
while

              while (DEF_ON)
{ : : flags = OSFlagPost(&EngineStatusFlags, ENGINE_START,
 {
                  :
                  :
                  flags = OSFlagPost(&EngineStatusFlags,
                                     ENGINE_START,
                                     OS_OPT_POST_FLAG_SET,
&err); /* Check ’err” */ : : } }tr

                                     &err);
                  /* Check 'err" */
                  :
                  :
              }
          }
HTML Table
summary
classCode_Listing
Table Row (tr)
Table Cell (td)
rowspan21
Anchor
10003611000361
titleOSFlagPost() example usage
          #define  ENGINE_OIL_PRES_OK
0x01
Anchor
10003621000362
Anchor
10003631000363
Anchor
10003641000364
Anchor
10003651000365
Anchor
10003661000366
Anchor
10003671000367
Anchor
10003681000368
Anchor
10003691000369
Anchor
10003701000370
Anchor
10003711000371
Anchor
10003721000372
Anchor
10003731000373
Anchor
10003741000374
Anchor
10003751000375
Anchor
10003761000376
Anchor
10003771000377
Anchor
10003781000378
Anchor
10003791000379
Anchor
10003801000380
Anchor
10003811000381
Anchor
10003821000382
Anchor
10003831000383
Anchor
10003841000384
Anchor
10003851000385
Anchor
10003861000386
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)
Table Row (tr)