Updated Mar 2025
xEventGroupClearBits()
event_groups.h
1EventBits_t xEventGroupClearBits(2 EventGroupHandle_t xEventGroup,3 const EventBits_t uxBitsToClear );
Clear bits (flags) within an RTOS event group. This function cannot be called from an interrupt. See xEventGroupClearBitsFromISR() for a version that can be called from an interrupt.
The RTOS source file FreeRTOS/source/event_groups.c must be included in the build for the
xEventGroupClearBits()
Parameters:
-
xEventGroup
The event group in which the bits are to be cleared. The event group must have previously been created using a call to xEventGroupCreate().
-
uxBitsToClear
A bitwise value that indicates the bit or bits to clear in the event group. For example set
to 0x08 to clear just bit 3. SetuxBitsToClearto 0x09 to clear bit 3 and bit 0.uxBitsToClear
Returns:
- The value of the event group before the specified bits were cleared.
Example usage:
1#define BIT_0 ( 1 << 0 )2#define BIT_4 ( 1 << 4 )34void aFunction( EventGroupHandle_t xEventGroup )5{6 EventBits_t uxBits;78 /* Clear bit 0 and bit 4 in xEventGroup. */9 uxBits = xEventGroupClearBits(10 xEventGroup, /* The event group being updated. */11 BIT_0 | BIT_4 ); /* The bits being cleared. */1213 if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )14 {15 /* Both bit 0 and bit 4 were set before xEventGroupClearBits()16 was called. Both will now be clear (not set). */17 }18 else if( ( uxBits & BIT_0 ) != 0 )19 {20 /* Bit 0 was set before xEventGroupClearBits() was called. It will21 now be clear. */22 }23 else if( ( uxBits & BIT_4 ) != 0 )24 {25 /* Bit 4 was set before xEventGroupClearBits() was called. It will26 now be clear. */27 }28 else29 {30 /* Neither bit 0 nor bit 4 were set in the first place. */31 }32}