CMSIS-OS2 api thread flag learning

Follow-up will be updated with progress. . .

--Thread flags--

The thread flag (close to the event flag) can be used for inter-process communication. For example, in the Bluetooth fingerprint lock project I made, Bluetooth receives a message and sets a thread flag for the fingerprint task. The fingerprint task waits until the flag is no longer blocked and executes the corresponding fingerprint task (register, delete, sleep...) according to the thread flag.

Thread flag setting function:

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

Thread flag clear function:

uint32_t osThreadFlagsClear(uint32_t flags)

Return the current thread flag:

uint32_t osThreadFlagsGet(void )

Waiting for the thread flag:

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

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);

Guess you like

Origin blog.csdn.net/qq_28851611/article/details/108291381