按照您给的提示,问题解决了。
[C] 纯文本查看 复制代码
#define BIT_0 ( 1 << 0 )
#define BIT_4 ( 1 << 4 )
void aFunction( EventGroupHandle_t xEventGroup )
{
EventBits_t uxBits;
const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
/* Wait a maximum of 100ms for either bit 0 or bit 4 to be set within
the event group. Clear the bits before exiting. */
uxBits = xEventGroupWaitBits(
xEventGroup, /* The event group being tested. */
BIT_0 | BIT_4, /* The bits within the event group to wait for. */
pdTRUE, /* BIT_0 & BIT_4 should be cleared before returning. */
pdFALSE, /* Don't wait for both bits, either bit will do. */
xTicksToWait );/* Wait a maximum of 100ms for either bit to be set. */
if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
{
/* xEventGroupWaitBits() returned because both bits were set. */
}
else if( ( uxBits & BIT_0 ) != 0 )
{
/* xEventGroupWaitBits() returned because just BIT_0 was set. */
}
else if( ( uxBits & BIT_4 ) != 0 )
{
/* xEventGroupWaitBits() returned because just BIT_4 was set. */
}
else
{
/* xEventGroupWaitBits() returned because xTicksToWait ticks passed
without either BIT_0 or BIT_4 becoming set. */
}
}
也去查了下API手册,
应该是对事件返回的值进行判断。正常是返回对应事件位,后续可以判断这个事件位。
挂起任务后,返回的是osFlagsErrorTimeout 0xFFFFFFFE 错误代码
另注意:如果按照上述代码判断方式,假如用Bit2=1 判断 时 & 错误代码, 也会 !=0 。
判断方法,需另写即可。
再次感谢坛主指教,授人以鱼不如授人以渔。 |