Versions Compared

Key

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

...

Figure 9.1, µC/OS-II Event Flag services.

...

Event Flag Internals

A µC/OS-II's event flag group consist of three elements as shown in the OS_FLAG_GRP structure below.

...

OS_FLAG_WAIT_CLR_ALL      
OS_FLAG_WAIT_CLR_AND      
OS_FLAG_WAIT_CLR_ANY      
OS_FLAG_WAIT_CLR_OR 
OS_FLAG_WAIT_SET_ALL 
OS_FLAG_WAIT_SET_AND      
OS_FLAG_WAIT_SET_ANY      
OS_FLAG_WAIT_SET_OR 

 

You should note that AND and ALL means the same thing and either one can be used. I prefer to use OS_FLAG_WAIT_???_ALL because it’s more obvious but you are certainly welcomed to use OS_FLAG_WAIT_???_AND. Similarly, OR or ANY means the same thing and either one can be used. Again, I prefer to use OS_FLAG_WAIT_???_ANY because it’s more obvious but again, you can use OS_FLAG_WAIT_???_OR. The other thing to notice is that you can wait for either bits to be SET or CLEARED.

...

Creating an Event Flag Group, OSFlagCreate()

The code to create an event flag group is shown in listing 9.3.

Figure 9.3 Event Flag group just before OSFlagCreate() returns.

...

Deleting an Event Flag Group, OSFlagDel()

The code to delete an event flag group is shown in listing 9.4.

This is a function you should use with caution because multiple tasks could attempt to access a deleted event flag group. You should always use this function with great care. Generally speaking, before you would delete an event flag group, you would first delete all the tasks that access the event flag group.

...

Waiting for event(s) of an Event Flag Group, OSFlagPend()

The code to wait for event(s) of an event flag group is shown in listing 9.5.

...

Figure 9.4, Adding the current task to the wait list of the Event Flag Group.

...

Setting or Clearing event(s) in an Event Flag Group, OSFlagPost()

The code to either setting or clearing bits in an event flag group is done by calling OSFlagPost() and the code for this function is shown in listing 9.7.

...

Figure 9.9, Removing an OS_FLAG_NODE from the wait list, Case D.

...

Looking for event(s) of an Event Flag Group, OSFlagAccept()

The code to look for desired event(s) from an event flag group without waiting is shown in listing 9.10. This function is quite similar to OSFlagPend() except that the caller will not be suspended (i.e. blocked) should the event(s) not be present. The only two things that are different are:

  1. OSFlagAccept() can be called from an ISR unlike some of the other calls.
  2. If the conditions are NOT met, the call does not block and simply returns an error code that the caller should check.

...

Querying an Event Flag Group, OSFlagQuery()

OSFlagQuery() allows your code to get the current value of the event flag group. The code for this function is shown in listing 9.11.

...