xEventGroupClearBits()
[事件组 API]
event_groups.h
EventBits_t xEventGroupClearBits(
EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToClear );
清除 RTOS 事件组中的位(标志)。 无法从中断调用此函数
。 有关可从中断调用的版本,请参阅 xEventGroupClearBitsFromISR()
。
RTOS 源文件 FreeRTOS/source/event_groups.c 必须
包含在 xEventGroupClearBits() 函数可用的构建中。
-
参数:
-
xEventGroup
|
要在其中清除位的事件组。 此事件组
必须已通过
调用 xEventGroupCreate() 事先创建。
|
uxBitsToClear
|
表示要在事件组中清除一个或多个位的
按位值。 例如,将 uxBitsToClear 设置为 0x08
以仅清除位 3。 将 uxBitsToClear 设置为 0x09 以清除位 3
和位 0。
|
-
返回:
-
清除指定位之前的事件组的值。
用法示例:
#define BIT_0 ( 1 << 0 )
#define BIT_4 ( 1 << 4 )
void aFunction( EventGroupHandle_t xEventGroup )
{
EventBits_t uxBits;
/* Clear bit 0 and bit 4 in xEventGroup. */
uxBits = xEventGroupClearBits(
xEventGroup, /* The event group being updated. */
BIT_0 | BIT_4 );/* The bits being cleared. */
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
{
/* Both bit 0 and bit 4 were set before xEventGroupClearBits()
was called. Both will now be clear (not set). */
}
else if( ( uxBits & BIT_0 ) != 0 )
{
/* Bit 0 was set before xEventGroupClearBits() was called. It will
now be clear. */
}
else if( ( uxBits & BIT_4 ) != 0 )
{
/* Bit 4 was set before xEventGroupClearBits() was called. It will
now be clear. */
}
else
{
/* Neither bit 0 nor bit 4 were set in the first place. */
}
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.