Flags objects

Flags are simple objects responsible for small amount of data exchange. It is a set of bit-flags that allow the setting or resetting of each bit-flag state individually and return information on all successfully modified flags.

Flags creation and deletion

The function osCreateFlags creates a flags object. The flags object can be created before system start, from an interrupt handler or by a task. During flags creation, an optional object name may be specified. It makes tasks able to open it by osOpenFlags function. During flags creation and opening, its handle is returned. The handle is assigned by the system and it is used to discern the system objects. All operations performed on the flags except to specify its handle. The non-used flags should be closed with the osCloseHandle. Flags object will be deleted when it will be closed by all tasks that opened it. More information you can find in the system objects management section.

When flags objects are not used, the OS_USE_FLAGS constant may be set to 0, to reduce the output code.

Using an flags object

A flags object is a set of bit-flags generally used to provide the information on events occurrence. The number of available bit-flags depends on architecture configuration and it is 8 * size of INDEX type. The object state is signaled when at least one of the flag is set, otherwise it is non-signaled. The flag state can be modified any time by osSetFlags that sets the state of masked flags for 1, and osResetFlags that resets this state to 0.

During modifying flag state, it is returned the information whether the flag has been modified successfully (i.e. if its previous state differ from the setting now). The flags state can be read in any time by osGetFlags function.

SpaceShadow documentation