µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
cmsis_os.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------
2 * $Date: 5. February 2013
3 * $Revision: V1.02
4 *
5 * Project: CMSIS-RTOS API
6 * Title: cmsis_os.h template header file
7 *
8 * Version 0.02
9 * Initial Proposal Phase
10 * Version 0.03
11 * osKernelStart added, optional feature: main started as thread
12 * osSemaphores have standard behaviour
13 * osTimerCreate does not start the timer, added osTimerStart
14 * osThreadPass is renamed to osThreadYield
15 * Version 1.01
16 * Support for C++ interface
17 * - const attribute removed from the osXxxxDef_t typedef's
18 * - const attribute added to the osXxxxDef macros
19 * Added: osTimerDelete, osMutexDelete, osSemaphoreDelete
20 * Added: osKernelInitialize
21 * Version 1.02
22 * Control functions for short timeouts in microsecond resolution:
23 * Added: osKernelSysTick, osKernelSysTickFrequency, osKernelSysTickMicroSec
24 * Removed: osSignalGet
25 *----------------------------------------------------------------------------
26 *
27 * Copyright (c) 2013 ARM LIMITED
28 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions are met:
31 * - Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * - Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * - Neither the name of ARM nor the names of its contributors may be used
37 * to endorse or promote products derived from this software without
38 * specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
41 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
44 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
46 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
47 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50 * POSSIBILITY OF SUCH DAMAGE.
51 *---------------------------------------------------------------------------*/
52
53/*
54 * This file is part of the µOS++ distribution.
55 * (https://github.com/micro-os-plus)
56 * Copyright (c) 2016-2023 Liviu Ionescu. All rights reserved.
57 *
58 * Permission to use, copy, modify, and/or distribute this software
59 * for any purpose is hereby granted, under the terms of the MIT license.
60 *
61 * If a copy of the license was not distributed with this file, it can
62 * be obtained from https://opensource.org/licenses/mit/.
63 */
64
65/*
66 * The code exposes a fully compliant ARM CMSIS API in the
67 * context of the µOS++.
68 */
69
70/*
71 * Calls from Interrupt Service Routines
72 *
73 * The following CMSIS-RTOS functions can be called both from threads and
74 * Interrupt Service Routines (ISR):
75 *
76 * - osKernelRunning
77 * - osSignalSet
78 * - osSemaphoreRelease
79 * - osPoolAlloc, osPoolCAlloc, osPoolFree
80 * - osMessagePut, osMessageGet
81 * - osMailAlloc, osMailCAlloc, osMailGet, osMailPut, osMailFree
82 */
83
84#ifndef CMSIS_OS_H_
85#define CMSIS_OS_H_
86
87#pragma GCC diagnostic push
88#if defined(__clang__)
89#pragma clang diagnostic ignored "-Wpadded"
90#elif defined(__GNUC__)
91#if !defined(__cplusplus)
92#pragma GCC diagnostic ignored "-Wc++-compat"
93#endif
94#pragma GCC diagnostic ignored "-Wpadded"
95#endif
96
98#define osCMSIS 0x00010002
99
101#define osCMSIS_KERNEL 0x00010000
102
104#define osKernelSystemId "µOS++"
105
107#define osFeature_MainThread 0
108#define osFeature_Pool 1
109#define osFeature_MailQ 1
110#define osFeature_MessageQ 1
111#define osFeature_Signals 8
112#define osFeature_Semaphore 30
113#define osFeature_Wait 1
114#define osFeature_SysTick 1
115
116// Include the µOS++ C API structures declarations.
118
119#include <stdint.h>
120#include <stddef.h>
121
122#ifdef __cplusplus
123extern "C"
124{
125#endif
126
127// ==== Enumeration, structures, defines ====
128
131 typedef enum
132 {
142
147#define osWaitForever 0xFFFFFFFF
148
153 typedef enum
154 {
155 osOK = 0,
158 osEventMail = 0x20,
163 osErrorISR = 0x82,
168 osErrorOS = 0xFF,
169 os_status_reserved = 0x7FFFFFFF
171
176 typedef enum
177 {
181
186 typedef void
187 (*os_pthread) (void const *argument);
188
193 typedef void
194 (*os_ptimer) (void const *argument);
195
196 // Redefine some µOS++ struct's to the legacy code.
199
202
205
208
211
214
215 typedef struct os_mail_queue_s
216 {
220
222
228
234
240
246
251 typedef osPool* osPoolId;
252
258
264
265#pragma GCC diagnostic push
266#if defined(__clang__)
267#pragma clang diagnostic ignored "-Wpadded"
268#elif defined(__GNUC__)
269#pragma GCC diagnostic ignored "-Wpadded"
270#endif
271
276 typedef struct os_thread_def
277 {
278 const char* name;
281 uint32_t instances;
282 uint32_t stacksize;
284 uint64_t* stack; // align the stack at 8 bytes
286
287#pragma GCC diagnostic pop
288
293 typedef struct os_timer_def
294 {
295 const char* name;
299
304 typedef struct os_mutex_def
305 {
306 const char* name;
309
314 typedef struct os_semaphore_def
315 {
316 const char* name;
319
320#pragma GCC diagnostic push
321#if defined(__clang__)
322#pragma clang diagnostic ignored "-Wpadded"
323#elif defined(__GNUC__)
324#pragma GCC diagnostic ignored "-Wpadded"
325#endif
326
331 typedef struct os_pool_def
332 {
333 const char* name;
334 uint32_t items;
335 uint32_t item_sz;
336 void* pool;
337 uint32_t pool_sz;
340
345 typedef struct os_messageQ_def
346 {
347 const char* name;
348 uint32_t items;
349 uint32_t item_sz;
350 void* queue;
351 uint32_t queue_sz;
354
359 typedef struct os_mailQ_def
360 {
361 const char* name;
362 uint32_t items;
363 uint32_t pool_item_sz;
364 uint32_t queue_item_sz;
365 void* pool;
366 uint32_t pool_sz;
367 void* queue;
368 uint32_t queue_sz;
371
377 typedef struct
378 {
380 union
381 {
382 uint32_t v;
383 void* p;
384 int32_t signals;
385 } value;
386 union
387 {
390 } def;
391 } osEvent;
392
393#pragma GCC diagnostic pop
394
395// ==== Kernel Control Functions ====
396
405 osKernelInitialize (void);
406
415 osKernelStart (void);
416
422 int32_t
423 osKernelRunning (void);
424
425#if (defined (osFeature_SysTick) && (osFeature_SysTick != 0)) // System Timer available
426
433 uint32_t
435
447#define osKernelSysTickFrequency (OS_INTEGER_SYSTICK_FREQUENCY_HZ)
448
460#define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000)
461
462#endif // System Timer available
463
464// ==== Thread Management ====
465
481#if defined (osObjectsExternal) // object is external
482#define osThreadDef(name, priority, instances, stacksz) \
483extern const osThreadDef_t os_thread_def_##name
484#else // define the object
485#define osThreadAllocatedDef(name, priority, instances, stacksz) \
486struct { \
487 osThread data[instances]; \
488} os_thread_##name; \
489const osThreadDef_t os_thread_def_##name = \
490{ \
491 #name, \
492 (os_pthread)(name), \
493 (priority), \
494 (instances), \
495 (stacksz), \
496 &os_thread_##name.data[0], \
497 0 \
498}
499#define osThreadStaticDef(name, priority, instances, stacksz) \
500struct { \
501 uint64_t stack[(instances)*((stacksz+sizeof(uint64_t)-1)/sizeof(uint64_t))]; \
502 osThread data[instances]; \
503} os_thread_##name; \
504const osThreadDef_t os_thread_def_##name = \
505{ \
506 #name, \
507 (os_pthread)(name), \
508 (priority), \
509 (instances), \
510 (stacksz), \
511 &os_thread_##name.data[0], \
512 &os_thread_##name.stack[0] \
513}
514#if defined(osObjectsStatic)
515#define osThreadDef(name, priority, instances, stacksz) osThreadStaticDef(name, priority, instances, stacksz)
516#else
517#define osThreadDef(name, priority, instances, stacksz) osThreadAllocatedDef(name, priority, instances, stacksz)
518#endif
519#endif
520
531#define osThread(name) \
532&os_thread_def_##name
533
544 osThreadCreate (const osThreadDef_t* thread_def, void* args);
545
554 osThreadGetId (void);
555
568 osThreadTerminate (osThreadId thread_id);
569
579 osThreadYield (void);
580
595 osThreadSetPriority (osThreadId thread_id, osPriority priority);
596
607
608// ==== Generic Wait Functions ====
609
617 osDelay (uint32_t millisec);
618
619#if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available
620
632 osEvent
633 osWait (uint32_t millisec);
634
635#endif // Generic Wait available
636
637// ==== Timer Management Functions ====
638
650#if defined (osObjectsExternal) // object is external
651#define osTimerDef(name, function) \
652extern const osTimerDef_t os_timer_def_##name
653#else // define the object
654#define osTimerDef(name, function) \
655struct { \
656 osTimer data; \
657} os_timer_##name; \
658const osTimerDef_t os_timer_def_##name = \
659{ \
660 #name, \
661 (os_ptimer)(function), \
662 &os_timer_##name.data \
663}
664#endif
665
676#define osTimer(name) \
677&os_timer_def_##name
678
689 osTimerCreate (const osTimerDef_t* timer_def, os_timer_type type, void* args);
690
702 osTimerStart (osTimerId timer_id, uint32_t millisec);
703
715 osTimerStop (osTimerId timer_id);
716
727 osTimerDelete (osTimerId timer_id);
728
729// ==== Signal Management ====
730
739 int32_t
740 osSignalSet (osThreadId thread_id, int32_t signals);
741
750 int32_t
751 osSignalClear (osThreadId thread_id, int32_t signals);
752
765 osEvent
766 osSignalWait (int32_t signals, uint32_t millisec);
767
768// ==== Mutex Management ====
769
780#if defined (osObjectsExternal) // object is external
781#define osMutexDef(name) \
782extern const osMutexDef_t os_mutex_def_##name
783#else // define the object
784#define osMutexDef(name) \
785osMutex os_mutex_data_##name; \
786const osMutexDef_t os_mutex_def_##name = \
787{ \
788 #name, \
789 &os_mutex_data_##name \
790}
791#endif
792
803#define osMutex(name) \
804&os_mutex_def_##name
805
815 osMutexCreate (const osMutexDef_t* mutex_def);
816
831 osMutexWait (osMutexId mutex_id, uint32_t millisec);
832
845 osMutexRelease (osMutexId mutex_id);
846
859 osMutexDelete (osMutexId mutex_id);
860
861// ==== Semaphore Management Functions ====
862
863#if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0)) // Semaphore available
864
872#if defined (osObjectsExternal) // object is external
873#define osSemaphoreDef(name) \
874extern const osSemaphoreDef_t os_semaphore_def_##name
875#else // define the object
876#define osSemaphoreDef(name) \
877osSemaphore os_semaphore_data_##name; \
878const osSemaphoreDef_t os_semaphore_def_##name = \
879{ \
880 #name, \
881 &os_semaphore_data_##name \
882}
883#endif
884
893#define osSemaphore(name) \
894&os_semaphore_def_##name
895
906 osSemaphoreCreate (const osSemaphoreDef_t* semaphore_def, int32_t count);
907
917 int32_t
918 osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec);
919
932
946
947#endif // Semaphore available
948
949// ==== Memory Pool Management Functions ====
950
951#if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
952
962#if defined (osObjectsExternal) // object is external
963#define osPoolDef(name, no, type) \
964extern const osPoolDef_t os_pool_def_##name
965#else // define the object
966#define osPoolAllocatedDef(name, items, type) \
967struct { \
968 osPool data; \
969} os_pool_##name; \
970const osPoolDef_t os_pool_def_##name = \
971{ \
972 #name, \
973 (items), \
974 sizeof(type), \
975 0, \
976 0, \
977 &os_pool_##name.data \
978}
979#define osPoolStaticDef(name, items, type) \
980struct { \
981 osPool data; \
982 struct { \
983 type pool[items]; \
984 } storage; \
985} os_pool_##name; \
986const osPoolDef_t os_pool_def_##name = \
987{ \
988 #name, \
989 (items), \
990 sizeof(type), \
991 &os_pool_##name.storage, \
992 sizeof(os_pool_##name.storage), \
993 &os_pool_##name.data \
994}
995#if defined(osObjectsStatic)
996#define osPoolDef(name, items, type) osPoolStaticDef(name, items, type)
997#else
998#define osPoolDef(name, items, type) osPoolAllocatedDef(name, items, type)
999#endif
1000#endif
1001
1009#define osPool(name) \
1010&os_pool_def_##name
1011
1020 osPoolId
1021 osPoolCreate (const osPoolDef_t* pool_def);
1022
1031 void*
1033
1041 void*
1043
1054 osStatus
1055 osPoolFree (osPoolId pool_id, void* block);
1056
1057#endif // Memory Pool Management available
1058
1059// ==== Message Queue Management Functions ====
1060
1061#if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queues available
1062
1072#if defined (osObjectsExternal) // object is external
1073#define osMessageQDef(name, queue_sz, type) \
1074extern const osMessageQDef_t os_messageQ_def_##name
1075#else // define the object
1076#define osMessageQAllocatedDef(name, items, type) \
1077struct { \
1078 osMessageQ data; \
1079} os_messageQ_##name; \
1080const osMessageQDef_t os_messageQ_def_##name = { \
1081 #name, \
1082 (items), \
1083 sizeof (void*), \
1084 0, \
1085 0, \
1086 &os_messageQ_##name.data \
1087}
1088#define osMessageQStaticDef(name, items, type) \
1089struct { \
1090 osMessageQ data; \
1091 struct { \
1092 void* queue[items]; \
1093 os_mqueue_index_t links[2 * items]; \
1094 os_mqueue_prio_t prios[items]; \
1095 } storage; \
1096} os_messageQ_##name; \
1097const osMessageQDef_t os_messageQ_def_##name = { \
1098 #name, \
1099 (items), \
1100 sizeof (void*), \
1101 &os_messageQ_##name.storage, \
1102 sizeof(os_messageQ_##name.storage), \
1103 &os_messageQ_##name.data \
1104}
1105
1106#if defined(osObjectsStatic)
1107#define osMessageQDef(name, items, type) osMessageQStaticDef(name, items, type)
1108#else
1109#define osMessageQDef(name, items, type) osMessageQAllocatedDef(name, items, type)
1110#endif
1111#endif
1112
1123#define osMessageQ(name) \
1124&os_messageQ_def_##name
1125
1136 osMessageCreate (const osMessageQDef_t* queue_def, osThreadId thread_id);
1137
1151 osStatus
1152 osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec);
1153
1166 osEvent
1167 osMessageGet (osMessageQId queue_id, uint32_t millisec);
1168
1169#endif // Message Queues available
1170
1171// ==== Mail Queue Management Functions ====
1172
1173#if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queues available
1174
1183#if defined (osObjectsExternal) // object is external
1184#define osMailQDef(name, queue_sz, type) \
1185extern const osMailQDef_t os_mailQ_def_##name
1186#else // define the object
1187#define osMailQAllocatedDef(name, items, type) \
1188struct { \
1189 osMailQ data; \
1190 struct { \
1191 type pool[items]; \
1192 } pool_storage; \
1193 struct { \
1194 void* queue[items]; \
1195 os_mqueue_index_t links[2 * items]; \
1196 os_mqueue_prio_t prios[items]; \
1197 } queue_storage; \
1198} os_mailQ_##name; \
1199const osMailQDef_t os_mailQ_def_##name = { \
1200 #name, \
1201 (items), \
1202 sizeof (type), \
1203 sizeof (void*), \
1204 0, \
1205 0, \
1206 0, \
1207 0, \
1208 &os_mailQ_##name.data \
1209}
1210#define osMailQStaticDef(name, items, type) \
1211struct { \
1212 osMailQ data; \
1213 struct { \
1214 type pool[items]; \
1215 } pool_storage; \
1216 struct { \
1217 void* queue[items]; \
1218 os_mqueue_index_t links[2 * items]; \
1219 os_mqueue_prio_t prios[items]; \
1220 } queue_storage; \
1221} os_mailQ_##name; \
1222const osMailQDef_t os_mailQ_def_##name = { \
1223 #name, \
1224 (items), \
1225 sizeof (type), \
1226 sizeof (void*), \
1227 &os_mailQ_##name.pool_storage, \
1228 sizeof(os_mailQ_##name.pool_storage), \
1229 &os_mailQ_##name.queue_storage, \
1230 sizeof(os_mailQ_##name.queue_storage), \
1231 &os_mailQ_##name.data \
1232}
1233#if defined(osObjectsStatic)
1234#define osMailQDef(name, items, type) osMailQStaticDef(name, items, type)
1235#else
1236#define osMailQDef(name, items, type) osMailQAllocatedDef(name, items, type)
1237#endif
1238#endif
1239
1247#define osMailQ(name) \
1248&os_mailQ_def_##name
1249
1259 osMailQId
1260 osMailCreate (const osMailQDef_t* mail_def, osThreadId thread_id);
1261
1271 void*
1272 osMailAlloc (osMailQId mail_id, uint32_t millisec);
1273
1283 void*
1284 osMailCAlloc (osMailQId mail_id, uint32_t millisec);
1285
1297 osStatus
1298 osMailPut (osMailQId mail_id, void* mail);
1299
1312 osEvent
1313 osMailGet (osMailQId mail_id, uint32_t millisec);
1314
1326 osStatus
1327 osMailFree (osMailQId mail_id, void* mail);
1328
1329#endif // Mail Queues available
1330
1331#ifdef __cplusplus
1332}
1333#endif
1334
1335#pragma GCC diagnostic pop
1336
1337#endif /* CMSIS_OS_H_ */
osStatus osMutexRelease(osMutexId mutex_id)
Release the mutex.
osStatus osDelay(uint32_t millisec)
Time Delay.
#define osSemaphore(name)
Access a Semaphore definition.
Definition cmsis_os.h:893
osStatus osThreadSetPriority(osThreadId thread_id, osPriority priority)
Change thread priority.
#define osMutex(name)
Access a mutex.
Definition cmsis_os.h:803
osEvent osMailGet(osMailQId mail_id, uint32_t millisec)
Get a mail from a queue.
#define osTimer(name)
Access the timer.
Definition cmsis_os.h:676
struct os_timer_def osTimerDef_t
Timer definition structure contains timer parameters.
osTimerId osTimerCreate(const osTimerDef_t *timer_def, os_timer_type type, void *args)
Create a timer.
osStatus osTimerStart(osTimerId timer_id, uint32_t millisec)
Start the timer.
#define osMessageQ(name)
Access a Message Queue.
Definition cmsis_os.h:1123
osPoolId osPoolCreate(const osPoolDef_t *pool_def)
Create a memory pool.
osStatus osMailPut(osMailQId mail_id, void *mail)
Put a mail to a queue.
osEvent osSignalWait(int32_t signals, uint32_t millisec)
Wait for one or more Signal Flags to become signaled for the current RUNNING thread.
osMutex * osMutexId
Mutex ID identifies the mutex (pointer to a mutex control block).
Definition cmsis_os.h:239
void(* os_pthread)(void const *argument)
Entry point of a thread.
Definition cmsis_os.h:187
int32_t osKernelRunning(void)
Check if the RTOS scheduler is started.
int32_t osSignalSet(osThreadId thread_id, int32_t signals)
Set signal flags.
osPriority osThreadGetPriority(osThreadId thread_id)
Get thread priority.
osStatus osPoolFree(osPoolId pool_id, void *block)
Free a memory block.
struct os_mail_queue_s os_mail_queue_t
osMessageQ * osMessageQId
Message ID identifies the message queue (pointer to a message queue control block).
Definition cmsis_os.h:257
osStatus osKernelInitialize(void)
Initialize the RTOS.
struct os_messageQ_def osMessageQDef_t
Definition structure for message queue.
osPool * osPoolId
Pool ID identifies the memory pool (pointer to a memory pool control block).
Definition cmsis_os.h:251
osStatus osTimerStop(osTimerId timer_id)
Stop the timer.
osMutexId osMutexCreate(const osMutexDef_t *mutex_def)
Create a mutex.
osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec)
Wait for mutex.
#define osPool(name)
Access a Memory Pool definition.
Definition cmsis_os.h:1009
osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
Get a message or Wait for a Message from a Queue.
osStatus osTimerDelete(osTimerId timer_id)
Delete the timer.
os_timer_attr_t osTimerAttr
Definition cmsis_os.h:201
void(* os_ptimer)(void const *argument)
Entry point of a timer call back function.
Definition cmsis_os.h:194
void * osMailAlloc(osMailQId mail_id, uint32_t millisec)
Allocate a memory block from a mail.
osPriority
Definition cmsis_os.h:132
@ osPriorityRealtime
priority: realtime (highest)
Definition cmsis_os.h:139
@ osPriorityAboveNormal
priority: above normal
Definition cmsis_os.h:137
@ osPriorityBelowNormal
priority: below normal
Definition cmsis_os.h:135
@ osPriorityNormal
priority: normal (default)
Definition cmsis_os.h:136
@ osPriorityIdle
priority: idle (lowest)
Definition cmsis_os.h:133
@ osPriorityLow
priority: low
Definition cmsis_os.h:134
@ osPriorityHigh
priority: high
Definition cmsis_os.h:138
@ osPriorityError
system cannot determine priority or thread has illegal priority
Definition cmsis_os.h:140
void * osMailCAlloc(osMailQId mail_id, uint32_t millisec)
Allocate and clear a memory block from a mail.
osEvent osWait(uint32_t millisec)
Wait for Signal, Message, Mail, or Timeout.
int32_t osSignalClear(osThreadId thread_id, int32_t signals)
Clear the specified Signal Flags of an active thread.
osTimer * osTimerId
Timer ID identifies the timer (pointer to a timer control block).
Definition cmsis_os.h:233
struct os_thread_def osThreadDef_t
Thread definition structure contains startup information of a thread.
osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, int32_t count)
Create a semaphore.
void * osPoolCAlloc(osPoolId pool_id)
Allocate and clear a memory block.
osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *args)
Create a thread.
void * osPoolAlloc(osPoolId pool_id)
Allocate a memory block.
os_mempool_attr_t osPoolAttr
Definition cmsis_os.h:210
osStatus osKernelStart(void)
osStatus osMailFree(osMailQId mail_id, void *mail)
Free a memory block from a mail.
osStatus osSemaphoreRelease(osSemaphoreId semaphore_id)
Release the semaphore.
osThreadId osThreadGetId(void)
Get the current thread.
struct os_mailQ_def osMailQDef_t
Definition structure for mail queue.
osMailQId osMailCreate(const osMailQDef_t *mail_def, osThreadId thread_id)
Create a mail queue.
osStatus osSemaphoreDelete(osSemaphoreId semaphore_id)
Delete the semaphore.
os_semaphore_attr_t osSemaphoreAttr
Definition cmsis_os.h:207
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a message to a queue.
osStatus osMutexDelete(osMutexId mutex_id)
Delete the mutex.
struct os_mutex_def osMutexDef_t
Mutex definition structure contains setup information for a mutex.
struct os_pool_def osPoolDef_t
Definition structure for memory block allocation.
int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec)
Wait until a Semaphore token becomes available.
struct os_semaphore_def osSemaphoreDef_t
Semaphore definition structure contains setup information for a semaphore.
uint32_t osKernelSysTick(void)
Get the system timer counter.
os_mqueue_attr_t osMessageQAttr
Definition cmsis_os.h:213
osSemaphore * osSemaphoreId
Semaphore ID identifies the semaphore (pointer to a semaphore control block).
Definition cmsis_os.h:245
#define osMailQ(name)
Access a mail queue definition.
Definition cmsis_os.h:1247
os_timer_type
Timer type value for the timer definition.
Definition cmsis_os.h:177
@ osTimerPeriodic
repeating timer
Definition cmsis_os.h:179
@ osTimerOnce
one-shot timer
Definition cmsis_os.h:178
os_thread_attr_t osThreadAttr
Definition cmsis_os.h:198
os_mutex_attr_t osMutexAttr
Definition cmsis_os.h:204
osStatus
Status code values returned by CMSIS-RTOS functions.
Definition cmsis_os.h:154
@ osEventMail
function completed; mail event occurred.
Definition cmsis_os.h:158
@ osErrorISR
not allowed in ISR context: the function cannot be called from interrupt service routines.
Definition cmsis_os.h:163
@ osErrorTimeoutResource
resource not available within given time: a specified resource was not available within the timeout p...
Definition cmsis_os.h:162
@ osErrorValue
value of a parameter is out of range.
Definition cmsis_os.h:167
@ osEventSignal
function completed; signal event occurred.
Definition cmsis_os.h:156
@ osErrorOS
unspecified RTOS error: run-time error but no other error message fits.
Definition cmsis_os.h:168
@ osEventTimeout
function completed; timeout occurred.
Definition cmsis_os.h:159
@ osErrorResource
resource not available: a specified resource was not available.
Definition cmsis_os.h:161
@ osOK
function completed; no error or event occurred.
Definition cmsis_os.h:155
@ osErrorPriority
system cannot determine priority or thread has illegal priority.
Definition cmsis_os.h:165
@ osErrorParameter
parameter error: a mandatory parameter was missing or specified an incorrect object.
Definition cmsis_os.h:160
@ os_status_reserved
prevent from enum down-size compiler optimization.
Definition cmsis_os.h:169
@ osEventMessage
function completed; message event occurred.
Definition cmsis_os.h:157
@ osErrorNoMemory
system is out of memory: it was impossible to allocate or reserve memory for the operation.
Definition cmsis_os.h:166
@ osErrorISRRecursive
function called multiple times from ISR with same object.
Definition cmsis_os.h:164
osStatus osThreadTerminate(osThreadId thread_id)
Terminate a thread.
#define osThread(name)
Access a Thread definition.
Definition cmsis_os.h:531
osStatus osThreadYield(void)
Yield control.
osMailQ * osMailQId
Mail ID identifies the mail queue (pointer to a mail queue control block).
Definition cmsis_os.h:263
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create a message queue.
osThread * osThreadId
Thread ID identifies the thread (pointer to a thread control block).
Definition cmsis_os.h:227
@ os_thread_priority_error
Definition os-c-decls.h:282
@ os_thread_priority_below_normal
Definition os-c-decls.h:275
@ os_thread_priority_high
Definition os-c-decls.h:278
@ os_thread_priority_realtime
Definition os-c-decls.h:279
@ os_thread_priority_idle
Definition os-c-decls.h:272
@ os_thread_priority_normal
Definition os-c-decls.h:276
@ os_thread_priority_low
Definition os-c-decls.h:274
@ os_thread_priority_above_normal
Definition os-c-decls.h:277
@ os_timer_once
Definition os-c-decls.h:696
@ os_timer_periodic
Definition os-c-decls.h:697
Event structure contains detailed information about an event.
Definition cmsis_os.h:378
uint32_t v
message as 32-bit value
Definition cmsis_os.h:382
void * p
message or mail as void pointer
Definition cmsis_os.h:383
osStatus status
status code: event or error information
Definition cmsis_os.h:379
int32_t signals
signal flags
Definition cmsis_os.h:384
osMailQId mail_id
mail id obtained by osMailCreate
Definition cmsis_os.h:388
osMessageQId message_id
message id obtained by osMessageCreate
Definition cmsis_os.h:389
Definition structure for mail queue.
Definition cmsis_os.h:360
osMailQ * data
Definition cmsis_os.h:369
uint32_t items
number of elements in the queue
Definition cmsis_os.h:362
uint32_t queue_sz
Definition cmsis_os.h:368
void * queue
pointer to memory array for queue
Definition cmsis_os.h:367
uint32_t queue_item_sz
size of a queue item
Definition cmsis_os.h:364
uint32_t pool_sz
Definition cmsis_os.h:366
uint32_t pool_item_sz
size of a pool item
Definition cmsis_os.h:363
void * pool
pointer to memory array for pool
Definition cmsis_os.h:365
const char * name
Definition cmsis_os.h:361
os_mqueue_t queue
Definition cmsis_os.h:218
os_mempool_t pool
Definition cmsis_os.h:217
Memory pool attributes.
Memory pool object storage.
Definition structure for message queue.
Definition cmsis_os.h:346
void * queue
pointer to memory array for messages
Definition cmsis_os.h:350
osMessageQ * data
Definition cmsis_os.h:352
uint32_t items
number of elements in the queue
Definition cmsis_os.h:348
const char * name
Definition cmsis_os.h:347
uint32_t item_sz
size of an item
Definition cmsis_os.h:349
uint32_t queue_sz
Definition cmsis_os.h:351
Message queue attributes.
Message queue object storage.
Mutex attributes.
Definition os-c-decls.h:924
Mutex definition structure contains setup information for a mutex.
Definition cmsis_os.h:305
osMutex * data
Definition cmsis_os.h:307
const char * name
Definition cmsis_os.h:306
Mutex object storage.
Definition os-c-decls.h:974
Definition structure for memory block allocation.
Definition cmsis_os.h:332
osPool * data
Definition cmsis_os.h:338
const char * name
Definition cmsis_os.h:333
uint32_t pool_sz
Definition cmsis_os.h:337
uint32_t item_sz
size of an item
Definition cmsis_os.h:335
void * pool
pointer to memory for pool
Definition cmsis_os.h:336
uint32_t items
number of items (elements) in the pool
Definition cmsis_os.h:334
Semaphore attributes.
Semaphore definition structure contains setup information for a semaphore.
Definition cmsis_os.h:315
const char * name
Definition cmsis_os.h:316
osSemaphore * data
Definition cmsis_os.h:317
Semaphore object storage.
Thread attributes.
Definition os-c-decls.h:493
Thread definition structure contains startup information of a thread.
Definition cmsis_os.h:277
os_pthread pthread
start address of thread function
Definition cmsis_os.h:279
uint64_t * stack
Definition cmsis_os.h:284
const char * name
Definition cmsis_os.h:278
osPriority tpriority
initial thread priority
Definition cmsis_os.h:280
uint32_t stacksize
stack size requirements in bytes; 0 is default stack size
Definition cmsis_os.h:282
osThread * data
Definition cmsis_os.h:283
uint32_t instances
maximum number of instances of that thread function
Definition cmsis_os.h:281
Thread object storage.
Definition os-c-decls.h:563
Timer attributes.
Definition os-c-decls.h:755
Timer definition structure contains timer parameters.
Definition cmsis_os.h:294
const char * name
Definition cmsis_os.h:295
osTimer * data
Definition cmsis_os.h:297
os_ptimer ptimer
start address of a timer function
Definition cmsis_os.h:296
Timer object storage.
Definition os-c-decls.h:785