CMSIS-OS2 api 线程标志学习

后续随进度会更新。。。

–线程标志–

线程标志(和事件标志接近)可用于进程间通信。比如笔者做的蓝牙指纹锁项目,蓝牙收到消息 给指纹任务设置一个线程标志,指纹任务等到标志不再阻塞根据线程标志执行对应指纹任务(注册,删除,休眠。。。)。

线程标志设置函数:

uint32_t osThreadFlagsSet   (      osThreadId_t       thread_id,uint32_t        flags )     
thread_id:是线程ID
flags:是线程标志,根据需要设置

线程标志清除函数:

uint32_t osThreadFlagsClear(uint32_t flags)

返回当前线程标志:

uint32_t osThreadFlagsGet(void )

等待线程标志:

功能:等待当前线程的标志被设置

flags:等待的标志
options: 
	osFlagsWaitAny        0x00000000U  等待任意标志被设置
	osFlagsWaitAll        0x00000001U  等待所有标志被设置
	osFlagsNoClear        0x00000002U  不清除被设置的标志
timeout:0值为等待超时的tick数;  0 永久等待无限超时;

返回值:被清除前的标志  或  错误码(最高位是1)
uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);

猜你喜欢

转载自blog.csdn.net/qq_28851611/article/details/108291381