From 9f95ff5b6ba01db09552b84a0ab79607060a2666 Mon Sep 17 00:00:00 2001 From: Ali Labbene Date: Wed, 11 Dec 2019 08:59:21 +0100 Subject: Official ARM version: v5.4.0 Add CMSIS V5.4.0, please refer to index.html available under \docs folder. Note: content of \CMSIS\Core\Include has been copied under \Include to keep the same structure used in existing projects, and thus avoid projects mass update Note: the following components have been removed from ARM original delivery (as not used in ST packages) - CMSIS_EW2018.pdf - .gitattributes - .gitignore - \Device - \CMSIS - \CoreValidation - \DAP - \Documentation - \DoxyGen - \Driver - \Pack - \RTOS\CMSIS_RTOS_Tutorial.pdf - \RTOS\RTX - \RTOS\Template - \RTOS2\RTX - \Utilities - All ARM/GCC projects files are deleted from \DSP, \RTOS and \RTOS2 Change-Id: Ia026c3f0f0d016627a4fb5a9032852c33d24b4d3 --- .../html/group__CMSIS__RTOS__ThreadFlagsMgmt.html | 376 +++++++++++++++++++++ 1 file changed, 376 insertions(+) create mode 100644 docs/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html (limited to 'docs/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html') diff --git a/docs/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html b/docs/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html new file mode 100644 index 0000000..5c25af2 --- /dev/null +++ b/docs/RTOS2/html/group__CMSIS__RTOS__ThreadFlagsMgmt.html @@ -0,0 +1,376 @@ + + + + + +Thread Flags +CMSIS-RTOS2: Thread Flags + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
CMSIS-RTOS2 +  Version 2.1.3 +
+
Real-Time Operating System: API and RTX Reference Implementation
+
+
+ +
+
    + +
+
+ + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+ +
+
Thread Flags
+
+
+ +

Synchronize threads using flags. +More...

+ + + + + + + + + + + + + + +

+Functions

uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags)
 Set the specified Thread Flags of a thread. More...
 
uint32_t osThreadFlagsClear (uint32_t flags)
 Clear the specified Thread Flags of current running thread. More...
 
uint32_t osThreadFlagsGet (void)
 Get the current Thread Flags of current running thread. More...
 
uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout)
 Wait for one or more Thread Flags of the current running thread to become signaled. More...
 
+

Description

+

Thread Flags are a more specialized version of the Event Flags. See Event Flags. 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.

+
Note
Thread flag management functions cannot be called from Interrupt Service Routines, except for osThreadFlagsSet.
+

Usage Example

+

The following (incomplete) code excerpt sketches the usage principals for Thread Flags.

+

The behavior is the following:

+
    +
  • app_main starts executing
  • +
  • statement A sets thread flags to 0x02 (flags = 0x02 – after set)
  • +
  • app_main enters delay
  • +
  • execution switches to threadX
  • +
  • statement B waits for flag 0x01 and blocks since flag is not set
  • +
  • execution switches to app_main
  • +
  • statement C sets thread flags to 0x07
  • +
  • threadX wakes-up and clears flag 0x01, thread flags = 0x06, return value set to 0x07 (before clear), note: all this happens during statement C
  • +
  • statement C returns with flags = 0x06
  • +
  • app_main enters delay
  • +
  • execution switches to threadX
  • +
  • statement B returns with flagsX = 0x07
  • +
+
#include "cmsis_os2.h"
+
+ +
uint32_t flagsX;
+
uint32_t flags;
+
+
void threadX (void *argument) {
+
+
osDelay(1U);
+
for (;;) {
+
flagsX = osThreadFlagsWait(0x0001U, osFlagsWaitAny, osWaitForever); /* B */
+
}
+
}
+
+
void app_main (void *argument) {
+
+
tid = osThreadNew(threadX, NULL, NULL);
+
+
flags = osThreadFlagsSet(tid, 0x0002U); /* A */
+
osDelay(2U);
+
flags = osThreadFlagsSet(tid, 0x0005U); /* C */
+
osDelay(2U);
+
+
for(;;);
+
}
+

Function Documentation

+ +
+
+ + + + + + + + + + + + + + + + + + +
uint32_t osThreadFlagsSet (osThreadId_t thread_id,
uint32_t flags 
)
+
+
Parameters
+ + + +
[in]thread_idthread ID obtained by osThreadNew or osThreadGetId.
[in]flagsspecifies the flags of the thread that shall be set.
+
+
+
Returns
thread flags after setting or error code if highest bit set.
+

The function osThreadFlagsSet sets the thread flags for a thread specified by parameter thread_id. It returns the flags set, or an error code if highest bit is set (refer to Flags Functions Error Codes). This function may be used also within interrupt service routines. Threads waiting for a flag to be set will resume from BLOCKED state.

+

Possible Flags Functions Error Codes return values:

+
    +
  • osFlagsErrorUnknown: Unspecified error.
  • +
  • osFlagsErrorResource: Thread specified by parameter thread_id is not active to receive flags.
  • +
  • osFlagsErrorParameter: Parameter thread_id is not a valid thread or flags has highest bit set.
  • +
+
Note
This function may be called from Interrupt Service Routines.
+

Code Example

+
/*----------------------------------------------------------------------------
+
* Function 'signal_func' called from multiple threads
+
*---------------------------------------------------------------------------*/
+
void signal_func (osThreadId_t tid) {
+
osThreadFlagsSet(tid_clock, 0x0100); /* set signal to clock thread */
+
osDelay(500); /* delay 500ms */
+
osThreadFlagsSet(tid_clock, 0x0100); /* set signal to clock thread */
+
osDelay(500); /* delay 500ms */
+
osThreadFlagsSet(tid, 0x0001); /* set signal to thread 'thread' */
+
osDelay(500); /* delay 500ms */
+
}
+
+
+
+ +
+
+ + + + + + + + +
uint32_t osThreadFlagsClear (uint32_t flags)
+
+
Parameters
+ + +
[in]flagsspecifies the flags of the thread that shall be cleared.
+
+
+
Returns
thread flags before clearing or error code if highest bit set.
+

The function osThreadFlagsClear clears the specified flags for the currently running thread. It returns the flags before clearing, or an error code if highest bit is set (refer to Flags Functions Error Codes).

+

Possible Flags Functions Error Codes return values:

+
    +
  • osFlagsErrorUnknown: Unspecified error, i.e. not called from a running threads context.
  • +
  • osFlagsErrorResource: Running thread is not active to receive flags.
  • +
  • osFlagsErrorParameter: Parameter flags has highest bit set.
  • +
+
Note
This function cannot be called from Interrupt Service Routines.
+ +
+
+ +
+
+ + + + + + + + +
uint32_t osThreadFlagsGet (void )
+
+
Returns
current thread flags.
+

The function osThreadFlagsGet returns the flags currently set for the currently running thread. If called without a active and currently running thread osThreadFlagsGet return zero.

+
Note
This function cannot be called from Interrupt Service Routines.
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
uint32_t osThreadFlagsWait (uint32_t flags,
uint32_t options,
uint32_t timeout 
)
+
+
Parameters
+ + + + +
[in]flagsspecifies the flags to wait for.
[in]optionsspecifies flags options (osFlagsXxxx).
[in]timeoutTimeout Value or 0 in case of no time-out.
+
+
+
Returns
thread flags before clearing or error code if highest bit set.
+

The function osThreadFlagsWait suspends the execution of the currently RUNNING thread until any or all of the thread flags specified with the parameter flags are set. When these thread flags are already set, the function returns instantly. Otherwise the thread is put into the state BLOCKED.

+

The parameter options specifies the wait condition:

+ + + + + + + + + +
Option
osFlagsWaitAny Wait for any flag (default).
osFlagsWaitAll Wait for all flags.
osFlagsNoClear Do not clear flags which have been specified to wait for.
+

If osFlagsNoClear is set in the options osThreadFlagsClear can be used to clear flags manually. Otherwise osThreadFlagsWait automatically clears the flags waited for.

+

The parameter timeout represents a number of timer ticks and is an upper bound. The exact time delay depends on the actual time elapsed since the last timer tick.

+

The function returns the flags before clearing, or an error code if highest bit is set (refer to Flags Functions Error Codes).

+

Possible Flags Functions Error Codes return values:

+
    +
  • osFlagsErrorUnknown: Unspecified error, i.e. not called from a running threads context.
  • +
  • osFlagsErrorTimeout: The awaited flags has not been set during given timeout.
  • +
  • osFlagsErrorResource: Running thread is not active to receive flags.
  • +
  • osFlagsErrorParameter: Parameter flags has highest bit set.
  • +
+
Note
This function cannot be called from Interrupt Service Routines.
+

Code Example

+
#include "cmsis_os2.h"
+
+
void Thread (void* arg) {
+
;
+
osThreadFlagsWait (0x00000001U, osFlagsWaitAny, osWaitForever); // Wait forever until thread flag 1 is set.
+
;
+
osThreadFlagsWait (0x00000003U, osFlagsWaitAny, osWaitForever); // Wait forever until either thread flag 0 or 1 is set.
+
;
+
osThreadFlagsWait (0x00000003U, osFlagsWaitAll, 10); // Wait for 10 timer ticks until thread flags 0 and 1 are set. Timeout afterwards.
+
;
+
osThreadFlagsWait (0x00000003U, osFlagsWaitAll | osFlagsNoClear, osWaitForever); // Same as the above, but the flags will not be cleared.
+
}
+
+
+
+
+
+ + + + -- cgit