annotate f103c8/Drivers/CMSIS/RTOS/Template/cmsis_os.h @ 2:0c59e7a7782a

Working on GPIO and RCC
author cin
date Mon, 16 Jan 2017 11:04:47 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
1 /* ----------------------------------------------------------------------
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
2 * $Date: 5. February 2013
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
3 * $Revision: V1.02
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
4 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
5 * Project: CMSIS-RTOS API
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
6 * Title: cmsis_os.h template header file
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
7 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
8 * Version 0.02
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
9 * Initial Proposal Phase
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
10 * Version 0.03
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
11 * osKernelStart added, optional feature: main started as thread
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
12 * osSemaphores have standard behavior
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
13 * osTimerCreate does not start the timer, added osTimerStart
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
14 * osThreadPass is renamed to osThreadYield
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
15 * Version 1.01
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
16 * Support for C++ interface
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
17 * - const attribute removed from the osXxxxDef_t typedef's
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
18 * - const attribute added to the osXxxxDef macros
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
19 * Added: osTimerDelete, osMutexDelete, osSemaphoreDelete
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
20 * Added: osKernelInitialize
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
21 * Version 1.02
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
22 * Control functions for short timeouts in microsecond resolution:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
23 * Added: osKernelSysTick, osKernelSysTickFrequency, osKernelSysTickMicroSec
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
24 * Removed: osSignalGet
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
25 *----------------------------------------------------------------------------
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
26 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
27 * Copyright (c) 2013 ARM LIMITED
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
28 * All rights reserved.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
29 * Redistribution and use in source and binary forms, with or without
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
30 * modification, are permitted provided that the following conditions are met:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
31 * - Redistributions of source code must retain the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
32 * notice, this list of conditions and the following disclaimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
33 * - Redistributions in binary form must reproduce the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
34 * notice, this list of conditions and the following disclaimer in the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
35 * documentation and/or other materials provided with the distribution.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
36 * - Neither the name of ARM nor the names of its contributors may be used
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
37 * to endorse or promote products derived from this software without
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
38 * specific prior written permission.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
39 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
41 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
43 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
44 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
45 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
46 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
47 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
48 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
50 * POSSIBILITY OF SUCH DAMAGE.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
51 *---------------------------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
52
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
53
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
54 #ifndef _CMSIS_OS_H
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
55 #define _CMSIS_OS_H
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
56
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
57 /// \note MUST REMAIN UNCHANGED: \b osCMSIS identifies the CMSIS-RTOS API version.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
58 #define osCMSIS 0x10002 ///< API version (main [31:16] .sub [15:0])
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
59
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
60 /// \note CAN BE CHANGED: \b osCMSIS_KERNEL identifies the underlying RTOS kernel and version number.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
61 #define osCMSIS_KERNEL 0x10000 ///< RTOS identification and version (main [31:16] .sub [15:0])
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
62
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
63 /// \note MUST REMAIN UNCHANGED: \b osKernelSystemId shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
64 #define osKernelSystemId "KERNEL V1.00" ///< RTOS identification string
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
65
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
66 /// \note MUST REMAIN UNCHANGED: \b osFeature_xxx shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
67 #define osFeature_MainThread 1 ///< main thread 1=main can be thread, 0=not available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
68 #define osFeature_Pool 1 ///< Memory Pools: 1=available, 0=not available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
69 #define osFeature_MailQ 1 ///< Mail Queues: 1=available, 0=not available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
70 #define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
71 #define osFeature_Signals 8 ///< maximum number of Signal Flags available per thread
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
72 #define osFeature_Semaphore 30 ///< maximum count for \ref osSemaphoreCreate function
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
73 #define osFeature_Wait 1 ///< osWait function: 1=available, 0=not available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
74 #define osFeature_SysTick 1 ///< osKernelSysTick functions: 1=available, 0=not available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
75
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
76 #include <stdint.h>
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
77 #include <stddef.h>
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
78
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
79 #ifdef __cplusplus
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
80 extern "C"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
81 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
82 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
83
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
84
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
85 // ==== Enumeration, structures, defines ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
86
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
87 /// Priority used for thread control.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
88 /// \note MUST REMAIN UNCHANGED: \b osPriority shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
89 typedef enum {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
90 osPriorityIdle = -3, ///< priority: idle (lowest)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
91 osPriorityLow = -2, ///< priority: low
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
92 osPriorityBelowNormal = -1, ///< priority: below normal
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
93 osPriorityNormal = 0, ///< priority: normal (default)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
94 osPriorityAboveNormal = +1, ///< priority: above normal
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
95 osPriorityHigh = +2, ///< priority: high
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
96 osPriorityRealtime = +3, ///< priority: realtime (highest)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
97 osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
98 } osPriority;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
99
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
100 /// Timeout value.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
101 /// \note MUST REMAIN UNCHANGED: \b osWaitForever shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
102 #define osWaitForever 0xFFFFFFFF ///< wait forever timeout value
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
103
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
104 /// Status code values returned by CMSIS-RTOS functions.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
105 /// \note MUST REMAIN UNCHANGED: \b osStatus shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
106 typedef enum {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
107 osOK = 0, ///< function completed; no error or event occurred.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
108 osEventSignal = 0x08, ///< function completed; signal event occurred.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
109 osEventMessage = 0x10, ///< function completed; message event occurred.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
110 osEventMail = 0x20, ///< function completed; mail event occurred.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
111 osEventTimeout = 0x40, ///< function completed; timeout occurred.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
112 osErrorParameter = 0x80, ///< parameter error: a mandatory parameter was missing or specified an incorrect object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
113 osErrorResource = 0x81, ///< resource not available: a specified resource was not available.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
114 osErrorTimeoutResource = 0xC1, ///< resource not available within given time: a specified resource was not available within the timeout period.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
115 osErrorISR = 0x82, ///< not allowed in ISR context: the function cannot be called from interrupt service routines.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
116 osErrorISRRecursive = 0x83, ///< function called multiple times from ISR with same object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
117 osErrorPriority = 0x84, ///< system cannot determine priority or thread has illegal priority.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
118 osErrorNoMemory = 0x85, ///< system is out of memory: it was impossible to allocate or reserve memory for the operation.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
119 osErrorValue = 0x86, ///< value of a parameter is out of range.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
120 osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
121 os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
122 } osStatus;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
123
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
124
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
125 /// Timer type value for the timer definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
126 /// \note MUST REMAIN UNCHANGED: \b os_timer_type shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
127 typedef enum {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
128 osTimerOnce = 0, ///< one-shot timer
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
129 osTimerPeriodic = 1 ///< repeating timer
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
130 } os_timer_type;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
131
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
132 /// Entry point of a thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
133 /// \note MUST REMAIN UNCHANGED: \b os_pthread shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
134 typedef void (*os_pthread) (void const *argument);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
135
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
136 /// Entry point of a timer call back function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
137 /// \note MUST REMAIN UNCHANGED: \b os_ptimer shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
138 typedef void (*os_ptimer) (void const *argument);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
139
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
140 // >>> the following data type definitions may shall adapted towards a specific RTOS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
141
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
142 /// Thread ID identifies the thread (pointer to a thread control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
143 /// \note CAN BE CHANGED: \b os_thread_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
144 typedef struct os_thread_cb *osThreadId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
145
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
146 /// Timer ID identifies the timer (pointer to a timer control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
147 /// \note CAN BE CHANGED: \b os_timer_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
148 typedef struct os_timer_cb *osTimerId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
149
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
150 /// Mutex ID identifies the mutex (pointer to a mutex control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
151 /// \note CAN BE CHANGED: \b os_mutex_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
152 typedef struct os_mutex_cb *osMutexId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
153
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
154 /// Semaphore ID identifies the semaphore (pointer to a semaphore control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
155 /// \note CAN BE CHANGED: \b os_semaphore_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
156 typedef struct os_semaphore_cb *osSemaphoreId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
157
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
158 /// Pool ID identifies the memory pool (pointer to a memory pool control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
159 /// \note CAN BE CHANGED: \b os_pool_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
160 typedef struct os_pool_cb *osPoolId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
161
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
162 /// Message ID identifies the message queue (pointer to a message queue control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
163 /// \note CAN BE CHANGED: \b os_messageQ_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
164 typedef struct os_messageQ_cb *osMessageQId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
165
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
166 /// Mail ID identifies the mail queue (pointer to a mail queue control block).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
167 /// \note CAN BE CHANGED: \b os_mailQ_cb is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
168 typedef struct os_mailQ_cb *osMailQId;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
169
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
170
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
171 /// Thread Definition structure contains startup information of a thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
172 /// \note CAN BE CHANGED: \b os_thread_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
173 typedef struct os_thread_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
174 os_pthread pthread; ///< start address of thread function
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
175 osPriority tpriority; ///< initial thread priority
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
176 uint32_t instances; ///< maximum number of instances of that thread function
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
177 uint32_t stacksize; ///< stack size requirements in bytes; 0 is default stack size
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
178 } osThreadDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
179
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
180 /// Timer Definition structure contains timer parameters.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
181 /// \note CAN BE CHANGED: \b os_timer_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
182 typedef struct os_timer_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
183 os_ptimer ptimer; ///< start address of a timer function
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
184 } osTimerDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
185
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
186 /// Mutex Definition structure contains setup information for a mutex.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
187 /// \note CAN BE CHANGED: \b os_mutex_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
188 typedef struct os_mutex_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
189 uint32_t dummy; ///< dummy value.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
190 } osMutexDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
191
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
192 /// Semaphore Definition structure contains setup information for a semaphore.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
193 /// \note CAN BE CHANGED: \b os_semaphore_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
194 typedef struct os_semaphore_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
195 uint32_t dummy; ///< dummy value.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
196 } osSemaphoreDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
197
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
198 /// Definition structure for memory block allocation.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
199 /// \note CAN BE CHANGED: \b os_pool_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
200 typedef struct os_pool_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
201 uint32_t pool_sz; ///< number of items (elements) in the pool
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
202 uint32_t item_sz; ///< size of an item
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
203 void *pool; ///< pointer to memory for pool
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
204 } osPoolDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
205
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
206 /// Definition structure for message queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
207 /// \note CAN BE CHANGED: \b os_messageQ_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
208 typedef struct os_messageQ_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
209 uint32_t queue_sz; ///< number of elements in the queue
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
210 uint32_t item_sz; ///< size of an item
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
211 void *pool; ///< memory array for messages
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
212 } osMessageQDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
213
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
214 /// Definition structure for mail queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
215 /// \note CAN BE CHANGED: \b os_mailQ_def is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
216 typedef struct os_mailQ_def {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
217 uint32_t queue_sz; ///< number of elements in the queue
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
218 uint32_t item_sz; ///< size of an item
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
219 void *pool; ///< memory array for mail
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
220 } osMailQDef_t;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
221
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
222 /// Event structure contains detailed information about an event.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
223 /// \note MUST REMAIN UNCHANGED: \b os_event shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
224 /// However the struct may be extended at the end.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
225 typedef struct {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
226 osStatus status; ///< status code: event or error information
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
227 union {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
228 uint32_t v; ///< message as 32-bit value
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
229 void *p; ///< message or mail as void pointer
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
230 int32_t signals; ///< signal flags
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
231 } value; ///< event value
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
232 union {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
233 osMailQId mail_id; ///< mail id obtained by \ref osMailCreate
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
234 osMessageQId message_id; ///< message id obtained by \ref osMessageCreate
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
235 } def; ///< event definition
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
236 } osEvent;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
237
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
238
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
239 // ==== Kernel Control Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
240
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
241 /// Initialize the RTOS Kernel for creating objects.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
242 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
243 /// \note MUST REMAIN UNCHANGED: \b osKernelInitialize shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
244 osStatus osKernelInitialize (void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
245
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
246 /// Start the RTOS Kernel.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
247 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
248 /// \note MUST REMAIN UNCHANGED: \b osKernelStart shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
249 osStatus osKernelStart (void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
250
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
251 /// Check if the RTOS kernel is already started.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
252 /// \note MUST REMAIN UNCHANGED: \b osKernelRunning shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
253 /// \return 0 RTOS is not started, 1 RTOS is started.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
254 int32_t osKernelRunning(void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
255
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
256 #if (defined (osFeature_SysTick) && (osFeature_SysTick != 0)) // System Timer available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
257
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
258 /// Get the RTOS kernel system timer counter
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
259 /// \note MUST REMAIN UNCHANGED: \b osKernelSysTick shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
260 /// \return RTOS kernel system timer as 32-bit value
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
261 uint32_t osKernelSysTick (void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
262
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
263 /// The RTOS kernel system timer frequency in Hz
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
264 /// \note Reflects the system timer setting and is typically defined in a configuration file.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
265 #define osKernelSysTickFrequency 100000000
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
266
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
267 /// Convert a microseconds value to a RTOS kernel system timer value.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
268 /// \param microsec time value in microseconds.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
269 /// \return time value normalized to the \ref osKernelSysTickFrequency
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
270 #define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
271
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
272 #endif // System Timer available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
273
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
274 // ==== Thread Management ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
275
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
276 /// Create a Thread Definition with function, priority, and stack requirements.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
277 /// \param name name of the thread function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
278 /// \param priority initial priority of the thread function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
279 /// \param instances number of possible thread instances.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
280 /// \param stacksz stack size (in bytes) requirements for the thread function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
281 /// \note CAN BE CHANGED: The parameters to \b osThreadDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
282 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
283 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
284 #define osThreadDef(name, priority, instances, stacksz) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
285 extern const osThreadDef_t os_thread_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
286 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
287 #define osThreadDef(name, priority, instances, stacksz) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
288 const osThreadDef_t os_thread_def_##name = \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
289 { (name), (priority), (instances), (stacksz) }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
290 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
291
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
292 /// Access a Thread definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
293 /// \param name name of the thread definition object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
294 /// \note CAN BE CHANGED: The parameter to \b osThread shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
295 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
296 #define osThread(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
297 &os_thread_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
298
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
299 /// Create a thread and add it to Active Threads and set it to state READY.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
300 /// \param[in] thread_def thread definition referenced with \ref osThread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
301 /// \param[in] argument pointer that is passed to the thread function as start argument.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
302 /// \return thread ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
303 /// \note MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
304 osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
305
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
306 /// Return the thread ID of the current running thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
307 /// \return thread ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
308 /// \note MUST REMAIN UNCHANGED: \b osThreadGetId shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
309 osThreadId osThreadGetId (void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
310
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
311 /// Terminate execution of a thread and remove it from Active Threads.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
312 /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
313 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
314 /// \note MUST REMAIN UNCHANGED: \b osThreadTerminate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
315 osStatus osThreadTerminate (osThreadId thread_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
316
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
317 /// Pass control to next thread that is in state \b READY.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
318 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
319 /// \note MUST REMAIN UNCHANGED: \b osThreadYield shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
320 osStatus osThreadYield (void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
321
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
322 /// Change priority of an active thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
323 /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
324 /// \param[in] priority new priority value for the thread function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
325 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
326 /// \note MUST REMAIN UNCHANGED: \b osThreadSetPriority shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
327 osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
328
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
329 /// Get current priority of an active thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
330 /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
331 /// \return current priority value of the thread function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
332 /// \note MUST REMAIN UNCHANGED: \b osThreadGetPriority shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
333 osPriority osThreadGetPriority (osThreadId thread_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
334
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
335
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
336 // ==== Generic Wait Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
337
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
338 /// Wait for Timeout (Time Delay).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
339 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue "time delay" value
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
340 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
341 osStatus osDelay (uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
342
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
343 #if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
344
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
345 /// Wait for Signal, Message, Mail, or Timeout.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
346 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
347 /// \return event that contains signal, message, or mail information or error code.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
348 /// \note MUST REMAIN UNCHANGED: \b osWait shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
349 osEvent osWait (uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
350
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
351 #endif // Generic Wait available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
352
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
353
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
354 // ==== Timer Management Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
355 /// Define a Timer object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
356 /// \param name name of the timer object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
357 /// \param function name of the timer call back function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
358 /// \note CAN BE CHANGED: The parameter to \b osTimerDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
359 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
360 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
361 #define osTimerDef(name, function) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
362 extern const osTimerDef_t os_timer_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
363 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
364 #define osTimerDef(name, function) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
365 const osTimerDef_t os_timer_def_##name = \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
366 { (function) }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
367 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
368
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
369 /// Access a Timer definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
370 /// \param name name of the timer object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
371 /// \note CAN BE CHANGED: The parameter to \b osTimer shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
372 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
373 #define osTimer(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
374 &os_timer_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
375
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
376 /// Create a timer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
377 /// \param[in] timer_def timer object referenced with \ref osTimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
378 /// \param[in] type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
379 /// \param[in] argument argument to the timer call back function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
380 /// \return timer ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
381 /// \note MUST REMAIN UNCHANGED: \b osTimerCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
382 osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
383
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
384 /// Start or restart a timer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
385 /// \param[in] timer_id timer ID obtained by \ref osTimerCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
386 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue "time delay" value of the timer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
387 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
388 /// \note MUST REMAIN UNCHANGED: \b osTimerStart shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
389 osStatus osTimerStart (osTimerId timer_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
390
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
391 /// Stop the timer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
392 /// \param[in] timer_id timer ID obtained by \ref osTimerCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
393 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
394 /// \note MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
395 osStatus osTimerStop (osTimerId timer_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
396
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
397 /// Delete a timer that was created by \ref osTimerCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
398 /// \param[in] timer_id timer ID obtained by \ref osTimerCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
399 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
400 /// \note MUST REMAIN UNCHANGED: \b osTimerDelete shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
401 osStatus osTimerDelete (osTimerId timer_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
402
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
403
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
404 // ==== Signal Management ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
405
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
406 /// Set the specified Signal Flags of an active thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
407 /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
408 /// \param[in] signals specifies the signal flags of the thread that should be set.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
409 /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
410 /// \note MUST REMAIN UNCHANGED: \b osSignalSet shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
411 int32_t osSignalSet (osThreadId thread_id, int32_t signals);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
412
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
413 /// Clear the specified Signal Flags of an active thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
414 /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
415 /// \param[in] signals specifies the signal flags of the thread that shall be cleared.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
416 /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters or call from ISR.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
417 /// \note MUST REMAIN UNCHANGED: \b osSignalClear shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
418 int32_t osSignalClear (osThreadId thread_id, int32_t signals);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
419
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
420 /// Wait for one or more Signal Flags to become signaled for the current \b RUNNING thread.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
421 /// \param[in] signals wait until all specified signal flags set or 0 for any single signal flag.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
422 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
423 /// \return event flag information or error code.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
424 /// \note MUST REMAIN UNCHANGED: \b osSignalWait shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
425 osEvent osSignalWait (int32_t signals, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
426
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
427
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
428 // ==== Mutex Management ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
429
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
430 /// Define a Mutex.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
431 /// \param name name of the mutex object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
432 /// \note CAN BE CHANGED: The parameter to \b osMutexDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
433 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
434 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
435 #define osMutexDef(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
436 extern const osMutexDef_t os_mutex_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
437 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
438 #define osMutexDef(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
439 const osMutexDef_t os_mutex_def_##name = { 0 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
440 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
441
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
442 /// Access a Mutex definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
443 /// \param name name of the mutex object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
444 /// \note CAN BE CHANGED: The parameter to \b osMutex shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
445 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
446 #define osMutex(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
447 &os_mutex_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
448
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
449 /// Create and Initialize a Mutex object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
450 /// \param[in] mutex_def mutex definition referenced with \ref osMutex.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
451 /// \return mutex ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
452 /// \note MUST REMAIN UNCHANGED: \b osMutexCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
453 osMutexId osMutexCreate (const osMutexDef_t *mutex_def);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
454
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
455 /// Wait until a Mutex becomes available.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
456 /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
457 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
458 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
459 /// \note MUST REMAIN UNCHANGED: \b osMutexWait shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
460 osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
461
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
462 /// Release a Mutex that was obtained by \ref osMutexWait.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
463 /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
464 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
465 /// \note MUST REMAIN UNCHANGED: \b osMutexRelease shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
466 osStatus osMutexRelease (osMutexId mutex_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
467
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
468 /// Delete a Mutex that was created by \ref osMutexCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
469 /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
470 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
471 /// \note MUST REMAIN UNCHANGED: \b osMutexDelete shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
472 osStatus osMutexDelete (osMutexId mutex_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
473
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
474
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
475 // ==== Semaphore Management Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
476
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
477 #if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0)) // Semaphore available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
478
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
479 /// Define a Semaphore object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
480 /// \param name name of the semaphore object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
481 /// \note CAN BE CHANGED: The parameter to \b osSemaphoreDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
482 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
483 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
484 #define osSemaphoreDef(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
485 extern const osSemaphoreDef_t os_semaphore_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
486 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
487 #define osSemaphoreDef(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
488 const osSemaphoreDef_t os_semaphore_def_##name = { 0 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
489 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
490
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
491 /// Access a Semaphore definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
492 /// \param name name of the semaphore object.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
493 /// \note CAN BE CHANGED: The parameter to \b osSemaphore shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
494 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
495 #define osSemaphore(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
496 &os_semaphore_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
497
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
498 /// Create and Initialize a Semaphore object used for managing resources.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
499 /// \param[in] semaphore_def semaphore definition referenced with \ref osSemaphore.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
500 /// \param[in] count number of available resources.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
501 /// \return semaphore ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
502 /// \note MUST REMAIN UNCHANGED: \b osSemaphoreCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
503 osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
504
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
505 /// Wait until a Semaphore token becomes available.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
506 /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
507 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
508 /// \return number of available tokens, or -1 in case of incorrect parameters.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
509 /// \note MUST REMAIN UNCHANGED: \b osSemaphoreWait shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
510 int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
511
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
512 /// Release a Semaphore token.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
513 /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
514 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
515 /// \note MUST REMAIN UNCHANGED: \b osSemaphoreRelease shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
516 osStatus osSemaphoreRelease (osSemaphoreId semaphore_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
517
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
518 /// Delete a Semaphore that was created by \ref osSemaphoreCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
519 /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
520 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
521 /// \note MUST REMAIN UNCHANGED: \b osSemaphoreDelete shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
522 osStatus osSemaphoreDelete (osSemaphoreId semaphore_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
523
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
524 #endif // Semaphore available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
525
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
526
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
527 // ==== Memory Pool Management Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
528
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
529 #if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
530
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
531 /// \brief Define a Memory Pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
532 /// \param name name of the memory pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
533 /// \param no maximum number of blocks (objects) in the memory pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
534 /// \param type data type of a single block (object).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
535 /// \note CAN BE CHANGED: The parameter to \b osPoolDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
536 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
537 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
538 #define osPoolDef(name, no, type) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
539 extern const osPoolDef_t os_pool_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
540 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
541 #define osPoolDef(name, no, type) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
542 const osPoolDef_t os_pool_def_##name = \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
543 { (no), sizeof(type), NULL }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
544 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
545
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
546 /// \brief Access a Memory Pool definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
547 /// \param name name of the memory pool
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
548 /// \note CAN BE CHANGED: The parameter to \b osPool shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
549 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
550 #define osPool(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
551 &os_pool_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
552
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
553 /// Create and Initialize a memory pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
554 /// \param[in] pool_def memory pool definition referenced with \ref osPool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
555 /// \return memory pool ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
556 /// \note MUST REMAIN UNCHANGED: \b osPoolCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
557 osPoolId osPoolCreate (const osPoolDef_t *pool_def);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
558
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
559 /// Allocate a memory block from a memory pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
560 /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
561 /// \return address of the allocated memory block or NULL in case of no memory available.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
562 /// \note MUST REMAIN UNCHANGED: \b osPoolAlloc shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
563 void *osPoolAlloc (osPoolId pool_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
564
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
565 /// Allocate a memory block from a memory pool and set memory block to zero.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
566 /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
567 /// \return address of the allocated memory block or NULL in case of no memory available.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
568 /// \note MUST REMAIN UNCHANGED: \b osPoolCAlloc shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
569 void *osPoolCAlloc (osPoolId pool_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
570
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
571 /// Return an allocated memory block back to a specific memory pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
572 /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
573 /// \param[in] block address of the allocated memory block that is returned to the memory pool.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
574 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
575 /// \note MUST REMAIN UNCHANGED: \b osPoolFree shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
576 osStatus osPoolFree (osPoolId pool_id, void *block);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
577
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
578 #endif // Memory Pool Management available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
579
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
580
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
581 // ==== Message Queue Management Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
582
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
583 #if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queues available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
584
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
585 /// \brief Create a Message Queue Definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
586 /// \param name name of the queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
587 /// \param queue_sz maximum number of messages in the queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
588 /// \param type data type of a single message element (for debugger).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
589 /// \note CAN BE CHANGED: The parameter to \b osMessageQDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
590 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
591 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
592 #define osMessageQDef(name, queue_sz, type) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
593 extern const osMessageQDef_t os_messageQ_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
594 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
595 #define osMessageQDef(name, queue_sz, type) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
596 const osMessageQDef_t os_messageQ_def_##name = \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
597 { (queue_sz), sizeof (type) }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
598 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
599
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
600 /// \brief Access a Message Queue Definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
601 /// \param name name of the queue
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
602 /// \note CAN BE CHANGED: The parameter to \b osMessageQ shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
603 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
604 #define osMessageQ(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
605 &os_messageQ_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
606
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
607 /// Create and Initialize a Message Queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
608 /// \param[in] queue_def queue definition referenced with \ref osMessageQ.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
609 /// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
610 /// \return message queue ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
611 /// \note MUST REMAIN UNCHANGED: \b osMessageCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
612 osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
613
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
614 /// Put a Message to a Queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
615 /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
616 /// \param[in] info message information.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
617 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
618 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
619 /// \note MUST REMAIN UNCHANGED: \b osMessagePut shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
620 osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
621
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
622 /// Get a Message or Wait for a Message from a Queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
623 /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
624 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
625 /// \return event information that includes status code.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
626 /// \note MUST REMAIN UNCHANGED: \b osMessageGet shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
627 osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
628
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
629 #endif // Message Queues available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
630
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
631
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
632 // ==== Mail Queue Management Functions ====
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
633
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
634 #if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queues available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
635
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
636 /// \brief Create a Mail Queue Definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
637 /// \param name name of the queue
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
638 /// \param queue_sz maximum number of messages in queue
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
639 /// \param type data type of a single message element
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
640 /// \note CAN BE CHANGED: The parameter to \b osMailQDef shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
641 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
642 #if defined (osObjectsExternal) // object is external
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
643 #define osMailQDef(name, queue_sz, type) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
644 extern const osMailQDef_t os_mailQ_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
645 #else // define the object
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
646 #define osMailQDef(name, queue_sz, type) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
647 const osMailQDef_t os_mailQ_def_##name = \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
648 { (queue_sz), sizeof (type) }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
649 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
650
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
651 /// \brief Access a Mail Queue Definition.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
652 /// \param name name of the queue
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
653 /// \note CAN BE CHANGED: The parameter to \b osMailQ shall be consistent but the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
654 /// macro body is implementation specific in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
655 #define osMailQ(name) \
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
656 &os_mailQ_def_##name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
657
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
658 /// Create and Initialize mail queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
659 /// \param[in] queue_def reference to the mail queue definition obtain with \ref osMailQ
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
660 /// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
661 /// \return mail queue ID for reference by other functions or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
662 /// \note MUST REMAIN UNCHANGED: \b osMailCreate shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
663 osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
664
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
665 /// Allocate a memory block from a mail.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
666 /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
667 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
668 /// \return pointer to memory block that can be filled with mail or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
669 /// \note MUST REMAIN UNCHANGED: \b osMailAlloc shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
670 void *osMailAlloc (osMailQId queue_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
671
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
672 /// Allocate a memory block from a mail and set memory block to zero.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
673 /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
674 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
675 /// \return pointer to memory block that can be filled with mail or NULL in case of error.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
676 /// \note MUST REMAIN UNCHANGED: \b osMailCAlloc shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
677 void *osMailCAlloc (osMailQId queue_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
678
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
679 /// Put a mail to a queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
680 /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
681 /// \param[in] mail memory block previously allocated with \ref osMailAlloc or \ref osMailCAlloc.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
682 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
683 /// \note MUST REMAIN UNCHANGED: \b osMailPut shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
684 osStatus osMailPut (osMailQId queue_id, void *mail);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
685
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
686 /// Get a mail from a queue.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
687 /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
688 /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
689 /// \return event that contains mail information or error code.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
690 /// \note MUST REMAIN UNCHANGED: \b osMailGet shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
691 osEvent osMailGet (osMailQId queue_id, uint32_t millisec);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
692
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
693 /// Free a memory block from a mail.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
694 /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
695 /// \param[in] mail pointer to the memory block that was obtained with \ref osMailGet.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
696 /// \return status code that indicates the execution status of the function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
697 /// \note MUST REMAIN UNCHANGED: \b osMailFree shall be consistent in every CMSIS-RTOS.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
698 osStatus osMailFree (osMailQId queue_id, void *mail);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
699
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
700 #endif // Mail Queues available
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
701
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
702
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
703 #ifdef __cplusplus
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
704 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
705 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
706
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
707 #endif // _CMSIS_OS_H