firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
xEventGroupCreate
Collaboration diagram for xEventGroupCreate:

event_groups.h

EventGroupHandle_t xEventGroupCreate( void );
struct EventGroupDef_t * EventGroupHandle_t
Definition event_groups.h:103

Create a new event group.

Internally, within the FreeRTOS implementation, event groups use a [small] block of memory, in which the event group's structure is stored. If an event groups is created using xEventGroupCreate() then the required memory is automatically dynamically allocated inside the xEventGroupCreate() function. (see https://www.FreeRTOS.org/a00111.html). If an event group is created using xEventGroupCreateStatic() then the application writer must instead provide the memory that will get used by the event group. xEventGroupCreateStatic() therefore allows an event group to be created without using any dynamic memory allocation.

Although event groups are not related to ticks, for internal implementation reasons the number of bits available for use in an event group is dependent on the configTICK_TYPE_WIDTH_IN_BITS setting in FreeRTOSConfig.h. If configTICK_TYPE_WIDTH_IN_BITS is 0 then each event group contains 8 usable bits (bit 0 to bit 7). If configTICK_TYPE_WIDTH_IN_BITS is set to 1 then each event group has 24 usable bits (bit 0 to bit 23). If configTICK_TYPE_WIDTH_IN_BITS is set to 2 then each event group has 56 usable bits (bit 0 to bit 53). The EventBits_t type is used to store event bits within an event group.

The configUSE_EVENT_GROUPS configuration constant must be set to 1 for xEventGroupCreate() to be available.

Returns
If the event group was created then a handle to the event group is returned. If there was insufficient FreeRTOS heap available to create the event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html

Example usage:

// Declare a variable to hold the created event group.
EventGroupHandle_t xCreatedEventGroup;
// Attempt to create the event group.
xCreatedEventGroup = xEventGroupCreate();
// Was the event group created successfully?
if( xCreatedEventGroup == NULL )
{
// The event group was not created because there was insufficient
// FreeRTOS heap available.
}
else
{
// The event group was created.
}