0221 FreeRTOS事件组获得标志位

#include 	"event_groups.h"	

void StartTask02(void *argument)
{
  /* USER CODE BEGIN StartTask02 */
  /* Infinite loop */
/*事件组位置位*************************************************************/
	xEventGroupSetBits(myEvent01Handle, 0x01<<0);//  0001   1
	xEventGroupSetBits(myEvent01Handle, 0x01<<1);//  0011   3
  for(;;)
  {
/*获得标志位清零1************************************************************/
		EventBits_t curBit0 = xEventGroupClearBits(myEvent01Handle,0x01<<0);//0011 
		EventBits_t curBit1 = xEventGroupClearBits(myEvent01Handle,0x01<<1);//0010
		if(curBit0&0x01<<0)
		{
			printf("curBit0:%d\r\n",curBit0&0x01<<0);//1
		}
		if(curBit1&0x01<<1)
		{
			printf("curBit1:%d\r\n",curBit1&0x01<<1);//2
		}			
		
/*获得标志位清零2************************************************************/
		if(xEventGroupClearBits(myEvent01Handle,0x01<<0)&0x01<<0)
		{
			 
          printf("curBit0:%d\r\n",xEventGroupClearBits(myEvent01Handle,0x01<<0)&0x01<<0);
		}
		if(xEventGroupClearBits(myEvent01Handle,0x01<<1)&0x01<<1)
		{
		   
          printf("curBit1:%d\r\n",xEventGroupClearBits(myEvent01Handle,0x01<<1)&0x01<<1);
		}		
/*获得标志位不清零*************************************************************/	
		if(xEventGroupGetBits(myEvent01Handle)&0x01<<0)
		{
			printf("curBit0:%d\r\n",xEventGroupGetBits(myEvent01Handle)&0x01<<0);//0
		}
		if(xEventGroupGetBits(myEvent01Handle)&0x01<<1)
		{
			printf("curBit1:%d\r\n",xEventGroupGetBits(myEvent01Handle)&0x01<<1);//0
		}

    vTaskDelay(1);
  }

  /* USER CODE END StartTask02 */
}
xEventGroupWaitBits(SerialEventHandle,  \
                              0x01<<0,  \
                              pdFALSE,  \   //pdF退出时不清零
                               pdTRUE,  \   //pdT与
                        portMAX_DELAY);
                                           

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值