xref: /btstack/port/stm32-f4discovery-usb/Drivers/CMSIS/RTOS2/Include/cmsis_os2.h (revision a8f7f3fcbcd51f8d2e92aca076b6a9f812db358c)
1*a8f7f3fcSMatthias Ringwald /*
2*a8f7f3fcSMatthias Ringwald  * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
3*a8f7f3fcSMatthias Ringwald  *
4*a8f7f3fcSMatthias Ringwald  * SPDX-License-Identifier: Apache-2.0
5*a8f7f3fcSMatthias Ringwald  *
6*a8f7f3fcSMatthias Ringwald  * Licensed under the Apache License, Version 2.0 (the License); you may
7*a8f7f3fcSMatthias Ringwald  * not use this file except in compliance with the License.
8*a8f7f3fcSMatthias Ringwald  * You may obtain a copy of the License at
9*a8f7f3fcSMatthias Ringwald  *
10*a8f7f3fcSMatthias Ringwald  * www.apache.org/licenses/LICENSE-2.0
11*a8f7f3fcSMatthias Ringwald  *
12*a8f7f3fcSMatthias Ringwald  * Unless required by applicable law or agreed to in writing, software
13*a8f7f3fcSMatthias Ringwald  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14*a8f7f3fcSMatthias Ringwald  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15*a8f7f3fcSMatthias Ringwald  * See the License for the specific language governing permissions and
16*a8f7f3fcSMatthias Ringwald  * limitations under the License.
17*a8f7f3fcSMatthias Ringwald  *
18*a8f7f3fcSMatthias Ringwald  * ----------------------------------------------------------------------
19*a8f7f3fcSMatthias Ringwald  *
20*a8f7f3fcSMatthias Ringwald  * $Date:        18. June 2018
21*a8f7f3fcSMatthias Ringwald  * $Revision:    V2.1.3
22*a8f7f3fcSMatthias Ringwald  *
23*a8f7f3fcSMatthias Ringwald  * Project:      CMSIS-RTOS2 API
24*a8f7f3fcSMatthias Ringwald  * Title:        cmsis_os2.h header file
25*a8f7f3fcSMatthias Ringwald  *
26*a8f7f3fcSMatthias Ringwald  * Version 2.1.3
27*a8f7f3fcSMatthias Ringwald  *    Additional functions allowed to be called from Interrupt Service Routines:
28*a8f7f3fcSMatthias Ringwald  *    - osThreadGetId
29*a8f7f3fcSMatthias Ringwald  * Version 2.1.2
30*a8f7f3fcSMatthias Ringwald  *    Additional functions allowed to be called from Interrupt Service Routines:
31*a8f7f3fcSMatthias Ringwald  *    - osKernelGetInfo, osKernelGetState
32*a8f7f3fcSMatthias Ringwald  * Version 2.1.1
33*a8f7f3fcSMatthias Ringwald  *    Additional functions allowed to be called from Interrupt Service Routines:
34*a8f7f3fcSMatthias Ringwald  *    - osKernelGetTickCount, osKernelGetTickFreq
35*a8f7f3fcSMatthias Ringwald  *    Changed Kernel Tick type to uint32_t:
36*a8f7f3fcSMatthias Ringwald  *    - updated: osKernelGetTickCount, osDelayUntil
37*a8f7f3fcSMatthias Ringwald  * Version 2.1.0
38*a8f7f3fcSMatthias Ringwald  *    Support for critical and uncritical sections (nesting safe):
39*a8f7f3fcSMatthias Ringwald  *    - updated: osKernelLock, osKernelUnlock
40*a8f7f3fcSMatthias Ringwald  *    - added: osKernelRestoreLock
41*a8f7f3fcSMatthias Ringwald  *    Updated Thread and Event Flags:
42*a8f7f3fcSMatthias Ringwald  *    - changed flags parameter and return type from int32_t to uint32_t
43*a8f7f3fcSMatthias Ringwald  * Version 2.0.0
44*a8f7f3fcSMatthias Ringwald  *    Initial Release
45*a8f7f3fcSMatthias Ringwald  *---------------------------------------------------------------------------*/
46*a8f7f3fcSMatthias Ringwald 
47*a8f7f3fcSMatthias Ringwald #ifndef CMSIS_OS2_H_
48*a8f7f3fcSMatthias Ringwald #define CMSIS_OS2_H_
49*a8f7f3fcSMatthias Ringwald 
50*a8f7f3fcSMatthias Ringwald #ifndef __NO_RETURN
51*a8f7f3fcSMatthias Ringwald #if   defined(__CC_ARM)
52*a8f7f3fcSMatthias Ringwald #define __NO_RETURN __declspec(noreturn)
53*a8f7f3fcSMatthias Ringwald #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
54*a8f7f3fcSMatthias Ringwald #define __NO_RETURN __attribute__((__noreturn__))
55*a8f7f3fcSMatthias Ringwald #elif defined(__GNUC__)
56*a8f7f3fcSMatthias Ringwald #define __NO_RETURN __attribute__((__noreturn__))
57*a8f7f3fcSMatthias Ringwald #elif defined(__ICCARM__)
58*a8f7f3fcSMatthias Ringwald #define __NO_RETURN __noreturn
59*a8f7f3fcSMatthias Ringwald #else
60*a8f7f3fcSMatthias Ringwald #define __NO_RETURN
61*a8f7f3fcSMatthias Ringwald #endif
62*a8f7f3fcSMatthias Ringwald #endif
63*a8f7f3fcSMatthias Ringwald 
64*a8f7f3fcSMatthias Ringwald #include <stdint.h>
65*a8f7f3fcSMatthias Ringwald #include <stddef.h>
66*a8f7f3fcSMatthias Ringwald 
67*a8f7f3fcSMatthias Ringwald #ifdef  __cplusplus
68*a8f7f3fcSMatthias Ringwald extern "C"
69*a8f7f3fcSMatthias Ringwald {
70*a8f7f3fcSMatthias Ringwald #endif
71*a8f7f3fcSMatthias Ringwald 
72*a8f7f3fcSMatthias Ringwald 
73*a8f7f3fcSMatthias Ringwald //  ==== Enumerations, structures, defines ====
74*a8f7f3fcSMatthias Ringwald 
75*a8f7f3fcSMatthias Ringwald /// Version information.
76*a8f7f3fcSMatthias Ringwald typedef struct {
77*a8f7f3fcSMatthias Ringwald   uint32_t                       api;   ///< API version (major.minor.rev: mmnnnrrrr dec).
78*a8f7f3fcSMatthias Ringwald   uint32_t                    kernel;   ///< Kernel version (major.minor.rev: mmnnnrrrr dec).
79*a8f7f3fcSMatthias Ringwald } osVersion_t;
80*a8f7f3fcSMatthias Ringwald 
81*a8f7f3fcSMatthias Ringwald /// Kernel state.
82*a8f7f3fcSMatthias Ringwald typedef enum {
83*a8f7f3fcSMatthias Ringwald   osKernelInactive        =  0,         ///< Inactive.
84*a8f7f3fcSMatthias Ringwald   osKernelReady           =  1,         ///< Ready.
85*a8f7f3fcSMatthias Ringwald   osKernelRunning         =  2,         ///< Running.
86*a8f7f3fcSMatthias Ringwald   osKernelLocked          =  3,         ///< Locked.
87*a8f7f3fcSMatthias Ringwald   osKernelSuspended       =  4,         ///< Suspended.
88*a8f7f3fcSMatthias Ringwald   osKernelError           = -1,         ///< Error.
89*a8f7f3fcSMatthias Ringwald   osKernelReserved        = 0x7FFFFFFFU ///< Prevents enum down-size compiler optimization.
90*a8f7f3fcSMatthias Ringwald } osKernelState_t;
91*a8f7f3fcSMatthias Ringwald 
92*a8f7f3fcSMatthias Ringwald /// Thread state.
93*a8f7f3fcSMatthias Ringwald typedef enum {
94*a8f7f3fcSMatthias Ringwald   osThreadInactive        =  0,         ///< Inactive.
95*a8f7f3fcSMatthias Ringwald   osThreadReady           =  1,         ///< Ready.
96*a8f7f3fcSMatthias Ringwald   osThreadRunning         =  2,         ///< Running.
97*a8f7f3fcSMatthias Ringwald   osThreadBlocked         =  3,         ///< Blocked.
98*a8f7f3fcSMatthias Ringwald   osThreadTerminated      =  4,         ///< Terminated.
99*a8f7f3fcSMatthias Ringwald   osThreadError           = -1,         ///< Error.
100*a8f7f3fcSMatthias Ringwald   osThreadReserved        = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.
101*a8f7f3fcSMatthias Ringwald } osThreadState_t;
102*a8f7f3fcSMatthias Ringwald 
103*a8f7f3fcSMatthias Ringwald /// Priority values.
104*a8f7f3fcSMatthias Ringwald typedef enum {
105*a8f7f3fcSMatthias Ringwald   osPriorityNone          =  0,         ///< No priority (not initialized).
106*a8f7f3fcSMatthias Ringwald   osPriorityIdle          =  1,         ///< Reserved for Idle thread.
107*a8f7f3fcSMatthias Ringwald   osPriorityLow           =  8,         ///< Priority: low
108*a8f7f3fcSMatthias Ringwald   osPriorityLow1          =  8+1,       ///< Priority: low + 1
109*a8f7f3fcSMatthias Ringwald   osPriorityLow2          =  8+2,       ///< Priority: low + 2
110*a8f7f3fcSMatthias Ringwald   osPriorityLow3          =  8+3,       ///< Priority: low + 3
111*a8f7f3fcSMatthias Ringwald   osPriorityLow4          =  8+4,       ///< Priority: low + 4
112*a8f7f3fcSMatthias Ringwald   osPriorityLow5          =  8+5,       ///< Priority: low + 5
113*a8f7f3fcSMatthias Ringwald   osPriorityLow6          =  8+6,       ///< Priority: low + 6
114*a8f7f3fcSMatthias Ringwald   osPriorityLow7          =  8+7,       ///< Priority: low + 7
115*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal   = 16,         ///< Priority: below normal
116*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal1  = 16+1,       ///< Priority: below normal + 1
117*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal2  = 16+2,       ///< Priority: below normal + 2
118*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal3  = 16+3,       ///< Priority: below normal + 3
119*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal4  = 16+4,       ///< Priority: below normal + 4
120*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal5  = 16+5,       ///< Priority: below normal + 5
121*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal6  = 16+6,       ///< Priority: below normal + 6
122*a8f7f3fcSMatthias Ringwald   osPriorityBelowNormal7  = 16+7,       ///< Priority: below normal + 7
123*a8f7f3fcSMatthias Ringwald   osPriorityNormal        = 24,         ///< Priority: normal
124*a8f7f3fcSMatthias Ringwald   osPriorityNormal1       = 24+1,       ///< Priority: normal + 1
125*a8f7f3fcSMatthias Ringwald   osPriorityNormal2       = 24+2,       ///< Priority: normal + 2
126*a8f7f3fcSMatthias Ringwald   osPriorityNormal3       = 24+3,       ///< Priority: normal + 3
127*a8f7f3fcSMatthias Ringwald   osPriorityNormal4       = 24+4,       ///< Priority: normal + 4
128*a8f7f3fcSMatthias Ringwald   osPriorityNormal5       = 24+5,       ///< Priority: normal + 5
129*a8f7f3fcSMatthias Ringwald   osPriorityNormal6       = 24+6,       ///< Priority: normal + 6
130*a8f7f3fcSMatthias Ringwald   osPriorityNormal7       = 24+7,       ///< Priority: normal + 7
131*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal   = 32,         ///< Priority: above normal
132*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal1  = 32+1,       ///< Priority: above normal + 1
133*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal2  = 32+2,       ///< Priority: above normal + 2
134*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal3  = 32+3,       ///< Priority: above normal + 3
135*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal4  = 32+4,       ///< Priority: above normal + 4
136*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal5  = 32+5,       ///< Priority: above normal + 5
137*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal6  = 32+6,       ///< Priority: above normal + 6
138*a8f7f3fcSMatthias Ringwald   osPriorityAboveNormal7  = 32+7,       ///< Priority: above normal + 7
139*a8f7f3fcSMatthias Ringwald   osPriorityHigh          = 40,         ///< Priority: high
140*a8f7f3fcSMatthias Ringwald   osPriorityHigh1         = 40+1,       ///< Priority: high + 1
141*a8f7f3fcSMatthias Ringwald   osPriorityHigh2         = 40+2,       ///< Priority: high + 2
142*a8f7f3fcSMatthias Ringwald   osPriorityHigh3         = 40+3,       ///< Priority: high + 3
143*a8f7f3fcSMatthias Ringwald   osPriorityHigh4         = 40+4,       ///< Priority: high + 4
144*a8f7f3fcSMatthias Ringwald   osPriorityHigh5         = 40+5,       ///< Priority: high + 5
145*a8f7f3fcSMatthias Ringwald   osPriorityHigh6         = 40+6,       ///< Priority: high + 6
146*a8f7f3fcSMatthias Ringwald   osPriorityHigh7         = 40+7,       ///< Priority: high + 7
147*a8f7f3fcSMatthias Ringwald   osPriorityRealtime      = 48,         ///< Priority: realtime
148*a8f7f3fcSMatthias Ringwald   osPriorityRealtime1     = 48+1,       ///< Priority: realtime + 1
149*a8f7f3fcSMatthias Ringwald   osPriorityRealtime2     = 48+2,       ///< Priority: realtime + 2
150*a8f7f3fcSMatthias Ringwald   osPriorityRealtime3     = 48+3,       ///< Priority: realtime + 3
151*a8f7f3fcSMatthias Ringwald   osPriorityRealtime4     = 48+4,       ///< Priority: realtime + 4
152*a8f7f3fcSMatthias Ringwald   osPriorityRealtime5     = 48+5,       ///< Priority: realtime + 5
153*a8f7f3fcSMatthias Ringwald   osPriorityRealtime6     = 48+6,       ///< Priority: realtime + 6
154*a8f7f3fcSMatthias Ringwald   osPriorityRealtime7     = 48+7,       ///< Priority: realtime + 7
155*a8f7f3fcSMatthias Ringwald   osPriorityISR           = 56,         ///< Reserved for ISR deferred thread.
156*a8f7f3fcSMatthias Ringwald   osPriorityError         = -1,         ///< System cannot determine priority or illegal priority.
157*a8f7f3fcSMatthias Ringwald   osPriorityReserved      = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.
158*a8f7f3fcSMatthias Ringwald } osPriority_t;
159*a8f7f3fcSMatthias Ringwald 
160*a8f7f3fcSMatthias Ringwald /// Entry point of a thread.
161*a8f7f3fcSMatthias Ringwald typedef void (*osThreadFunc_t) (void *argument);
162*a8f7f3fcSMatthias Ringwald 
163*a8f7f3fcSMatthias Ringwald /// Timer callback function.
164*a8f7f3fcSMatthias Ringwald typedef void (*osTimerFunc_t) (void *argument);
165*a8f7f3fcSMatthias Ringwald 
166*a8f7f3fcSMatthias Ringwald /// Timer type.
167*a8f7f3fcSMatthias Ringwald typedef enum {
168*a8f7f3fcSMatthias Ringwald   osTimerOnce               = 0,          ///< One-shot timer.
169*a8f7f3fcSMatthias Ringwald   osTimerPeriodic           = 1           ///< Repeating timer.
170*a8f7f3fcSMatthias Ringwald } osTimerType_t;
171*a8f7f3fcSMatthias Ringwald 
172*a8f7f3fcSMatthias Ringwald // Timeout value.
173*a8f7f3fcSMatthias Ringwald #define osWaitForever         0xFFFFFFFFU ///< Wait forever timeout value.
174*a8f7f3fcSMatthias Ringwald 
175*a8f7f3fcSMatthias Ringwald // Flags options (\ref osThreadFlagsWait and \ref osEventFlagsWait).
176*a8f7f3fcSMatthias Ringwald #define osFlagsWaitAny        0x00000000U ///< Wait for any flag (default).
177*a8f7f3fcSMatthias Ringwald #define osFlagsWaitAll        0x00000001U ///< Wait for all flags.
178*a8f7f3fcSMatthias Ringwald #define osFlagsNoClear        0x00000002U ///< Do not clear flags which have been specified to wait for.
179*a8f7f3fcSMatthias Ringwald 
180*a8f7f3fcSMatthias Ringwald // Flags errors (returned by osThreadFlagsXxxx and osEventFlagsXxxx).
181*a8f7f3fcSMatthias Ringwald #define osFlagsError          0x80000000U ///< Error indicator.
182*a8f7f3fcSMatthias Ringwald #define osFlagsErrorUnknown   0xFFFFFFFFU ///< osError (-1).
183*a8f7f3fcSMatthias Ringwald #define osFlagsErrorTimeout   0xFFFFFFFEU ///< osErrorTimeout (-2).
184*a8f7f3fcSMatthias Ringwald #define osFlagsErrorResource  0xFFFFFFFDU ///< osErrorResource (-3).
185*a8f7f3fcSMatthias Ringwald #define osFlagsErrorParameter 0xFFFFFFFCU ///< osErrorParameter (-4).
186*a8f7f3fcSMatthias Ringwald #define osFlagsErrorISR       0xFFFFFFFAU ///< osErrorISR (-6).
187*a8f7f3fcSMatthias Ringwald 
188*a8f7f3fcSMatthias Ringwald // Thread attributes (attr_bits in \ref osThreadAttr_t).
189*a8f7f3fcSMatthias Ringwald #define osThreadDetached      0x00000000U ///< Thread created in detached mode (default)
190*a8f7f3fcSMatthias Ringwald #define osThreadJoinable      0x00000001U ///< Thread created in joinable mode
191*a8f7f3fcSMatthias Ringwald 
192*a8f7f3fcSMatthias Ringwald // Mutex attributes (attr_bits in \ref osMutexAttr_t).
193*a8f7f3fcSMatthias Ringwald #define osMutexRecursive      0x00000001U ///< Recursive mutex.
194*a8f7f3fcSMatthias Ringwald #define osMutexPrioInherit    0x00000002U ///< Priority inherit protocol.
195*a8f7f3fcSMatthias Ringwald #define osMutexRobust         0x00000008U ///< Robust mutex.
196*a8f7f3fcSMatthias Ringwald 
197*a8f7f3fcSMatthias Ringwald /// Status code values returned by CMSIS-RTOS functions.
198*a8f7f3fcSMatthias Ringwald typedef enum {
199*a8f7f3fcSMatthias Ringwald   osOK                      =  0,         ///< Operation completed successfully.
200*a8f7f3fcSMatthias Ringwald   osError                   = -1,         ///< Unspecified RTOS error: run-time error but no other error message fits.
201*a8f7f3fcSMatthias Ringwald   osErrorTimeout            = -2,         ///< Operation not completed within the timeout period.
202*a8f7f3fcSMatthias Ringwald   osErrorResource           = -3,         ///< Resource not available.
203*a8f7f3fcSMatthias Ringwald   osErrorParameter          = -4,         ///< Parameter error.
204*a8f7f3fcSMatthias Ringwald   osErrorNoMemory           = -5,         ///< System is out of memory: it was impossible to allocate or reserve memory for the operation.
205*a8f7f3fcSMatthias Ringwald   osErrorISR                = -6,         ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.
206*a8f7f3fcSMatthias Ringwald   osStatusReserved          = 0x7FFFFFFF  ///< Prevents enum down-size compiler optimization.
207*a8f7f3fcSMatthias Ringwald } osStatus_t;
208*a8f7f3fcSMatthias Ringwald 
209*a8f7f3fcSMatthias Ringwald 
210*a8f7f3fcSMatthias Ringwald /// \details Thread ID identifies the thread.
211*a8f7f3fcSMatthias Ringwald typedef void *osThreadId_t;
212*a8f7f3fcSMatthias Ringwald 
213*a8f7f3fcSMatthias Ringwald /// \details Timer ID identifies the timer.
214*a8f7f3fcSMatthias Ringwald typedef void *osTimerId_t;
215*a8f7f3fcSMatthias Ringwald 
216*a8f7f3fcSMatthias Ringwald /// \details Event Flags ID identifies the event flags.
217*a8f7f3fcSMatthias Ringwald typedef void *osEventFlagsId_t;
218*a8f7f3fcSMatthias Ringwald 
219*a8f7f3fcSMatthias Ringwald /// \details Mutex ID identifies the mutex.
220*a8f7f3fcSMatthias Ringwald typedef void *osMutexId_t;
221*a8f7f3fcSMatthias Ringwald 
222*a8f7f3fcSMatthias Ringwald /// \details Semaphore ID identifies the semaphore.
223*a8f7f3fcSMatthias Ringwald typedef void *osSemaphoreId_t;
224*a8f7f3fcSMatthias Ringwald 
225*a8f7f3fcSMatthias Ringwald /// \details Memory Pool ID identifies the memory pool.
226*a8f7f3fcSMatthias Ringwald typedef void *osMemoryPoolId_t;
227*a8f7f3fcSMatthias Ringwald 
228*a8f7f3fcSMatthias Ringwald /// \details Message Queue ID identifies the message queue.
229*a8f7f3fcSMatthias Ringwald typedef void *osMessageQueueId_t;
230*a8f7f3fcSMatthias Ringwald 
231*a8f7f3fcSMatthias Ringwald 
232*a8f7f3fcSMatthias Ringwald #ifndef TZ_MODULEID_T
233*a8f7f3fcSMatthias Ringwald #define TZ_MODULEID_T
234*a8f7f3fcSMatthias Ringwald /// \details Data type that identifies secure software modules called by a process.
235*a8f7f3fcSMatthias Ringwald typedef uint32_t TZ_ModuleId_t;
236*a8f7f3fcSMatthias Ringwald #endif
237*a8f7f3fcSMatthias Ringwald 
238*a8f7f3fcSMatthias Ringwald 
239*a8f7f3fcSMatthias Ringwald /// Attributes structure for thread.
240*a8f7f3fcSMatthias Ringwald typedef struct {
241*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the thread
242*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
243*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
244*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
245*a8f7f3fcSMatthias Ringwald   void                   *stack_mem;    ///< memory for stack
246*a8f7f3fcSMatthias Ringwald   uint32_t                stack_size;   ///< size of stack
247*a8f7f3fcSMatthias Ringwald   osPriority_t              priority;   ///< initial thread priority (default: osPriorityNormal)
248*a8f7f3fcSMatthias Ringwald   TZ_ModuleId_t            tz_module;   ///< TrustZone module identifier
249*a8f7f3fcSMatthias Ringwald   uint32_t                  reserved;   ///< reserved (must be 0)
250*a8f7f3fcSMatthias Ringwald } osThreadAttr_t;
251*a8f7f3fcSMatthias Ringwald 
252*a8f7f3fcSMatthias Ringwald /// Attributes structure for timer.
253*a8f7f3fcSMatthias Ringwald typedef struct {
254*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the timer
255*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
256*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
257*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
258*a8f7f3fcSMatthias Ringwald } osTimerAttr_t;
259*a8f7f3fcSMatthias Ringwald 
260*a8f7f3fcSMatthias Ringwald /// Attributes structure for event flags.
261*a8f7f3fcSMatthias Ringwald typedef struct {
262*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the event flags
263*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
264*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
265*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
266*a8f7f3fcSMatthias Ringwald } osEventFlagsAttr_t;
267*a8f7f3fcSMatthias Ringwald 
268*a8f7f3fcSMatthias Ringwald /// Attributes structure for mutex.
269*a8f7f3fcSMatthias Ringwald typedef struct {
270*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the mutex
271*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
272*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
273*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
274*a8f7f3fcSMatthias Ringwald } osMutexAttr_t;
275*a8f7f3fcSMatthias Ringwald 
276*a8f7f3fcSMatthias Ringwald /// Attributes structure for semaphore.
277*a8f7f3fcSMatthias Ringwald typedef struct {
278*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the semaphore
279*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
280*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
281*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
282*a8f7f3fcSMatthias Ringwald } osSemaphoreAttr_t;
283*a8f7f3fcSMatthias Ringwald 
284*a8f7f3fcSMatthias Ringwald /// Attributes structure for memory pool.
285*a8f7f3fcSMatthias Ringwald typedef struct {
286*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the memory pool
287*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
288*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
289*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
290*a8f7f3fcSMatthias Ringwald   void                      *mp_mem;    ///< memory for data storage
291*a8f7f3fcSMatthias Ringwald   uint32_t                   mp_size;   ///< size of provided memory for data storage
292*a8f7f3fcSMatthias Ringwald } osMemoryPoolAttr_t;
293*a8f7f3fcSMatthias Ringwald 
294*a8f7f3fcSMatthias Ringwald /// Attributes structure for message queue.
295*a8f7f3fcSMatthias Ringwald typedef struct {
296*a8f7f3fcSMatthias Ringwald   const char                   *name;   ///< name of the message queue
297*a8f7f3fcSMatthias Ringwald   uint32_t                 attr_bits;   ///< attribute bits
298*a8f7f3fcSMatthias Ringwald   void                      *cb_mem;    ///< memory for control block
299*a8f7f3fcSMatthias Ringwald   uint32_t                   cb_size;   ///< size of provided memory for control block
300*a8f7f3fcSMatthias Ringwald   void                      *mq_mem;    ///< memory for data storage
301*a8f7f3fcSMatthias Ringwald   uint32_t                   mq_size;   ///< size of provided memory for data storage
302*a8f7f3fcSMatthias Ringwald } osMessageQueueAttr_t;
303*a8f7f3fcSMatthias Ringwald 
304*a8f7f3fcSMatthias Ringwald 
305*a8f7f3fcSMatthias Ringwald //  ==== Kernel Management Functions ====
306*a8f7f3fcSMatthias Ringwald 
307*a8f7f3fcSMatthias Ringwald /// Initialize the RTOS Kernel.
308*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
309*a8f7f3fcSMatthias Ringwald osStatus_t osKernelInitialize (void);
310*a8f7f3fcSMatthias Ringwald 
311*a8f7f3fcSMatthias Ringwald ///  Get RTOS Kernel Information.
312*a8f7f3fcSMatthias Ringwald /// \param[out]    version       pointer to buffer for retrieving version information.
313*a8f7f3fcSMatthias Ringwald /// \param[out]    id_buf        pointer to buffer for retrieving kernel identification string.
314*a8f7f3fcSMatthias Ringwald /// \param[in]     id_size       size of buffer for kernel identification string.
315*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
316*a8f7f3fcSMatthias Ringwald osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size);
317*a8f7f3fcSMatthias Ringwald 
318*a8f7f3fcSMatthias Ringwald /// Get the current RTOS Kernel state.
319*a8f7f3fcSMatthias Ringwald /// \return current RTOS Kernel state.
320*a8f7f3fcSMatthias Ringwald osKernelState_t osKernelGetState (void);
321*a8f7f3fcSMatthias Ringwald 
322*a8f7f3fcSMatthias Ringwald /// Start the RTOS Kernel scheduler.
323*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
324*a8f7f3fcSMatthias Ringwald osStatus_t osKernelStart (void);
325*a8f7f3fcSMatthias Ringwald 
326*a8f7f3fcSMatthias Ringwald /// Lock the RTOS Kernel scheduler.
327*a8f7f3fcSMatthias Ringwald /// \return previous lock state (1 - locked, 0 - not locked, error code if negative).
328*a8f7f3fcSMatthias Ringwald int32_t osKernelLock (void);
329*a8f7f3fcSMatthias Ringwald 
330*a8f7f3fcSMatthias Ringwald /// Unlock the RTOS Kernel scheduler.
331*a8f7f3fcSMatthias Ringwald /// \return previous lock state (1 - locked, 0 - not locked, error code if negative).
332*a8f7f3fcSMatthias Ringwald int32_t osKernelUnlock (void);
333*a8f7f3fcSMatthias Ringwald 
334*a8f7f3fcSMatthias Ringwald /// Restore the RTOS Kernel scheduler lock state.
335*a8f7f3fcSMatthias Ringwald /// \param[in]     lock          lock state obtained by \ref osKernelLock or \ref osKernelUnlock.
336*a8f7f3fcSMatthias Ringwald /// \return new lock state (1 - locked, 0 - not locked, error code if negative).
337*a8f7f3fcSMatthias Ringwald int32_t osKernelRestoreLock (int32_t lock);
338*a8f7f3fcSMatthias Ringwald 
339*a8f7f3fcSMatthias Ringwald /// Suspend the RTOS Kernel scheduler.
340*a8f7f3fcSMatthias Ringwald /// \return time in ticks, for how long the system can sleep or power-down.
341*a8f7f3fcSMatthias Ringwald uint32_t osKernelSuspend (void);
342*a8f7f3fcSMatthias Ringwald 
343*a8f7f3fcSMatthias Ringwald /// Resume the RTOS Kernel scheduler.
344*a8f7f3fcSMatthias Ringwald /// \param[in]     sleep_ticks   time in ticks for how long the system was in sleep or power-down mode.
345*a8f7f3fcSMatthias Ringwald void osKernelResume (uint32_t sleep_ticks);
346*a8f7f3fcSMatthias Ringwald 
347*a8f7f3fcSMatthias Ringwald /// Get the RTOS kernel tick count.
348*a8f7f3fcSMatthias Ringwald /// \return RTOS kernel current tick count.
349*a8f7f3fcSMatthias Ringwald uint32_t osKernelGetTickCount (void);
350*a8f7f3fcSMatthias Ringwald 
351*a8f7f3fcSMatthias Ringwald /// Get the RTOS kernel tick frequency.
352*a8f7f3fcSMatthias Ringwald /// \return frequency of the kernel tick in hertz, i.e. kernel ticks per second.
353*a8f7f3fcSMatthias Ringwald uint32_t osKernelGetTickFreq (void);
354*a8f7f3fcSMatthias Ringwald 
355*a8f7f3fcSMatthias Ringwald /// Get the RTOS kernel system timer count.
356*a8f7f3fcSMatthias Ringwald /// \return RTOS kernel current system timer count as 32-bit value.
357*a8f7f3fcSMatthias Ringwald uint32_t osKernelGetSysTimerCount (void);
358*a8f7f3fcSMatthias Ringwald 
359*a8f7f3fcSMatthias Ringwald /// Get the RTOS kernel system timer frequency.
360*a8f7f3fcSMatthias Ringwald /// \return frequency of the system timer in hertz, i.e. timer ticks per second.
361*a8f7f3fcSMatthias Ringwald uint32_t osKernelGetSysTimerFreq (void);
362*a8f7f3fcSMatthias Ringwald 
363*a8f7f3fcSMatthias Ringwald 
364*a8f7f3fcSMatthias Ringwald //  ==== Thread Management Functions ====
365*a8f7f3fcSMatthias Ringwald 
366*a8f7f3fcSMatthias Ringwald /// Create a thread and add it to Active Threads.
367*a8f7f3fcSMatthias Ringwald /// \param[in]     func          thread function.
368*a8f7f3fcSMatthias Ringwald /// \param[in]     argument      pointer that is passed to the thread function as start argument.
369*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          thread attributes; NULL: default values.
370*a8f7f3fcSMatthias Ringwald /// \return thread ID for reference by other functions or NULL in case of error.
371*a8f7f3fcSMatthias Ringwald osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
372*a8f7f3fcSMatthias Ringwald 
373*a8f7f3fcSMatthias Ringwald /// Get name of a thread.
374*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
375*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
376*a8f7f3fcSMatthias Ringwald const char *osThreadGetName (osThreadId_t thread_id);
377*a8f7f3fcSMatthias Ringwald 
378*a8f7f3fcSMatthias Ringwald /// Return the thread ID of the current running thread.
379*a8f7f3fcSMatthias Ringwald /// \return thread ID for reference by other functions or NULL in case of error.
380*a8f7f3fcSMatthias Ringwald osThreadId_t osThreadGetId (void);
381*a8f7f3fcSMatthias Ringwald 
382*a8f7f3fcSMatthias Ringwald /// Get current thread state of a thread.
383*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
384*a8f7f3fcSMatthias Ringwald /// \return current thread state of the specified thread.
385*a8f7f3fcSMatthias Ringwald osThreadState_t osThreadGetState (osThreadId_t thread_id);
386*a8f7f3fcSMatthias Ringwald 
387*a8f7f3fcSMatthias Ringwald /// Get stack size of a thread.
388*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
389*a8f7f3fcSMatthias Ringwald /// \return stack size in bytes.
390*a8f7f3fcSMatthias Ringwald uint32_t osThreadGetStackSize (osThreadId_t thread_id);
391*a8f7f3fcSMatthias Ringwald 
392*a8f7f3fcSMatthias Ringwald /// Get available stack space of a thread based on stack watermark recording during execution.
393*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
394*a8f7f3fcSMatthias Ringwald /// \return remaining stack space in bytes.
395*a8f7f3fcSMatthias Ringwald uint32_t osThreadGetStackSpace (osThreadId_t thread_id);
396*a8f7f3fcSMatthias Ringwald 
397*a8f7f3fcSMatthias Ringwald /// Change priority of a thread.
398*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
399*a8f7f3fcSMatthias Ringwald /// \param[in]     priority      new priority value for the thread function.
400*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
401*a8f7f3fcSMatthias Ringwald osStatus_t osThreadSetPriority (osThreadId_t thread_id, osPriority_t priority);
402*a8f7f3fcSMatthias Ringwald 
403*a8f7f3fcSMatthias Ringwald /// Get current priority of a thread.
404*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
405*a8f7f3fcSMatthias Ringwald /// \return current priority value of the specified thread.
406*a8f7f3fcSMatthias Ringwald osPriority_t osThreadGetPriority (osThreadId_t thread_id);
407*a8f7f3fcSMatthias Ringwald 
408*a8f7f3fcSMatthias Ringwald /// Pass control to next thread that is in state \b READY.
409*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
410*a8f7f3fcSMatthias Ringwald osStatus_t osThreadYield (void);
411*a8f7f3fcSMatthias Ringwald 
412*a8f7f3fcSMatthias Ringwald /// Suspend execution of a thread.
413*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
414*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
415*a8f7f3fcSMatthias Ringwald osStatus_t osThreadSuspend (osThreadId_t thread_id);
416*a8f7f3fcSMatthias Ringwald 
417*a8f7f3fcSMatthias Ringwald /// Resume execution of a thread.
418*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
419*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
420*a8f7f3fcSMatthias Ringwald osStatus_t osThreadResume (osThreadId_t thread_id);
421*a8f7f3fcSMatthias Ringwald 
422*a8f7f3fcSMatthias Ringwald /// Detach a thread (thread storage can be reclaimed when thread terminates).
423*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
424*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
425*a8f7f3fcSMatthias Ringwald osStatus_t osThreadDetach (osThreadId_t thread_id);
426*a8f7f3fcSMatthias Ringwald 
427*a8f7f3fcSMatthias Ringwald /// Wait for specified thread to terminate.
428*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
429*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
430*a8f7f3fcSMatthias Ringwald osStatus_t osThreadJoin (osThreadId_t thread_id);
431*a8f7f3fcSMatthias Ringwald 
432*a8f7f3fcSMatthias Ringwald /// Terminate execution of current running thread.
433*a8f7f3fcSMatthias Ringwald __NO_RETURN void osThreadExit (void);
434*a8f7f3fcSMatthias Ringwald 
435*a8f7f3fcSMatthias Ringwald /// Terminate execution of a thread.
436*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
437*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
438*a8f7f3fcSMatthias Ringwald osStatus_t osThreadTerminate (osThreadId_t thread_id);
439*a8f7f3fcSMatthias Ringwald 
440*a8f7f3fcSMatthias Ringwald /// Get number of active threads.
441*a8f7f3fcSMatthias Ringwald /// \return number of active threads.
442*a8f7f3fcSMatthias Ringwald uint32_t osThreadGetCount (void);
443*a8f7f3fcSMatthias Ringwald 
444*a8f7f3fcSMatthias Ringwald /// Enumerate active threads.
445*a8f7f3fcSMatthias Ringwald /// \param[out]    thread_array  pointer to array for retrieving thread IDs.
446*a8f7f3fcSMatthias Ringwald /// \param[in]     array_items   maximum number of items in array for retrieving thread IDs.
447*a8f7f3fcSMatthias Ringwald /// \return number of enumerated threads.
448*a8f7f3fcSMatthias Ringwald uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items);
449*a8f7f3fcSMatthias Ringwald 
450*a8f7f3fcSMatthias Ringwald 
451*a8f7f3fcSMatthias Ringwald //  ==== Thread Flags Functions ====
452*a8f7f3fcSMatthias Ringwald 
453*a8f7f3fcSMatthias Ringwald /// Set the specified Thread Flags of a thread.
454*a8f7f3fcSMatthias Ringwald /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
455*a8f7f3fcSMatthias Ringwald /// \param[in]     flags         specifies the flags of the thread that shall be set.
456*a8f7f3fcSMatthias Ringwald /// \return thread flags after setting or error code if highest bit set.
457*a8f7f3fcSMatthias Ringwald uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags);
458*a8f7f3fcSMatthias Ringwald 
459*a8f7f3fcSMatthias Ringwald /// Clear the specified Thread Flags of current running thread.
460*a8f7f3fcSMatthias Ringwald /// \param[in]     flags         specifies the flags of the thread that shall be cleared.
461*a8f7f3fcSMatthias Ringwald /// \return thread flags before clearing or error code if highest bit set.
462*a8f7f3fcSMatthias Ringwald uint32_t osThreadFlagsClear (uint32_t flags);
463*a8f7f3fcSMatthias Ringwald 
464*a8f7f3fcSMatthias Ringwald /// Get the current Thread Flags of current running thread.
465*a8f7f3fcSMatthias Ringwald /// \return current thread flags.
466*a8f7f3fcSMatthias Ringwald uint32_t osThreadFlagsGet (void);
467*a8f7f3fcSMatthias Ringwald 
468*a8f7f3fcSMatthias Ringwald /// Wait for one or more Thread Flags of the current running thread to become signaled.
469*a8f7f3fcSMatthias Ringwald /// \param[in]     flags         specifies the flags to wait for.
470*a8f7f3fcSMatthias Ringwald /// \param[in]     options       specifies flags options (osFlagsXxxx).
471*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
472*a8f7f3fcSMatthias Ringwald /// \return thread flags before clearing or error code if highest bit set.
473*a8f7f3fcSMatthias Ringwald uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);
474*a8f7f3fcSMatthias Ringwald 
475*a8f7f3fcSMatthias Ringwald 
476*a8f7f3fcSMatthias Ringwald //  ==== Generic Wait Functions ====
477*a8f7f3fcSMatthias Ringwald 
478*a8f7f3fcSMatthias Ringwald /// Wait for Timeout (Time Delay).
479*a8f7f3fcSMatthias Ringwald /// \param[in]     ticks         \ref CMSIS_RTOS_TimeOutValue "time ticks" value
480*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
481*a8f7f3fcSMatthias Ringwald osStatus_t osDelay (uint32_t ticks);
482*a8f7f3fcSMatthias Ringwald 
483*a8f7f3fcSMatthias Ringwald /// Wait until specified time.
484*a8f7f3fcSMatthias Ringwald /// \param[in]     ticks         absolute time in ticks
485*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
486*a8f7f3fcSMatthias Ringwald osStatus_t osDelayUntil (uint32_t ticks);
487*a8f7f3fcSMatthias Ringwald 
488*a8f7f3fcSMatthias Ringwald 
489*a8f7f3fcSMatthias Ringwald //  ==== Timer Management Functions ====
490*a8f7f3fcSMatthias Ringwald 
491*a8f7f3fcSMatthias Ringwald /// Create and Initialize a timer.
492*a8f7f3fcSMatthias Ringwald /// \param[in]     func          function pointer to callback function.
493*a8f7f3fcSMatthias Ringwald /// \param[in]     type          \ref osTimerOnce for one-shot or \ref osTimerPeriodic for periodic behavior.
494*a8f7f3fcSMatthias Ringwald /// \param[in]     argument      argument to the timer callback function.
495*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          timer attributes; NULL: default values.
496*a8f7f3fcSMatthias Ringwald /// \return timer ID for reference by other functions or NULL in case of error.
497*a8f7f3fcSMatthias Ringwald osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
498*a8f7f3fcSMatthias Ringwald 
499*a8f7f3fcSMatthias Ringwald /// Get name of a timer.
500*a8f7f3fcSMatthias Ringwald /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
501*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
502*a8f7f3fcSMatthias Ringwald const char *osTimerGetName (osTimerId_t timer_id);
503*a8f7f3fcSMatthias Ringwald 
504*a8f7f3fcSMatthias Ringwald /// Start or restart a timer.
505*a8f7f3fcSMatthias Ringwald /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
506*a8f7f3fcSMatthias Ringwald /// \param[in]     ticks         \ref CMSIS_RTOS_TimeOutValue "time ticks" value of the timer.
507*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
508*a8f7f3fcSMatthias Ringwald osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks);
509*a8f7f3fcSMatthias Ringwald 
510*a8f7f3fcSMatthias Ringwald /// Stop a timer.
511*a8f7f3fcSMatthias Ringwald /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
512*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
513*a8f7f3fcSMatthias Ringwald osStatus_t osTimerStop (osTimerId_t timer_id);
514*a8f7f3fcSMatthias Ringwald 
515*a8f7f3fcSMatthias Ringwald /// Check if a timer is running.
516*a8f7f3fcSMatthias Ringwald /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
517*a8f7f3fcSMatthias Ringwald /// \return 0 not running, 1 running.
518*a8f7f3fcSMatthias Ringwald uint32_t osTimerIsRunning (osTimerId_t timer_id);
519*a8f7f3fcSMatthias Ringwald 
520*a8f7f3fcSMatthias Ringwald /// Delete a timer.
521*a8f7f3fcSMatthias Ringwald /// \param[in]     timer_id      timer ID obtained by \ref osTimerNew.
522*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
523*a8f7f3fcSMatthias Ringwald osStatus_t osTimerDelete (osTimerId_t timer_id);
524*a8f7f3fcSMatthias Ringwald 
525*a8f7f3fcSMatthias Ringwald 
526*a8f7f3fcSMatthias Ringwald //  ==== Event Flags Management Functions ====
527*a8f7f3fcSMatthias Ringwald 
528*a8f7f3fcSMatthias Ringwald /// Create and Initialize an Event Flags object.
529*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          event flags attributes; NULL: default values.
530*a8f7f3fcSMatthias Ringwald /// \return event flags ID for reference by other functions or NULL in case of error.
531*a8f7f3fcSMatthias Ringwald osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr);
532*a8f7f3fcSMatthias Ringwald 
533*a8f7f3fcSMatthias Ringwald /// Get name of an Event Flags object.
534*a8f7f3fcSMatthias Ringwald /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
535*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
536*a8f7f3fcSMatthias Ringwald const char *osEventFlagsGetName (osEventFlagsId_t ef_id);
537*a8f7f3fcSMatthias Ringwald 
538*a8f7f3fcSMatthias Ringwald /// Set the specified Event Flags.
539*a8f7f3fcSMatthias Ringwald /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
540*a8f7f3fcSMatthias Ringwald /// \param[in]     flags         specifies the flags that shall be set.
541*a8f7f3fcSMatthias Ringwald /// \return event flags after setting or error code if highest bit set.
542*a8f7f3fcSMatthias Ringwald uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags);
543*a8f7f3fcSMatthias Ringwald 
544*a8f7f3fcSMatthias Ringwald /// Clear the specified Event Flags.
545*a8f7f3fcSMatthias Ringwald /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
546*a8f7f3fcSMatthias Ringwald /// \param[in]     flags         specifies the flags that shall be cleared.
547*a8f7f3fcSMatthias Ringwald /// \return event flags before clearing or error code if highest bit set.
548*a8f7f3fcSMatthias Ringwald uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags);
549*a8f7f3fcSMatthias Ringwald 
550*a8f7f3fcSMatthias Ringwald /// Get the current Event Flags.
551*a8f7f3fcSMatthias Ringwald /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
552*a8f7f3fcSMatthias Ringwald /// \return current event flags.
553*a8f7f3fcSMatthias Ringwald uint32_t osEventFlagsGet (osEventFlagsId_t ef_id);
554*a8f7f3fcSMatthias Ringwald 
555*a8f7f3fcSMatthias Ringwald /// Wait for one or more Event Flags to become signaled.
556*a8f7f3fcSMatthias Ringwald /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
557*a8f7f3fcSMatthias Ringwald /// \param[in]     flags         specifies the flags to wait for.
558*a8f7f3fcSMatthias Ringwald /// \param[in]     options       specifies flags options (osFlagsXxxx).
559*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
560*a8f7f3fcSMatthias Ringwald /// \return event flags before clearing or error code if highest bit set.
561*a8f7f3fcSMatthias Ringwald uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
562*a8f7f3fcSMatthias Ringwald 
563*a8f7f3fcSMatthias Ringwald /// Delete an Event Flags object.
564*a8f7f3fcSMatthias Ringwald /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
565*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
566*a8f7f3fcSMatthias Ringwald osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id);
567*a8f7f3fcSMatthias Ringwald 
568*a8f7f3fcSMatthias Ringwald 
569*a8f7f3fcSMatthias Ringwald //  ==== Mutex Management Functions ====
570*a8f7f3fcSMatthias Ringwald 
571*a8f7f3fcSMatthias Ringwald /// Create and Initialize a Mutex object.
572*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          mutex attributes; NULL: default values.
573*a8f7f3fcSMatthias Ringwald /// \return mutex ID for reference by other functions or NULL in case of error.
574*a8f7f3fcSMatthias Ringwald osMutexId_t osMutexNew (const osMutexAttr_t *attr);
575*a8f7f3fcSMatthias Ringwald 
576*a8f7f3fcSMatthias Ringwald /// Get name of a Mutex object.
577*a8f7f3fcSMatthias Ringwald /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
578*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
579*a8f7f3fcSMatthias Ringwald const char *osMutexGetName (osMutexId_t mutex_id);
580*a8f7f3fcSMatthias Ringwald 
581*a8f7f3fcSMatthias Ringwald /// Acquire a Mutex or timeout if it is locked.
582*a8f7f3fcSMatthias Ringwald /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
583*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
584*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
585*a8f7f3fcSMatthias Ringwald osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout);
586*a8f7f3fcSMatthias Ringwald 
587*a8f7f3fcSMatthias Ringwald /// Release a Mutex that was acquired by \ref osMutexAcquire.
588*a8f7f3fcSMatthias Ringwald /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
589*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
590*a8f7f3fcSMatthias Ringwald osStatus_t osMutexRelease (osMutexId_t mutex_id);
591*a8f7f3fcSMatthias Ringwald 
592*a8f7f3fcSMatthias Ringwald /// Get Thread which owns a Mutex object.
593*a8f7f3fcSMatthias Ringwald /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
594*a8f7f3fcSMatthias Ringwald /// \return thread ID of owner thread or NULL when mutex was not acquired.
595*a8f7f3fcSMatthias Ringwald osThreadId_t osMutexGetOwner (osMutexId_t mutex_id);
596*a8f7f3fcSMatthias Ringwald 
597*a8f7f3fcSMatthias Ringwald /// Delete a Mutex object.
598*a8f7f3fcSMatthias Ringwald /// \param[in]     mutex_id      mutex ID obtained by \ref osMutexNew.
599*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
600*a8f7f3fcSMatthias Ringwald osStatus_t osMutexDelete (osMutexId_t mutex_id);
601*a8f7f3fcSMatthias Ringwald 
602*a8f7f3fcSMatthias Ringwald 
603*a8f7f3fcSMatthias Ringwald //  ==== Semaphore Management Functions ====
604*a8f7f3fcSMatthias Ringwald 
605*a8f7f3fcSMatthias Ringwald /// Create and Initialize a Semaphore object.
606*a8f7f3fcSMatthias Ringwald /// \param[in]     max_count     maximum number of available tokens.
607*a8f7f3fcSMatthias Ringwald /// \param[in]     initial_count initial number of available tokens.
608*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          semaphore attributes; NULL: default values.
609*a8f7f3fcSMatthias Ringwald /// \return semaphore ID for reference by other functions or NULL in case of error.
610*a8f7f3fcSMatthias Ringwald osSemaphoreId_t osSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr);
611*a8f7f3fcSMatthias Ringwald 
612*a8f7f3fcSMatthias Ringwald /// Get name of a Semaphore object.
613*a8f7f3fcSMatthias Ringwald /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
614*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
615*a8f7f3fcSMatthias Ringwald const char *osSemaphoreGetName (osSemaphoreId_t semaphore_id);
616*a8f7f3fcSMatthias Ringwald 
617*a8f7f3fcSMatthias Ringwald /// Acquire a Semaphore token or timeout if no tokens are available.
618*a8f7f3fcSMatthias Ringwald /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
619*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
620*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
621*a8f7f3fcSMatthias Ringwald osStatus_t osSemaphoreAcquire (osSemaphoreId_t semaphore_id, uint32_t timeout);
622*a8f7f3fcSMatthias Ringwald 
623*a8f7f3fcSMatthias Ringwald /// Release a Semaphore token up to the initial maximum count.
624*a8f7f3fcSMatthias Ringwald /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
625*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
626*a8f7f3fcSMatthias Ringwald osStatus_t osSemaphoreRelease (osSemaphoreId_t semaphore_id);
627*a8f7f3fcSMatthias Ringwald 
628*a8f7f3fcSMatthias Ringwald /// Get current Semaphore token count.
629*a8f7f3fcSMatthias Ringwald /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
630*a8f7f3fcSMatthias Ringwald /// \return number of tokens available.
631*a8f7f3fcSMatthias Ringwald uint32_t osSemaphoreGetCount (osSemaphoreId_t semaphore_id);
632*a8f7f3fcSMatthias Ringwald 
633*a8f7f3fcSMatthias Ringwald /// Delete a Semaphore object.
634*a8f7f3fcSMatthias Ringwald /// \param[in]     semaphore_id  semaphore ID obtained by \ref osSemaphoreNew.
635*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
636*a8f7f3fcSMatthias Ringwald osStatus_t osSemaphoreDelete (osSemaphoreId_t semaphore_id);
637*a8f7f3fcSMatthias Ringwald 
638*a8f7f3fcSMatthias Ringwald 
639*a8f7f3fcSMatthias Ringwald //  ==== Memory Pool Management Functions ====
640*a8f7f3fcSMatthias Ringwald 
641*a8f7f3fcSMatthias Ringwald /// Create and Initialize a Memory Pool object.
642*a8f7f3fcSMatthias Ringwald /// \param[in]     block_count   maximum number of memory blocks in memory pool.
643*a8f7f3fcSMatthias Ringwald /// \param[in]     block_size    memory block size in bytes.
644*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          memory pool attributes; NULL: default values.
645*a8f7f3fcSMatthias Ringwald /// \return memory pool ID for reference by other functions or NULL in case of error.
646*a8f7f3fcSMatthias Ringwald osMemoryPoolId_t osMemoryPoolNew (uint32_t block_count, uint32_t block_size, const osMemoryPoolAttr_t *attr);
647*a8f7f3fcSMatthias Ringwald 
648*a8f7f3fcSMatthias Ringwald /// Get name of a Memory Pool object.
649*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
650*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
651*a8f7f3fcSMatthias Ringwald const char *osMemoryPoolGetName (osMemoryPoolId_t mp_id);
652*a8f7f3fcSMatthias Ringwald 
653*a8f7f3fcSMatthias Ringwald /// Allocate a memory block from a Memory Pool.
654*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
655*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
656*a8f7f3fcSMatthias Ringwald /// \return address of the allocated memory block or NULL in case of no memory is available.
657*a8f7f3fcSMatthias Ringwald void *osMemoryPoolAlloc (osMemoryPoolId_t mp_id, uint32_t timeout);
658*a8f7f3fcSMatthias Ringwald 
659*a8f7f3fcSMatthias Ringwald /// Return an allocated memory block back to a Memory Pool.
660*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
661*a8f7f3fcSMatthias Ringwald /// \param[in]     block         address of the allocated memory block to be returned to the memory pool.
662*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
663*a8f7f3fcSMatthias Ringwald osStatus_t osMemoryPoolFree (osMemoryPoolId_t mp_id, void *block);
664*a8f7f3fcSMatthias Ringwald 
665*a8f7f3fcSMatthias Ringwald /// Get maximum number of memory blocks in a Memory Pool.
666*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
667*a8f7f3fcSMatthias Ringwald /// \return maximum number of memory blocks.
668*a8f7f3fcSMatthias Ringwald uint32_t osMemoryPoolGetCapacity (osMemoryPoolId_t mp_id);
669*a8f7f3fcSMatthias Ringwald 
670*a8f7f3fcSMatthias Ringwald /// Get memory block size in a Memory Pool.
671*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
672*a8f7f3fcSMatthias Ringwald /// \return memory block size in bytes.
673*a8f7f3fcSMatthias Ringwald uint32_t osMemoryPoolGetBlockSize (osMemoryPoolId_t mp_id);
674*a8f7f3fcSMatthias Ringwald 
675*a8f7f3fcSMatthias Ringwald /// Get number of memory blocks used in a Memory Pool.
676*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
677*a8f7f3fcSMatthias Ringwald /// \return number of memory blocks used.
678*a8f7f3fcSMatthias Ringwald uint32_t osMemoryPoolGetCount (osMemoryPoolId_t mp_id);
679*a8f7f3fcSMatthias Ringwald 
680*a8f7f3fcSMatthias Ringwald /// Get number of memory blocks available in a Memory Pool.
681*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
682*a8f7f3fcSMatthias Ringwald /// \return number of memory blocks available.
683*a8f7f3fcSMatthias Ringwald uint32_t osMemoryPoolGetSpace (osMemoryPoolId_t mp_id);
684*a8f7f3fcSMatthias Ringwald 
685*a8f7f3fcSMatthias Ringwald /// Delete a Memory Pool object.
686*a8f7f3fcSMatthias Ringwald /// \param[in]     mp_id         memory pool ID obtained by \ref osMemoryPoolNew.
687*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
688*a8f7f3fcSMatthias Ringwald osStatus_t osMemoryPoolDelete (osMemoryPoolId_t mp_id);
689*a8f7f3fcSMatthias Ringwald 
690*a8f7f3fcSMatthias Ringwald 
691*a8f7f3fcSMatthias Ringwald //  ==== Message Queue Management Functions ====
692*a8f7f3fcSMatthias Ringwald 
693*a8f7f3fcSMatthias Ringwald /// Create and Initialize a Message Queue object.
694*a8f7f3fcSMatthias Ringwald /// \param[in]     msg_count     maximum number of messages in queue.
695*a8f7f3fcSMatthias Ringwald /// \param[in]     msg_size      maximum message size in bytes.
696*a8f7f3fcSMatthias Ringwald /// \param[in]     attr          message queue attributes; NULL: default values.
697*a8f7f3fcSMatthias Ringwald /// \return message queue ID for reference by other functions or NULL in case of error.
698*a8f7f3fcSMatthias Ringwald osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr);
699*a8f7f3fcSMatthias Ringwald 
700*a8f7f3fcSMatthias Ringwald /// Get name of a Message Queue object.
701*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
702*a8f7f3fcSMatthias Ringwald /// \return name as null-terminated string.
703*a8f7f3fcSMatthias Ringwald const char *osMessageQueueGetName (osMessageQueueId_t mq_id);
704*a8f7f3fcSMatthias Ringwald 
705*a8f7f3fcSMatthias Ringwald /// Put a Message into a Queue or timeout if Queue is full.
706*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
707*a8f7f3fcSMatthias Ringwald /// \param[in]     msg_ptr       pointer to buffer with message to put into a queue.
708*a8f7f3fcSMatthias Ringwald /// \param[in]     msg_prio      message priority.
709*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
710*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
711*a8f7f3fcSMatthias Ringwald osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout);
712*a8f7f3fcSMatthias Ringwald 
713*a8f7f3fcSMatthias Ringwald /// Get a Message from a Queue or timeout if Queue is empty.
714*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
715*a8f7f3fcSMatthias Ringwald /// \param[out]    msg_ptr       pointer to buffer for message to get from a queue.
716*a8f7f3fcSMatthias Ringwald /// \param[out]    msg_prio      pointer to buffer for message priority or NULL.
717*a8f7f3fcSMatthias Ringwald /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
718*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
719*a8f7f3fcSMatthias Ringwald osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout);
720*a8f7f3fcSMatthias Ringwald 
721*a8f7f3fcSMatthias Ringwald /// Get maximum number of messages in a Message Queue.
722*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
723*a8f7f3fcSMatthias Ringwald /// \return maximum number of messages.
724*a8f7f3fcSMatthias Ringwald uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id);
725*a8f7f3fcSMatthias Ringwald 
726*a8f7f3fcSMatthias Ringwald /// Get maximum message size in a Memory Pool.
727*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
728*a8f7f3fcSMatthias Ringwald /// \return maximum message size in bytes.
729*a8f7f3fcSMatthias Ringwald uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id);
730*a8f7f3fcSMatthias Ringwald 
731*a8f7f3fcSMatthias Ringwald /// Get number of queued messages in a Message Queue.
732*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
733*a8f7f3fcSMatthias Ringwald /// \return number of queued messages.
734*a8f7f3fcSMatthias Ringwald uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id);
735*a8f7f3fcSMatthias Ringwald 
736*a8f7f3fcSMatthias Ringwald /// Get number of available slots for messages in a Message Queue.
737*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
738*a8f7f3fcSMatthias Ringwald /// \return number of available slots for messages.
739*a8f7f3fcSMatthias Ringwald uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id);
740*a8f7f3fcSMatthias Ringwald 
741*a8f7f3fcSMatthias Ringwald /// Reset a Message Queue to initial empty state.
742*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
743*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
744*a8f7f3fcSMatthias Ringwald osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id);
745*a8f7f3fcSMatthias Ringwald 
746*a8f7f3fcSMatthias Ringwald /// Delete a Message Queue object.
747*a8f7f3fcSMatthias Ringwald /// \param[in]     mq_id         message queue ID obtained by \ref osMessageQueueNew.
748*a8f7f3fcSMatthias Ringwald /// \return status code that indicates the execution status of the function.
749*a8f7f3fcSMatthias Ringwald osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id);
750*a8f7f3fcSMatthias Ringwald 
751*a8f7f3fcSMatthias Ringwald 
752*a8f7f3fcSMatthias Ringwald #ifdef  __cplusplus
753*a8f7f3fcSMatthias Ringwald }
754*a8f7f3fcSMatthias Ringwald #endif
755*a8f7f3fcSMatthias Ringwald 
756*a8f7f3fcSMatthias Ringwald #endif  // CMSIS_OS2_H_
757