2 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3 // ==== Thread Flags Management ====
5 \addtogroup CMSIS_RTOS_ThreadFlagsMgmt Thread Flags
7 \brief Synchronize threads using flags.
9 Thread Flags are a more specialized version of the Event Flags. See \ref CMSIS_RTOS_EventFlags.
10 While Event Flags can be used to globally signal a number of threads, thread flags are only send to a single specific thread. Every thread instance can receive thread flags without any additional allocation of a thread flags object.
14 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
15 /** \fn int32_t osThreadFlagsSet (osThreadId_t thread_id, int32_t flags )
16 Set the thread flags for a thread instance specified by \em thread_id. This function may be used also within interrupt service routines.
17 The threads waiting for the flag set will be notified to resume from BLOCKED state.
21 void Thread (void *arg);
23 static void EX_Signal_1 (void) {
25 osThreadId_t thread_id;
27 thread_id = osThreadCreate (Thread, NULL, NULL);
28 signals = osThreadFlagsSet (event_id, 0x00000001ul); // Send signals to the created thread
32 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
33 /** \fn osStatus osThreadFlagsClear (int32_t flags)
35 Clear the specified event flags set for the a calling thread.
38 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
39 /** \fn int32_t osThreadFlagsGet (void)
41 Return the event flags currently set for the calling thread.
44 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
45 /** \fn int32_t osThreadFlagsWait (int32_t flags, uint32_t options, uint32_t timeout)
46 Suspend the execution of the current \b RUNNING thread until any or all specified thread flags with the parameter \a flags are set.
47 The \em options parameter specifies the wait condition.
50 |--------------------|-------------------------------------------------------|
51 |\b osFlagsWaitAny | Wait for any flag (default). |
52 |\b osFlagsWaitAll | Wait for all flags. |
53 |\b osFlagsNoClear | Do not clear flags which have been specified to wait for. |
55 If osFlagsNoClear is set in the options \ref osThreadFlagsClear can be used to clear flags manually.
57 When these thread flags are already set, the function returns instantly. Otherwise the thread is put into the state \b BLOCKED.
62 #include "cmsis_os2.h"
64 void Thread (void* arg) {
66 osThreadFlagsWait (0x00000001ul, NULL, osWaitForever); //Wait forever until event 0x01 is set.