User | Revision | Line number | New contents of line |
donatien |
0:e6ccf0b3d718
|
1
|
/* ----------------------------------------------------------------------
|
donatien |
0:e6ccf0b3d718
|
2
|
* Copyright (C) 2012 ARM Limited. All rights reserved.
|
donatien |
0:e6ccf0b3d718
|
3
|
*
|
donatien |
0:e6ccf0b3d718
|
4
|
* $Date: 5. March 2012
|
donatien |
0:e6ccf0b3d718
|
5
|
* $Revision: V0.03
|
donatien |
0:e6ccf0b3d718
|
6
|
*
|
donatien |
0:e6ccf0b3d718
|
7
|
* Project: CMSIS-RTOS API
|
donatien |
0:e6ccf0b3d718
|
8
|
* Title: cmsis_os.h RTX header file
|
donatien |
0:e6ccf0b3d718
|
9
|
*
|
donatien |
0:e6ccf0b3d718
|
10
|
* Version 0.02
|
donatien |
0:e6ccf0b3d718
|
11
|
* Initial Proposal Phase
|
donatien |
0:e6ccf0b3d718
|
12
|
* Version 0.03
|
donatien |
0:e6ccf0b3d718
|
13
|
* osKernelStart added, optional feature: main started as thread
|
donatien |
0:e6ccf0b3d718
|
14
|
* osSemaphores have standard behaviour
|
donatien |
0:e6ccf0b3d718
|
15
|
* osTimerCreate does not start the timer, added osTimerStart
|
donatien |
0:e6ccf0b3d718
|
16
|
* osThreadPass is renamed to osThreadYield
|
donatien |
0:e6ccf0b3d718
|
17
|
* -------------------------------------------------------------------- */
|
donatien |
0:e6ccf0b3d718
|
18
|
|
donatien |
0:e6ccf0b3d718
|
19
|
/**
|
donatien |
0:e6ccf0b3d718
|
20
|
\page cmsis_os_h Header File Template: cmsis_os.h
|
donatien |
0:e6ccf0b3d718
|
21
|
|
donatien |
0:e6ccf0b3d718
|
22
|
The file \b cmsis_os.h is a template header file for a CMSIS-RTOS compliant Real-Time Operating System (RTOS).
|
donatien |
0:e6ccf0b3d718
|
23
|
Each RTOS that is compliant with CMSIS-RTOS shall provide a specific \b cmsis_os.h header file that represents
|
donatien |
0:e6ccf0b3d718
|
24
|
its implementation.
|
donatien |
0:e6ccf0b3d718
|
25
|
|
donatien |
0:e6ccf0b3d718
|
26
|
The file cmsis_os.h contains:
|
donatien |
0:e6ccf0b3d718
|
27
|
- CMSIS-RTOS API function definitions
|
donatien |
0:e6ccf0b3d718
|
28
|
- struct definitions for parameters and return types
|
donatien |
0:e6ccf0b3d718
|
29
|
- status and priority values used by CMSIS-RTOS API functions
|
donatien |
0:e6ccf0b3d718
|
30
|
- macros for defining threads and other kernel objects
|
donatien |
0:e6ccf0b3d718
|
31
|
|
donatien |
0:e6ccf0b3d718
|
32
|
|
donatien |
0:e6ccf0b3d718
|
33
|
<b>Name conventions and header file modifications</b>
|
donatien |
0:e6ccf0b3d718
|
34
|
|
donatien |
0:e6ccf0b3d718
|
35
|
All definitions are prefixed with \b os to give an unique name space for CMSIS-RTOS functions.
|
donatien |
0:e6ccf0b3d718
|
36
|
Definitions that are prefixed \b os_ are not used in the application code but local to this header file.
|
donatien |
0:e6ccf0b3d718
|
37
|
All definitions and functions that belong to a module are grouped and have a common prefix, i.e. \b osThread.
|
donatien |
0:e6ccf0b3d718
|
38
|
|
donatien |
0:e6ccf0b3d718
|
39
|
Definitions that are marked with <b>CAN BE CHANGED</b> can be adapted towards the needs of the actual CMSIS-RTOS implementation.
|
donatien |
0:e6ccf0b3d718
|
40
|
These definitions can be specific to the underlying RTOS kernel.
|
donatien |
0:e6ccf0b3d718
|
41
|
|
donatien |
0:e6ccf0b3d718
|
42
|
Definitions that are marked with <b>MUST REMAIN UNCHANGED</b> cannot be altered. Otherwise the CMSIS-RTOS implementation is no longer
|
donatien |
0:e6ccf0b3d718
|
43
|
compliant to the standard. Note that some functions are optional and need not to be provided by every CMSIS-RTOS implementation.
|
donatien |
0:e6ccf0b3d718
|
44
|
|
donatien |
0:e6ccf0b3d718
|
45
|
|
donatien |
0:e6ccf0b3d718
|
46
|
<b>Function calls from interrupt service routines</b>
|
donatien |
0:e6ccf0b3d718
|
47
|
|
donatien |
0:e6ccf0b3d718
|
48
|
The following CMSIS-RTOS functions can be called from threads and interrupt service routines (ISR):
|
donatien |
0:e6ccf0b3d718
|
49
|
- \ref osSignalSet
|
donatien |
0:e6ccf0b3d718
|
50
|
- \ref osSemaphoreRelease
|
donatien |
0:e6ccf0b3d718
|
51
|
- \ref osPoolAlloc, \ref osPoolCAlloc, \ref osPoolFree
|
donatien |
0:e6ccf0b3d718
|
52
|
- \ref osMessagePut, \ref osMessageGet
|
donatien |
0:e6ccf0b3d718
|
53
|
- \ref osMailAlloc, \ref osMailCAlloc, \ref osMailGet, \ref osMailPut, \ref osMailFree
|
donatien |
0:e6ccf0b3d718
|
54
|
|
donatien |
0:e6ccf0b3d718
|
55
|
Functions that cannot be called from an ISR are verifying the interrupt status and return in case that they are called
|
donatien |
0:e6ccf0b3d718
|
56
|
from an ISR context the status code \b osErrorISR. In some implementations this condition might be caught using the HARD FAULT vector.
|
donatien |
0:e6ccf0b3d718
|
57
|
|
donatien |
0:e6ccf0b3d718
|
58
|
Some CMSIS-RTOS implementations support CMSIS-RTOS function calls from multiple ISR at the same time.
|
donatien |
0:e6ccf0b3d718
|
59
|
If this is impossible, the CMSIS-RTOS rejects calls by nested ISR functions with the status code \b osErrorISRRecursive.
|
donatien |
0:e6ccf0b3d718
|
60
|
|
donatien |
0:e6ccf0b3d718
|
61
|
|
donatien |
0:e6ccf0b3d718
|
62
|
<b>Define and reference object definitions</b>
|
donatien |
0:e6ccf0b3d718
|
63
|
|
donatien |
0:e6ccf0b3d718
|
64
|
With <b>\#define osObjectsExternal</b> objects are defined as external symbols. This allows to create a consistent header file
|
donatien |
0:e6ccf0b3d718
|
65
|
that is used troughtout a project as shown below:
|
donatien |
0:e6ccf0b3d718
|
66
|
|
donatien |
0:e6ccf0b3d718
|
67
|
<i>Header File</i>
|
donatien |
0:e6ccf0b3d718
|
68
|
\code
|
donatien |
0:e6ccf0b3d718
|
69
|
#include <cmsis_os.h> // CMSIS RTOS header file
|
donatien |
0:e6ccf0b3d718
|
70
|
|
donatien |
0:e6ccf0b3d718
|
71
|
// Thread definition
|
donatien |
0:e6ccf0b3d718
|
72
|
extern void thread_sample (void const *argument); // function prototype
|
donatien |
0:e6ccf0b3d718
|
73
|
osThreadDef (thread_sample, osPriorityBelowNormal, 1, 100);
|
donatien |
0:e6ccf0b3d718
|
74
|
|
donatien |
0:e6ccf0b3d718
|
75
|
// Pool definition
|
donatien |
0:e6ccf0b3d718
|
76
|
osPoolDef(MyPool, 10, long);
|
donatien |
0:e6ccf0b3d718
|
77
|
\endcode
|
donatien |
0:e6ccf0b3d718
|
78
|
|
donatien |
0:e6ccf0b3d718
|
79
|
|
donatien |
0:e6ccf0b3d718
|
80
|
This header file defines all objects when included in a C/C++ source file. When <b>\#define osObjectsExternal</b> is
|
donatien |
0:e6ccf0b3d718
|
81
|
present before the header file, the objects are defined as external symbols. A single consistent header file can therefore be
|
donatien |
0:e6ccf0b3d718
|
82
|
used throughout the whole project.
|
donatien |
0:e6ccf0b3d718
|
83
|
|
donatien |
0:e6ccf0b3d718
|
84
|
<i>Example</i>
|
donatien |
0:e6ccf0b3d718
|
85
|
\code
|
donatien |
0:e6ccf0b3d718
|
86
|
#include "osObjects.h" // Definition of the CMSIS-RTOS objects
|
donatien |
0:e6ccf0b3d718
|
87
|
\endcode
|
donatien |
0:e6ccf0b3d718
|
88
|
|
donatien |
0:e6ccf0b3d718
|
89
|
\code
|
donatien |
0:e6ccf0b3d718
|
90
|
#define osObjectExternal // Objects will be defined as external symbols
|
donatien |
0:e6ccf0b3d718
|
91
|
#include "osObjects.h" // Reference to the CMSIS-RTOS objects
|
donatien |
0:e6ccf0b3d718
|
92
|
\endcode
|
donatien |
0:e6ccf0b3d718
|
93
|
|
donatien |
0:e6ccf0b3d718
|
94
|
*/
|
donatien |
0:e6ccf0b3d718
|
95
|
|
donatien |
0:e6ccf0b3d718
|
96
|
#ifndef _CMSIS_OS_H
|
donatien |
0:e6ccf0b3d718
|
97
|
#define _CMSIS_OS_H
|
donatien |
0:e6ccf0b3d718
|
98
|
|
donatien |
0:e6ccf0b3d718
|
99
|
/// \note MUST REMAIN UNCHANGED: \b osCMSIS identifies the CMSIS-RTOS API version
|
donatien |
0:e6ccf0b3d718
|
100
|
#define osCMSIS 0x10000 ///< API version (main [31:16] .sub [15:0])
|
donatien |
0:e6ccf0b3d718
|
101
|
|
donatien |
0:e6ccf0b3d718
|
102
|
/// \note CAN BE CHANGED: \b osCMSIS_KERNEL identifies the underlaying RTOS kernel and version number.
|
donatien |
0:e6ccf0b3d718
|
103
|
#define osCMSIS_RTX 0x0003 ///< RTOS identification and version (main [31:16] .sub [15:0])
|
donatien |
0:e6ccf0b3d718
|
104
|
|
donatien |
0:e6ccf0b3d718
|
105
|
/// \note MUST REMAIN UNCHANGED: \b osKernelSystemId shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
106
|
#define osKernelSystemId "RTX V0.03" ///< RTOS identification string
|
donatien |
0:e6ccf0b3d718
|
107
|
|
donatien |
0:e6ccf0b3d718
|
108
|
|
donatien |
0:e6ccf0b3d718
|
109
|
#define CMSIS_OS_RTX
|
donatien |
0:e6ccf0b3d718
|
110
|
|
donatien |
0:e6ccf0b3d718
|
111
|
#ifdef TOOLCHAIN_GCC_ARM
|
donatien |
0:e6ccf0b3d718
|
112
|
# define WORDS_STACK_SIZE 512
|
donatien |
0:e6ccf0b3d718
|
113
|
#else
|
donatien |
0:e6ccf0b3d718
|
114
|
# if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
|
donatien |
0:e6ccf0b3d718
|
115
|
# define WORDS_STACK_SIZE 256
|
donatien |
0:e6ccf0b3d718
|
116
|
# elif defined(TARGET_LPC11U24)
|
donatien |
0:e6ccf0b3d718
|
117
|
# define WORDS_STACK_SIZE 128
|
donatien |
0:e6ccf0b3d718
|
118
|
# endif
|
donatien |
0:e6ccf0b3d718
|
119
|
#endif
|
donatien |
0:e6ccf0b3d718
|
120
|
|
donatien |
0:e6ccf0b3d718
|
121
|
#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4)
|
donatien |
0:e6ccf0b3d718
|
122
|
|
donatien |
0:e6ccf0b3d718
|
123
|
|
donatien |
0:e6ccf0b3d718
|
124
|
/// \note MUST REMAIN UNCHANGED: \b osFeature_xxx shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
125
|
#define osFeature_MainThread 1 ///< main thread 1=main can be thread, 0=not available
|
donatien |
0:e6ccf0b3d718
|
126
|
#define osFeature_Pool 1 ///< Memory Pools: 1=available, 0=not available
|
donatien |
0:e6ccf0b3d718
|
127
|
#define osFeature_MailQ 1 ///< Mail Queues: 1=available, 0=not available
|
donatien |
0:e6ccf0b3d718
|
128
|
#define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available
|
donatien |
0:e6ccf0b3d718
|
129
|
#define osFeature_Signals 16 ///< maximum number of Signal Flags available per thread
|
donatien |
0:e6ccf0b3d718
|
130
|
#define osFeature_Semaphore 8 ///< maximum count for SemaphoreInit function
|
donatien |
0:e6ccf0b3d718
|
131
|
#define osFeature_Wait 0 ///< osWait function: 1=available, 0=not available
|
donatien |
0:e6ccf0b3d718
|
132
|
|
donatien |
0:e6ccf0b3d718
|
133
|
#if defined (__CC_ARM)
|
donatien |
0:e6ccf0b3d718
|
134
|
#define os_InRegs __value_in_regs // Compiler specific: force struct in registers
|
donatien |
0:e6ccf0b3d718
|
135
|
#else
|
donatien |
0:e6ccf0b3d718
|
136
|
#define os_InRegs
|
donatien |
0:e6ccf0b3d718
|
137
|
#endif
|
donatien |
0:e6ccf0b3d718
|
138
|
|
donatien |
0:e6ccf0b3d718
|
139
|
#include <stdint.h>
|
donatien |
0:e6ccf0b3d718
|
140
|
#include <stddef.h>
|
donatien |
0:e6ccf0b3d718
|
141
|
|
donatien |
0:e6ccf0b3d718
|
142
|
#ifdef __cplusplus
|
donatien |
0:e6ccf0b3d718
|
143
|
extern "C"
|
donatien |
0:e6ccf0b3d718
|
144
|
{
|
donatien |
0:e6ccf0b3d718
|
145
|
#endif
|
donatien |
0:e6ccf0b3d718
|
146
|
|
donatien |
0:e6ccf0b3d718
|
147
|
|
donatien |
0:e6ccf0b3d718
|
148
|
// ==== Enumeration, structures, defines ====
|
donatien |
0:e6ccf0b3d718
|
149
|
|
donatien |
0:e6ccf0b3d718
|
150
|
/// Priority used for thread control.
|
donatien |
0:e6ccf0b3d718
|
151
|
/// \note MUST REMAIN UNCHANGED: \b osPriority shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
152
|
typedef enum {
|
donatien |
0:e6ccf0b3d718
|
153
|
osPriorityIdle = -3, ///< priority: idle (lowest)
|
donatien |
0:e6ccf0b3d718
|
154
|
osPriorityLow = -2, ///< priority: low
|
donatien |
0:e6ccf0b3d718
|
155
|
osPriorityBelowNormal = -1, ///< priority: below normal
|
donatien |
0:e6ccf0b3d718
|
156
|
osPriorityNormal = 0, ///< priority: normal (default)
|
donatien |
0:e6ccf0b3d718
|
157
|
osPriorityAboveNormal = +1, ///< priority: above normal
|
donatien |
0:e6ccf0b3d718
|
158
|
osPriorityHigh = +2, ///< priority: high
|
donatien |
0:e6ccf0b3d718
|
159
|
osPriorityRealtime = +3, ///< priority: realtime (highest)
|
donatien |
0:e6ccf0b3d718
|
160
|
osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority
|
donatien |
0:e6ccf0b3d718
|
161
|
} osPriority;
|
donatien |
0:e6ccf0b3d718
|
162
|
|
donatien |
0:e6ccf0b3d718
|
163
|
/// Timeout value
|
donatien |
0:e6ccf0b3d718
|
164
|
/// \note MUST REMAIN UNCHANGED: \b osWaitForever shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
165
|
#define osWaitForever 0xFFFFFFFF ///< wait forever timeout value
|
donatien |
0:e6ccf0b3d718
|
166
|
|
donatien |
0:e6ccf0b3d718
|
167
|
/// Status code values returned by CMSIS-RTOS functions
|
donatien |
0:e6ccf0b3d718
|
168
|
/// \note MUST REMAIN UNCHANGED: \b osStatus shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
169
|
typedef enum {
|
donatien |
0:e6ccf0b3d718
|
170
|
osOK = 0, ///< function completed; no event occurred.
|
donatien |
0:e6ccf0b3d718
|
171
|
osEventSignal = 0x08, ///< function completed; signal event occurred.
|
donatien |
0:e6ccf0b3d718
|
172
|
osEventMessage = 0x10, ///< function completed; message event occurred.
|
donatien |
0:e6ccf0b3d718
|
173
|
osEventMail = 0x20, ///< function completed; mail event occurred.
|
donatien |
0:e6ccf0b3d718
|
174
|
osEventTimeout = 0x40, ///< function completed; timeout occurred.
|
donatien |
0:e6ccf0b3d718
|
175
|
osErrorParameter = 0x80, ///< parameter error: a mandatory parameter was missing or specified an incorrect object.
|
donatien |
0:e6ccf0b3d718
|
176
|
osErrorResource = 0x81, ///< resource not available: a specified resource was not available.
|
donatien |
0:e6ccf0b3d718
|
177
|
osErrorTimeoutResource = 0xC1, ///< resource not available within given time: a specified resource was not available within the timeout period.
|
donatien |
0:e6ccf0b3d718
|
178
|
osErrorISR = 0x82, ///< not allowed in ISR context: the function cannot be called from interrupt service routines.
|
donatien |
0:e6ccf0b3d718
|
179
|
osErrorISRRecursive = 0x83, ///< function called multiple times from ISR with same object.
|
donatien |
0:e6ccf0b3d718
|
180
|
osErrorPriority = 0x84, ///< system cannot determine priority or thread has illegal priority.
|
donatien |
0:e6ccf0b3d718
|
181
|
osErrorNoMemory = 0x85, ///< system is out of memory: it was impossible to allocate or reserve memory for the operation.
|
donatien |
0:e6ccf0b3d718
|
182
|
osErrorValue = 0x86, ///< value of a parameter is out of range.
|
donatien |
0:e6ccf0b3d718
|
183
|
osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits.
|
donatien |
0:e6ccf0b3d718
|
184
|
os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization.
|
donatien |
0:e6ccf0b3d718
|
185
|
} osStatus;
|
donatien |
0:e6ccf0b3d718
|
186
|
|
donatien |
0:e6ccf0b3d718
|
187
|
|
donatien |
0:e6ccf0b3d718
|
188
|
/// Timer type value for the timer definition
|
donatien |
0:e6ccf0b3d718
|
189
|
/// \note MUST REMAIN UNCHANGED: \b os_timer_type shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
190
|
typedef enum {
|
donatien |
0:e6ccf0b3d718
|
191
|
osTimerOnce = 0, ///< one-shot timer
|
donatien |
0:e6ccf0b3d718
|
192
|
osTimerPeriodic = 1 ///< repeating timer
|
donatien |
0:e6ccf0b3d718
|
193
|
} os_timer_type;
|
donatien |
0:e6ccf0b3d718
|
194
|
|
donatien |
0:e6ccf0b3d718
|
195
|
/// Entry point of a thread.
|
donatien |
0:e6ccf0b3d718
|
196
|
/// \note MUST REMAIN UNCHANGED: \b os_pthread shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
197
|
typedef void (*os_pthread) (void const *argument);
|
donatien |
0:e6ccf0b3d718
|
198
|
|
donatien |
0:e6ccf0b3d718
|
199
|
/// Entry point of a timer call back function.
|
donatien |
0:e6ccf0b3d718
|
200
|
/// \note MUST REMAIN UNCHANGED: \b os_ptimer shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
201
|
typedef void (*os_ptimer) (void const *argument);
|
donatien |
0:e6ccf0b3d718
|
202
|
|
donatien |
0:e6ccf0b3d718
|
203
|
// >>> the following data type definitions may shall adapted towards a specific RTOS
|
donatien |
0:e6ccf0b3d718
|
204
|
|
donatien |
0:e6ccf0b3d718
|
205
|
/// Thread ID identifies the thread (pointer to a thread control block).
|
donatien |
0:e6ccf0b3d718
|
206
|
/// \note CAN BE CHANGED: \b os_thread_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
207
|
typedef struct os_thread_cb *osThreadId;
|
donatien |
0:e6ccf0b3d718
|
208
|
|
donatien |
0:e6ccf0b3d718
|
209
|
/// Timer ID identifies the timer (pointer to a timer control block).
|
donatien |
0:e6ccf0b3d718
|
210
|
/// \note CAN BE CHANGED: \b os_timer_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
211
|
typedef struct os_timer_cb *osTimerId;
|
donatien |
0:e6ccf0b3d718
|
212
|
|
donatien |
0:e6ccf0b3d718
|
213
|
/// Mutex ID identifies the mutex (pointer to a mutex control block).
|
donatien |
0:e6ccf0b3d718
|
214
|
/// \note CAN BE CHANGED: \b os_mutex_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
215
|
typedef struct os_mutex_cb *osMutexId;
|
donatien |
0:e6ccf0b3d718
|
216
|
|
donatien |
0:e6ccf0b3d718
|
217
|
/// Semaphore ID identifies the semaphore (pointer to a semaphore control block).
|
donatien |
0:e6ccf0b3d718
|
218
|
/// \note CAN BE CHANGED: \b os_semaphore_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
219
|
typedef struct os_semaphore_cb *osSemaphoreId;
|
donatien |
0:e6ccf0b3d718
|
220
|
|
donatien |
0:e6ccf0b3d718
|
221
|
/// Pool ID identifies the memory pool (pointer to a memory pool control block).
|
donatien |
0:e6ccf0b3d718
|
222
|
/// \note CAN BE CHANGED: \b os_pool_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
223
|
typedef struct os_pool_cb *osPoolId;
|
donatien |
0:e6ccf0b3d718
|
224
|
|
donatien |
0:e6ccf0b3d718
|
225
|
/// Message ID identifies the message queue (pointer to a message queue control block).
|
donatien |
0:e6ccf0b3d718
|
226
|
/// \note CAN BE CHANGED: \b os_messageQ_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
227
|
typedef struct os_messageQ_cb *osMessageQId;
|
donatien |
0:e6ccf0b3d718
|
228
|
|
donatien |
0:e6ccf0b3d718
|
229
|
/// Mail ID identifies the mail queue (pointer to a mail queue control block).
|
donatien |
0:e6ccf0b3d718
|
230
|
/// \note CAN BE CHANGED: \b os_mailQ_cb is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
231
|
typedef struct os_mailQ_cb *osMailQId;
|
donatien |
0:e6ccf0b3d718
|
232
|
|
donatien |
0:e6ccf0b3d718
|
233
|
|
donatien |
0:e6ccf0b3d718
|
234
|
/// Thread Definition structure contains startup information of a thread.
|
donatien |
0:e6ccf0b3d718
|
235
|
/// \note CAN BE CHANGED: \b os_thread_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
236
|
typedef struct os_thread_def {
|
donatien |
0:e6ccf0b3d718
|
237
|
os_pthread pthread; ///< start address of thread function
|
donatien |
0:e6ccf0b3d718
|
238
|
osPriority tpriority; ///< initial thread priority
|
donatien |
0:e6ccf0b3d718
|
239
|
uint32_t instances; ///< maximum number of instances of that thread function
|
donatien |
0:e6ccf0b3d718
|
240
|
uint32_t stacksize; ///< stack size requirements in bytes; 0 is default stack size
|
donatien |
0:e6ccf0b3d718
|
241
|
} osThreadDef_t;
|
donatien |
0:e6ccf0b3d718
|
242
|
|
donatien |
0:e6ccf0b3d718
|
243
|
/// Timer Definition structure contains timer parameters.
|
donatien |
0:e6ccf0b3d718
|
244
|
/// \note CAN BE CHANGED: \b os_timer_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
245
|
typedef struct os_timer_def {
|
donatien |
0:e6ccf0b3d718
|
246
|
os_ptimer ptimer; ///< start address of a timer function
|
donatien |
0:e6ccf0b3d718
|
247
|
void *timer; ///< pointer to internal data
|
donatien |
0:e6ccf0b3d718
|
248
|
} osTimerDef_t;
|
donatien |
0:e6ccf0b3d718
|
249
|
|
donatien |
0:e6ccf0b3d718
|
250
|
/// Mutex Definition structure contains setup information for a mutex.
|
donatien |
0:e6ccf0b3d718
|
251
|
/// \note CAN BE CHANGED: \b os_mutex_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
252
|
typedef struct os_mutex_def {
|
donatien |
0:e6ccf0b3d718
|
253
|
void *mutex; ///< pointer to internal data
|
donatien |
0:e6ccf0b3d718
|
254
|
} osMutexDef_t;
|
donatien |
0:e6ccf0b3d718
|
255
|
|
donatien |
0:e6ccf0b3d718
|
256
|
/// Semaphore Definition structure contains setup information for a semaphore.
|
donatien |
0:e6ccf0b3d718
|
257
|
/// \note CAN BE CHANGED: \b os_semaphore_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
258
|
typedef struct os_semaphore_def {
|
donatien |
0:e6ccf0b3d718
|
259
|
void *semaphore; ///< pointer to internal data
|
donatien |
0:e6ccf0b3d718
|
260
|
} osSemaphoreDef_t;
|
donatien |
0:e6ccf0b3d718
|
261
|
|
donatien |
0:e6ccf0b3d718
|
262
|
/// Definition structure for memory block allocation
|
donatien |
0:e6ccf0b3d718
|
263
|
/// \note CAN BE CHANGED: \b os_pool_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
264
|
typedef struct os_pool_def {
|
donatien |
0:e6ccf0b3d718
|
265
|
uint32_t pool_sz; ///< number of items (elements) in the pool
|
donatien |
0:e6ccf0b3d718
|
266
|
uint32_t item_sz; ///< size of an item
|
donatien |
0:e6ccf0b3d718
|
267
|
void *pool; ///< pointer to memory for pool
|
donatien |
0:e6ccf0b3d718
|
268
|
} osPoolDef_t;
|
donatien |
0:e6ccf0b3d718
|
269
|
|
donatien |
0:e6ccf0b3d718
|
270
|
/// Definition structure for message queue
|
donatien |
0:e6ccf0b3d718
|
271
|
/// \note CAN BE CHANGED: \b os_messageQ_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
272
|
typedef struct os_messageQ_def {
|
donatien |
0:e6ccf0b3d718
|
273
|
uint32_t queue_sz; ///< number of elements in the queue
|
donatien |
0:e6ccf0b3d718
|
274
|
void *pool; ///< memory array for messages
|
donatien |
0:e6ccf0b3d718
|
275
|
} osMessageQDef_t;
|
donatien |
0:e6ccf0b3d718
|
276
|
|
donatien |
0:e6ccf0b3d718
|
277
|
/// Definition structure for mail queue
|
donatien |
0:e6ccf0b3d718
|
278
|
/// \note CAN BE CHANGED: \b os_mailQ_def is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
279
|
typedef struct os_mailQ_def {
|
donatien |
0:e6ccf0b3d718
|
280
|
uint32_t queue_sz; ///< number of elements in the queue
|
donatien |
0:e6ccf0b3d718
|
281
|
uint32_t item_sz; ///< size of an item
|
donatien |
0:e6ccf0b3d718
|
282
|
void *pool; ///< memory array for mail
|
donatien |
0:e6ccf0b3d718
|
283
|
} osMailQDef_t;
|
donatien |
0:e6ccf0b3d718
|
284
|
|
donatien |
0:e6ccf0b3d718
|
285
|
/// Event structure contains detailed information about an event.
|
donatien |
0:e6ccf0b3d718
|
286
|
/// \note MUST REMAIN UNCHANGED: \b os_event shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
287
|
/// However the struct may be extended at the end.
|
donatien |
0:e6ccf0b3d718
|
288
|
typedef struct {
|
donatien |
0:e6ccf0b3d718
|
289
|
osStatus status; ///< status code: event or error information
|
donatien |
0:e6ccf0b3d718
|
290
|
union {
|
donatien |
0:e6ccf0b3d718
|
291
|
uint32_t v; ///< message as 32-bit value
|
donatien |
0:e6ccf0b3d718
|
292
|
void *p; ///< message or mail as void pointer
|
donatien |
0:e6ccf0b3d718
|
293
|
int32_t signals; ///< signal flags
|
donatien |
0:e6ccf0b3d718
|
294
|
} value; ///< event value
|
donatien |
0:e6ccf0b3d718
|
295
|
union {
|
donatien |
0:e6ccf0b3d718
|
296
|
osMailQId mail_id; ///< mail id obtained by \ref osMailCreate
|
donatien |
0:e6ccf0b3d718
|
297
|
osMessageQId message_id; ///< message id obtained by \ref osMessageCreate
|
donatien |
0:e6ccf0b3d718
|
298
|
} def; ///< event definition
|
donatien |
0:e6ccf0b3d718
|
299
|
} osEvent;
|
donatien |
0:e6ccf0b3d718
|
300
|
|
donatien |
0:e6ccf0b3d718
|
301
|
|
donatien |
0:e6ccf0b3d718
|
302
|
// ==== Kernel Control Functions ====
|
donatien |
0:e6ccf0b3d718
|
303
|
|
donatien |
0:e6ccf0b3d718
|
304
|
/// Start the RTOS Kernel with executing the specified thread.
|
donatien |
0:e6ccf0b3d718
|
305
|
/// \param[in] thread_def thread definition referenced with \ref osThread.
|
donatien |
0:e6ccf0b3d718
|
306
|
/// \param[in] argument pointer that is passed to the thread function as start argument.
|
donatien |
0:e6ccf0b3d718
|
307
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
308
|
/// \note MUST REMAIN UNCHANGED: \b osKernelStart shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
309
|
osStatus osKernelStart (osThreadDef_t *thread_def, void *argument);
|
donatien |
0:e6ccf0b3d718
|
310
|
|
donatien |
0:e6ccf0b3d718
|
311
|
/// Check if the RTOS kernel is already started.
|
donatien |
0:e6ccf0b3d718
|
312
|
/// \note MUST REMAIN UNCHANGED: \b osKernelRunning shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
313
|
/// \return 0 RTOS is not started, 1 RTOS is started.
|
donatien |
0:e6ccf0b3d718
|
314
|
int32_t osKernelRunning(void);
|
donatien |
0:e6ccf0b3d718
|
315
|
|
donatien |
0:e6ccf0b3d718
|
316
|
|
donatien |
0:e6ccf0b3d718
|
317
|
// ==== Thread Management ====
|
donatien |
0:e6ccf0b3d718
|
318
|
|
donatien |
0:e6ccf0b3d718
|
319
|
/// Create a Thread Definition with function, priority, and stack requirements.
|
donatien |
0:e6ccf0b3d718
|
320
|
/// \param name name of the thread function.
|
donatien |
0:e6ccf0b3d718
|
321
|
/// \param priority initial priority of the thread function.
|
donatien |
0:e6ccf0b3d718
|
322
|
/// \param instances number of possible thread instances.
|
donatien |
0:e6ccf0b3d718
|
323
|
/// \param stacksz stack size (in bytes) requirements for the thread function.
|
donatien |
0:e6ccf0b3d718
|
324
|
/// \note CAN BE CHANGED: The parameters to \b osThreadDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
325
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
326
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
327
|
#define osThreadDef(name, priority, instances, stacksz) \
|
donatien |
0:e6ccf0b3d718
|
328
|
extern osThreadDef_t os_thread_def_##name
|
donatien |
0:e6ccf0b3d718
|
329
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
330
|
#define osThreadDef(name, priority, instances, stacksz) \
|
donatien |
0:e6ccf0b3d718
|
331
|
osThreadDef_t os_thread_def_##name = \
|
donatien |
0:e6ccf0b3d718
|
332
|
{ (name), (priority), (instances), (stacksz) }
|
donatien |
0:e6ccf0b3d718
|
333
|
#endif
|
donatien |
0:e6ccf0b3d718
|
334
|
|
donatien |
0:e6ccf0b3d718
|
335
|
/// Access a Thread defintion.
|
donatien |
0:e6ccf0b3d718
|
336
|
/// \param name name of the thread definition object.
|
donatien |
0:e6ccf0b3d718
|
337
|
/// \note CAN BE CHANGED: The parameter to \b osThread shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
338
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
339
|
#define osThread(name) \
|
donatien |
0:e6ccf0b3d718
|
340
|
&os_thread_def_##name
|
donatien |
0:e6ccf0b3d718
|
341
|
|
donatien |
0:e6ccf0b3d718
|
342
|
|
donatien |
0:e6ccf0b3d718
|
343
|
/// Create a thread and add it to Active Threads and set it to state READY.
|
donatien |
0:e6ccf0b3d718
|
344
|
/// \param[in] thread_def thread definition referenced with \ref osThread.
|
donatien |
0:e6ccf0b3d718
|
345
|
/// \param[in] argument pointer that is passed to the thread function as start argument.
|
donatien |
0:e6ccf0b3d718
|
346
|
/// \return thread ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
347
|
/// \note MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
348
|
osThreadId osThreadCreate (osThreadDef_t *thread_def, void *argument);
|
donatien |
0:e6ccf0b3d718
|
349
|
|
donatien |
0:e6ccf0b3d718
|
350
|
/// Return the thread ID of the current running thread.
|
donatien |
0:e6ccf0b3d718
|
351
|
/// \return thread ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
352
|
/// \note MUST REMAIN UNCHANGED: \b osThreadGetId shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
353
|
osThreadId osThreadGetId (void);
|
donatien |
0:e6ccf0b3d718
|
354
|
|
donatien |
0:e6ccf0b3d718
|
355
|
/// Terminate execution of a thread and remove it from Active Threads.
|
donatien |
0:e6ccf0b3d718
|
356
|
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
|
donatien |
0:e6ccf0b3d718
|
357
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
358
|
/// \note MUST REMAIN UNCHANGED: \b osThreadTerminate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
359
|
osStatus osThreadTerminate (osThreadId thread_id);
|
donatien |
0:e6ccf0b3d718
|
360
|
|
donatien |
0:e6ccf0b3d718
|
361
|
/// Pass control to next thread that is in state \b READY.
|
donatien |
0:e6ccf0b3d718
|
362
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
363
|
/// \note MUST REMAIN UNCHANGED: \b osThreadYield shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
364
|
osStatus osThreadYield (void);
|
donatien |
0:e6ccf0b3d718
|
365
|
|
donatien |
0:e6ccf0b3d718
|
366
|
/// Change priority of an active thread.
|
donatien |
0:e6ccf0b3d718
|
367
|
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
|
donatien |
0:e6ccf0b3d718
|
368
|
/// \param[in] priority new priority value for the thread function.
|
donatien |
0:e6ccf0b3d718
|
369
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
370
|
/// \note MUST REMAIN UNCHANGED: \b osThreadSetPriority shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
371
|
osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority);
|
donatien |
0:e6ccf0b3d718
|
372
|
|
donatien |
0:e6ccf0b3d718
|
373
|
/// Get current priority of an active thread.
|
donatien |
0:e6ccf0b3d718
|
374
|
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
|
donatien |
0:e6ccf0b3d718
|
375
|
/// \return current priority value of the thread function.
|
donatien |
0:e6ccf0b3d718
|
376
|
/// \note MUST REMAIN UNCHANGED: \b osThreadGetPriority shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
377
|
osPriority osThreadGetPriority (osThreadId thread_id);
|
donatien |
0:e6ccf0b3d718
|
378
|
|
donatien |
0:e6ccf0b3d718
|
379
|
|
donatien |
0:e6ccf0b3d718
|
380
|
|
donatien |
0:e6ccf0b3d718
|
381
|
// ==== Generic Wait Functions ====
|
donatien |
0:e6ccf0b3d718
|
382
|
|
donatien |
0:e6ccf0b3d718
|
383
|
/// Wait for Timeout (Time Delay)
|
donatien |
0:e6ccf0b3d718
|
384
|
/// \param[in] millisec time delay value
|
donatien |
0:e6ccf0b3d718
|
385
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
386
|
osStatus osDelay (uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
387
|
|
donatien |
0:e6ccf0b3d718
|
388
|
#if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available
|
donatien |
0:e6ccf0b3d718
|
389
|
|
donatien |
0:e6ccf0b3d718
|
390
|
/// Wait for Signal, Message, Mail, or Timeout
|
donatien |
0:e6ccf0b3d718
|
391
|
/// \param[in] millisec timeout value or 0 in case of no time-out
|
donatien |
0:e6ccf0b3d718
|
392
|
/// \return event that contains signal, message, or mail information or error code.
|
donatien |
0:e6ccf0b3d718
|
393
|
/// \note MUST REMAIN UNCHANGED: \b osWait shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
394
|
os_InRegs osEvent osWait (uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
395
|
|
donatien |
0:e6ccf0b3d718
|
396
|
#endif // Generic Wait available
|
donatien |
0:e6ccf0b3d718
|
397
|
|
donatien |
0:e6ccf0b3d718
|
398
|
|
donatien |
0:e6ccf0b3d718
|
399
|
// ==== Timer Management Functions ====
|
donatien |
0:e6ccf0b3d718
|
400
|
/// Define a Timer object.
|
donatien |
0:e6ccf0b3d718
|
401
|
/// \param name name of the timer object.
|
donatien |
0:e6ccf0b3d718
|
402
|
/// \param function name of the timer call back function.
|
donatien |
0:e6ccf0b3d718
|
403
|
/// \note CAN BE CHANGED: The parameter to \b osTimerDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
404
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
405
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
406
|
#define osTimerDef(name, function) \
|
donatien |
0:e6ccf0b3d718
|
407
|
extern osTimerDef_t os_timer_def_##name
|
donatien |
0:e6ccf0b3d718
|
408
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
409
|
#define osTimerDef(name, function) \
|
donatien |
0:e6ccf0b3d718
|
410
|
uint32_t os_timer_cb_##name[5]; \
|
donatien |
0:e6ccf0b3d718
|
411
|
osTimerDef_t os_timer_def_##name = \
|
donatien |
0:e6ccf0b3d718
|
412
|
{ (function), (os_timer_cb_##name) }
|
donatien |
0:e6ccf0b3d718
|
413
|
#endif
|
donatien |
0:e6ccf0b3d718
|
414
|
|
donatien |
0:e6ccf0b3d718
|
415
|
/// Access a Timer definition.
|
donatien |
0:e6ccf0b3d718
|
416
|
/// \param name name of the timer object.
|
donatien |
0:e6ccf0b3d718
|
417
|
/// \note CAN BE CHANGED: The parameter to \b osTimer shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
418
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
419
|
#define osTimer(name) \
|
donatien |
0:e6ccf0b3d718
|
420
|
&os_timer_def_##name
|
donatien |
0:e6ccf0b3d718
|
421
|
|
donatien |
0:e6ccf0b3d718
|
422
|
/// Create a timer.
|
donatien |
0:e6ccf0b3d718
|
423
|
/// \param[in] timer_def timer object referenced with \ref osTimer.
|
donatien |
0:e6ccf0b3d718
|
424
|
/// \param[in] type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior.
|
donatien |
0:e6ccf0b3d718
|
425
|
/// \param[in] argument argument to the timer call back function.
|
donatien |
0:e6ccf0b3d718
|
426
|
/// \return timer ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
427
|
/// \note MUST REMAIN UNCHANGED: \b osTimerCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
428
|
osTimerId osTimerCreate (osTimerDef_t *timer_def, os_timer_type type, void *argument);
|
donatien |
0:e6ccf0b3d718
|
429
|
|
donatien |
0:e6ccf0b3d718
|
430
|
/// Start or restart a timer.
|
donatien |
0:e6ccf0b3d718
|
431
|
/// \param[in] timer_id timer ID obtained by \ref osTimerCreate.
|
donatien |
0:e6ccf0b3d718
|
432
|
/// \param[in] millisec time delay value of the timer.
|
donatien |
0:e6ccf0b3d718
|
433
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
434
|
/// \note MUST REMAIN UNCHANGED: \b osTimerStart shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
435
|
osStatus osTimerStart (osTimerId timer_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
436
|
|
donatien |
0:e6ccf0b3d718
|
437
|
/// Stop the timer.
|
donatien |
0:e6ccf0b3d718
|
438
|
/// \param[in] timer_id timer ID obtained by \ref osTimerCreate.
|
donatien |
0:e6ccf0b3d718
|
439
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
440
|
/// \note MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
441
|
osStatus osTimerStop (osTimerId timer_id);
|
donatien |
0:e6ccf0b3d718
|
442
|
|
donatien |
0:e6ccf0b3d718
|
443
|
|
donatien |
0:e6ccf0b3d718
|
444
|
// ==== Signal Management ====
|
donatien |
0:e6ccf0b3d718
|
445
|
|
donatien |
0:e6ccf0b3d718
|
446
|
/// Set the specified Signal Flags of an active thread.
|
donatien |
0:e6ccf0b3d718
|
447
|
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
|
donatien |
0:e6ccf0b3d718
|
448
|
/// \param[in] signals specifies the signal flags of the thread that should be set.
|
donatien |
0:e6ccf0b3d718
|
449
|
/// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
|
donatien |
0:e6ccf0b3d718
|
450
|
/// \note MUST REMAIN UNCHANGED: \b osSignalSet shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
451
|
int32_t osSignalSet (osThreadId thread_id, int32_t signal);
|
donatien |
0:e6ccf0b3d718
|
452
|
|
donatien |
0:e6ccf0b3d718
|
453
|
/// Clear the specified Signal Flags of an active thread.
|
donatien |
0:e6ccf0b3d718
|
454
|
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
|
donatien |
0:e6ccf0b3d718
|
455
|
/// \param[in] signals specifies the signal flags of the thread that shall be cleared.
|
donatien |
0:e6ccf0b3d718
|
456
|
/// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
|
donatien |
0:e6ccf0b3d718
|
457
|
/// \note MUST REMAIN UNCHANGED: \b osSignalClear shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
458
|
int32_t osSignalClear (osThreadId thread_id, int32_t signal);
|
donatien |
0:e6ccf0b3d718
|
459
|
|
donatien |
0:e6ccf0b3d718
|
460
|
/// Get Signal Flags status of an active thread.
|
donatien |
0:e6ccf0b3d718
|
461
|
/// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
|
donatien |
0:e6ccf0b3d718
|
462
|
/// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
|
donatien |
0:e6ccf0b3d718
|
463
|
/// \note MUST REMAIN UNCHANGED: \b osSignalGet shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
464
|
int32_t osSignalGet (osThreadId thread_id);
|
donatien |
0:e6ccf0b3d718
|
465
|
|
donatien |
0:e6ccf0b3d718
|
466
|
/// Wait for one or more Signal Flags to become signaled for the current \b RUNNING thread.
|
donatien |
0:e6ccf0b3d718
|
467
|
/// \param[in] signals wait until all specified signal flags set or 0 for any single signal flag.
|
donatien |
0:e6ccf0b3d718
|
468
|
/// \param[in] millisec timeout value or 0 in case of no time-out.
|
donatien |
0:e6ccf0b3d718
|
469
|
/// \return event flag information or error code.
|
donatien |
0:e6ccf0b3d718
|
470
|
/// \note MUST REMAIN UNCHANGED: \b osSignalWait shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
471
|
os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
472
|
|
donatien |
0:e6ccf0b3d718
|
473
|
|
donatien |
0:e6ccf0b3d718
|
474
|
// ==== Mutex Management ====
|
donatien |
0:e6ccf0b3d718
|
475
|
|
donatien |
0:e6ccf0b3d718
|
476
|
/// Define a Mutex.
|
donatien |
0:e6ccf0b3d718
|
477
|
/// \param name name of the mutex object.
|
donatien |
0:e6ccf0b3d718
|
478
|
/// \note CAN BE CHANGED: The parameter to \b osMutexDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
479
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
480
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
481
|
#define osMutexDef(name) \
|
donatien |
0:e6ccf0b3d718
|
482
|
extern osMutexDef_t os_mutex_def_##name
|
donatien |
0:e6ccf0b3d718
|
483
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
484
|
#define osMutexDef(name) \
|
donatien |
0:e6ccf0b3d718
|
485
|
uint32_t os_mutex_cb_##name[3]; \
|
donatien |
0:e6ccf0b3d718
|
486
|
osMutexDef_t os_mutex_def_##name = { (os_mutex_cb_##name) }
|
donatien |
0:e6ccf0b3d718
|
487
|
#endif
|
donatien |
0:e6ccf0b3d718
|
488
|
|
donatien |
0:e6ccf0b3d718
|
489
|
/// Access a Mutex defintion.
|
donatien |
0:e6ccf0b3d718
|
490
|
/// \param name name of the mutex object.
|
donatien |
0:e6ccf0b3d718
|
491
|
/// \note CAN BE CHANGED: The parameter to \b osMutex shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
492
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
493
|
#define osMutex(name) \
|
donatien |
0:e6ccf0b3d718
|
494
|
&os_mutex_def_##name
|
donatien |
0:e6ccf0b3d718
|
495
|
|
donatien |
0:e6ccf0b3d718
|
496
|
/// Create and Initialize a Mutex object
|
donatien |
0:e6ccf0b3d718
|
497
|
/// \param[in] mutex_def mutex definition referenced with \ref osMutex.
|
donatien |
0:e6ccf0b3d718
|
498
|
/// \return mutex ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
499
|
/// \note MUST REMAIN UNCHANGED: \b osMutexCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
500
|
osMutexId osMutexCreate (osMutexDef_t *mutex_def);
|
donatien |
0:e6ccf0b3d718
|
501
|
|
donatien |
0:e6ccf0b3d718
|
502
|
/// Wait until a Mutex becomes available
|
donatien |
0:e6ccf0b3d718
|
503
|
/// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate.
|
donatien |
0:e6ccf0b3d718
|
504
|
/// \param[in] millisec timeout value or 0 in case of no time-out.
|
donatien |
0:e6ccf0b3d718
|
505
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
506
|
/// \note MUST REMAIN UNCHANGED: \b osMutexWait shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
507
|
osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
508
|
|
donatien |
0:e6ccf0b3d718
|
509
|
/// Release a Mutex that was obtained by \ref osMutexWait
|
donatien |
0:e6ccf0b3d718
|
510
|
/// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate.
|
donatien |
0:e6ccf0b3d718
|
511
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
512
|
/// \note MUST REMAIN UNCHANGED: \b osMutexRelease shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
513
|
osStatus osMutexRelease (osMutexId mutex_id);
|
donatien |
0:e6ccf0b3d718
|
514
|
|
donatien |
0:e6ccf0b3d718
|
515
|
|
donatien |
0:e6ccf0b3d718
|
516
|
// ==== Semaphore Management Functions ====
|
donatien |
0:e6ccf0b3d718
|
517
|
|
donatien |
0:e6ccf0b3d718
|
518
|
#if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0)) // Semaphore available
|
donatien |
0:e6ccf0b3d718
|
519
|
|
donatien |
0:e6ccf0b3d718
|
520
|
/// Define a Semaphore object.
|
donatien |
0:e6ccf0b3d718
|
521
|
/// \param name name of the semaphore object.
|
donatien |
0:e6ccf0b3d718
|
522
|
/// \note CAN BE CHANGED: The parameter to \b osSemaphoreDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
523
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
524
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
525
|
#define osSemaphoreDef(name) \
|
donatien |
0:e6ccf0b3d718
|
526
|
extern osSemaphoreDef_t os_semaphore_def_##name
|
donatien |
0:e6ccf0b3d718
|
527
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
528
|
#define osSemaphoreDef(name) \
|
donatien |
0:e6ccf0b3d718
|
529
|
uint32_t os_semaphore_cb_##name[2]; \
|
donatien |
0:e6ccf0b3d718
|
530
|
osSemaphoreDef_t os_semaphore_def_##name = { (os_semaphore_cb_##name) }
|
donatien |
0:e6ccf0b3d718
|
531
|
#endif
|
donatien |
0:e6ccf0b3d718
|
532
|
|
donatien |
0:e6ccf0b3d718
|
533
|
/// Access a Semaphore definition.
|
donatien |
0:e6ccf0b3d718
|
534
|
/// \param name name of the semaphore object.
|
donatien |
0:e6ccf0b3d718
|
535
|
/// \note CAN BE CHANGED: The parameter to \b osSemaphore shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
536
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
537
|
#define osSemaphore(name) \
|
donatien |
0:e6ccf0b3d718
|
538
|
&os_semaphore_def_##name
|
donatien |
0:e6ccf0b3d718
|
539
|
|
donatien |
0:e6ccf0b3d718
|
540
|
/// Create and Initialize a Semaphore object used for managing resources
|
donatien |
0:e6ccf0b3d718
|
541
|
/// \param[in] semaphore_def semaphore definition referenced with \ref osSemaphore.
|
donatien |
0:e6ccf0b3d718
|
542
|
/// \param[in] count number of available resources.
|
donatien |
0:e6ccf0b3d718
|
543
|
/// \return semaphore ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
544
|
/// \note MUST REMAIN UNCHANGED: \b osSemaphoreCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
545
|
osSemaphoreId osSemaphoreCreate (osSemaphoreDef_t *semaphore_def, int32_t count);
|
donatien |
0:e6ccf0b3d718
|
546
|
|
donatien |
0:e6ccf0b3d718
|
547
|
/// Wait until a Semaphore token becomes available
|
donatien |
0:e6ccf0b3d718
|
548
|
/// \param[in] semaphore_id semaphore object referenced with \ref osSemaphore.
|
donatien |
0:e6ccf0b3d718
|
549
|
/// \param[in] millisec timeout value or 0 in case of no time-out.
|
donatien |
0:e6ccf0b3d718
|
550
|
/// \return number of available tokens, or -1 in case of incorrect parameters.
|
donatien |
0:e6ccf0b3d718
|
551
|
/// \note MUST REMAIN UNCHANGED: \b osSemaphoreWait shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
552
|
int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
553
|
|
donatien |
0:e6ccf0b3d718
|
554
|
/// Release a Semaphore token
|
donatien |
0:e6ccf0b3d718
|
555
|
/// \param[in] semaphore_id semaphore object referenced with \ref osSemaphore.
|
donatien |
0:e6ccf0b3d718
|
556
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
557
|
/// \note MUST REMAIN UNCHANGED: \b osSemaphoreRelease shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
558
|
osStatus osSemaphoreRelease (osSemaphoreId semaphore_id);
|
donatien |
0:e6ccf0b3d718
|
559
|
|
donatien |
0:e6ccf0b3d718
|
560
|
#endif // Semaphore available
|
donatien |
0:e6ccf0b3d718
|
561
|
|
donatien |
0:e6ccf0b3d718
|
562
|
// ==== Memory Pool Management Functions ====
|
donatien |
0:e6ccf0b3d718
|
563
|
|
donatien |
0:e6ccf0b3d718
|
564
|
#if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available
|
donatien |
0:e6ccf0b3d718
|
565
|
|
donatien |
0:e6ccf0b3d718
|
566
|
/// \brief Define a Memory Pool.
|
donatien |
0:e6ccf0b3d718
|
567
|
/// \param name name of the memory pool.
|
donatien |
0:e6ccf0b3d718
|
568
|
/// \param no maximum number of objects (elements) in the memory pool.
|
donatien |
0:e6ccf0b3d718
|
569
|
/// \param type data type of a single object (element).
|
donatien |
0:e6ccf0b3d718
|
570
|
/// \note CAN BE CHANGED: The parameter to \b osPoolDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
571
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
572
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
573
|
#define osPoolDef(name, no, type) \
|
donatien |
0:e6ccf0b3d718
|
574
|
extern osPoolDef_t os_pool_def_##name
|
donatien |
0:e6ccf0b3d718
|
575
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
576
|
#define osPoolDef(name, no, type) \
|
donatien |
0:e6ccf0b3d718
|
577
|
uint32_t os_pool_m_##name[3+((sizeof(type)+3)/4)*(no)]; \
|
donatien |
0:e6ccf0b3d718
|
578
|
osPoolDef_t os_pool_def_##name = \
|
donatien |
0:e6ccf0b3d718
|
579
|
{ (no), sizeof(type), (os_pool_m_##name) }
|
donatien |
0:e6ccf0b3d718
|
580
|
#endif
|
donatien |
0:e6ccf0b3d718
|
581
|
|
donatien |
0:e6ccf0b3d718
|
582
|
/// \brief Access a Memory Pool definition.
|
donatien |
0:e6ccf0b3d718
|
583
|
/// \param name name of the memory pool
|
donatien |
0:e6ccf0b3d718
|
584
|
/// \note CAN BE CHANGED: The parameter to \b osPool shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
585
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
586
|
#define osPool(name) \
|
donatien |
0:e6ccf0b3d718
|
587
|
&os_pool_def_##name
|
donatien |
0:e6ccf0b3d718
|
588
|
|
donatien |
0:e6ccf0b3d718
|
589
|
/// Create and Initialize a memory pool
|
donatien |
0:e6ccf0b3d718
|
590
|
/// \param[in] pool_def memory pool definition referenced with \ref osPool.
|
donatien |
0:e6ccf0b3d718
|
591
|
/// \return memory pool ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
592
|
/// \note MUST REMAIN UNCHANGED: \b osPoolCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
593
|
osPoolId osPoolCreate (osPoolDef_t *pool_def);
|
donatien |
0:e6ccf0b3d718
|
594
|
|
donatien |
0:e6ccf0b3d718
|
595
|
/// Allocate a memory block from a memory pool
|
donatien |
0:e6ccf0b3d718
|
596
|
/// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate.
|
donatien |
0:e6ccf0b3d718
|
597
|
/// \return address of the allocated memory block or NULL in case of no memory available.
|
donatien |
0:e6ccf0b3d718
|
598
|
/// \note MUST REMAIN UNCHANGED: \b osPoolAlloc shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
599
|
void *osPoolAlloc (osPoolId pool_id);
|
donatien |
0:e6ccf0b3d718
|
600
|
|
donatien |
0:e6ccf0b3d718
|
601
|
/// Allocate a memory block from a memory pool and set memory block to zero
|
donatien |
0:e6ccf0b3d718
|
602
|
/// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate.
|
donatien |
0:e6ccf0b3d718
|
603
|
/// \return address of the allocated memory block or NULL in case of no memory available.
|
donatien |
0:e6ccf0b3d718
|
604
|
/// \note MUST REMAIN UNCHANGED: \b osPoolCAlloc shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
605
|
void *osPoolCAlloc (osPoolId pool_id);
|
donatien |
0:e6ccf0b3d718
|
606
|
|
donatien |
0:e6ccf0b3d718
|
607
|
/// Return an allocated memory block back to a specific memory pool
|
donatien |
0:e6ccf0b3d718
|
608
|
/// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate.
|
donatien |
0:e6ccf0b3d718
|
609
|
/// \param[in] block address of the allocated memory block that is returned to the memory pool.
|
donatien |
0:e6ccf0b3d718
|
610
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
611
|
/// \note MUST REMAIN UNCHANGED: \b osPoolFree shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
612
|
osStatus osPoolFree (osPoolId pool_id, void *block);
|
donatien |
0:e6ccf0b3d718
|
613
|
|
donatien |
0:e6ccf0b3d718
|
614
|
#endif // Memory Pool Management available
|
donatien |
0:e6ccf0b3d718
|
615
|
|
donatien |
0:e6ccf0b3d718
|
616
|
|
donatien |
0:e6ccf0b3d718
|
617
|
// ==== Message Queue Management Functions ====
|
donatien |
0:e6ccf0b3d718
|
618
|
|
donatien |
0:e6ccf0b3d718
|
619
|
#if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queues available
|
donatien |
0:e6ccf0b3d718
|
620
|
|
donatien |
0:e6ccf0b3d718
|
621
|
/// \brief Create a Message Queue Definition.
|
donatien |
0:e6ccf0b3d718
|
622
|
/// \param name name of the queue.
|
donatien |
0:e6ccf0b3d718
|
623
|
/// \param queue_sz maximum number of messages in the queue.
|
donatien |
0:e6ccf0b3d718
|
624
|
/// \param type data type of a single message element (for debugger).
|
donatien |
0:e6ccf0b3d718
|
625
|
/// \note CAN BE CHANGED: The parameter to \b osMessageQDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
626
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
627
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
628
|
#define osMessageQDef(name, queue_sz, type) \
|
donatien |
0:e6ccf0b3d718
|
629
|
extern osMessageQDef_t os_messageQ_def_##name
|
donatien |
0:e6ccf0b3d718
|
630
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
631
|
#define osMessageQDef(name, queue_sz, type) \
|
donatien |
0:e6ccf0b3d718
|
632
|
uint32_t os_messageQ_q_##name[4+(queue_sz)]; \
|
donatien |
0:e6ccf0b3d718
|
633
|
osMessageQDef_t os_messageQ_def_##name = \
|
donatien |
0:e6ccf0b3d718
|
634
|
{ (queue_sz), (os_messageQ_q_##name) }
|
donatien |
0:e6ccf0b3d718
|
635
|
#endif
|
donatien |
0:e6ccf0b3d718
|
636
|
|
donatien |
0:e6ccf0b3d718
|
637
|
/// \brief Access a Message Queue Definition.
|
donatien |
0:e6ccf0b3d718
|
638
|
/// \param name name of the queue
|
donatien |
0:e6ccf0b3d718
|
639
|
/// \note CAN BE CHANGED: The parameter to \b osMessageQ shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
640
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
641
|
#define osMessageQ(name) \
|
donatien |
0:e6ccf0b3d718
|
642
|
&os_messageQ_def_##name
|
donatien |
0:e6ccf0b3d718
|
643
|
|
donatien |
0:e6ccf0b3d718
|
644
|
/// Create and Initialize a Message Queue.
|
donatien |
0:e6ccf0b3d718
|
645
|
/// \param[in] queue_def queue definition referenced with \ref osMessageQ.
|
donatien |
0:e6ccf0b3d718
|
646
|
/// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL.
|
donatien |
0:e6ccf0b3d718
|
647
|
/// \return message queue ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
648
|
/// \note MUST REMAIN UNCHANGED: \b osMessageCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
649
|
osMessageQId osMessageCreate (osMessageQDef_t *queue_def, osThreadId thread_id);
|
donatien |
0:e6ccf0b3d718
|
650
|
|
donatien |
0:e6ccf0b3d718
|
651
|
/// Put a Message to a Queue.
|
donatien |
0:e6ccf0b3d718
|
652
|
/// \param[in] queue_id message queue ID obtained with \ref osMessageCreate.
|
donatien |
0:e6ccf0b3d718
|
653
|
/// \param[in] info message information.
|
donatien |
0:e6ccf0b3d718
|
654
|
/// \param[in] millisec timeout value or 0 in case of no time-out.
|
donatien |
0:e6ccf0b3d718
|
655
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
656
|
/// \note MUST REMAIN UNCHANGED: \b osMessagePut shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
657
|
osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
658
|
|
donatien |
0:e6ccf0b3d718
|
659
|
/// Get a Message or Wait for a Message from a Queue.
|
donatien |
0:e6ccf0b3d718
|
660
|
/// \param[in] queue_id message queue ID obtained with \ref osMessageCreate.
|
donatien |
0:e6ccf0b3d718
|
661
|
/// \param[in] millisec timeout value or 0 in case of no time-out.
|
donatien |
0:e6ccf0b3d718
|
662
|
/// \return event information that includes status code.
|
donatien |
0:e6ccf0b3d718
|
663
|
/// \note MUST REMAIN UNCHANGED: \b osMessageGet shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
664
|
os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
665
|
|
donatien |
0:e6ccf0b3d718
|
666
|
#endif // Message Queues available
|
donatien |
0:e6ccf0b3d718
|
667
|
|
donatien |
0:e6ccf0b3d718
|
668
|
|
donatien |
0:e6ccf0b3d718
|
669
|
// ==== Mail Queue Management Functions ====
|
donatien |
0:e6ccf0b3d718
|
670
|
|
donatien |
0:e6ccf0b3d718
|
671
|
#if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queues available
|
donatien |
0:e6ccf0b3d718
|
672
|
|
donatien |
0:e6ccf0b3d718
|
673
|
/// \brief Create a Mail Queue Definition
|
donatien |
0:e6ccf0b3d718
|
674
|
/// \param name name of the queue
|
donatien |
0:e6ccf0b3d718
|
675
|
/// \param queue_sz maximum number of messages in queue
|
donatien |
0:e6ccf0b3d718
|
676
|
/// \param type data type of a single message element
|
donatien |
0:e6ccf0b3d718
|
677
|
/// \note CAN BE CHANGED: The parameter to \b osMailQDef shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
678
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
679
|
#if defined (osObjectsExternal) // object is external
|
donatien |
0:e6ccf0b3d718
|
680
|
#define osMailQDef(name, queue_sz, type) \
|
donatien |
0:e6ccf0b3d718
|
681
|
extern osMailQDef_t os_mailQ_def_##name
|
donatien |
0:e6ccf0b3d718
|
682
|
#else // define the object
|
donatien |
0:e6ccf0b3d718
|
683
|
#define osMailQDef(name, queue_sz, type) \
|
donatien |
0:e6ccf0b3d718
|
684
|
uint32_t os_mailQ_q_##name[4+(queue_sz)]; \
|
donatien |
0:e6ccf0b3d718
|
685
|
uint32_t os_mailQ_m_##name[3+((sizeof(type)+3)/4)*(queue_sz)]; \
|
donatien |
0:e6ccf0b3d718
|
686
|
void * os_mailQ_p_##name[2] = { (os_mailQ_q_##name), os_mailQ_m_##name }; \
|
donatien |
0:e6ccf0b3d718
|
687
|
osMailQDef_t os_mailQ_def_##name = \
|
donatien |
0:e6ccf0b3d718
|
688
|
{ (queue_sz), sizeof(type), (os_mailQ_p_##name) }
|
donatien |
0:e6ccf0b3d718
|
689
|
#endif
|
donatien |
0:e6ccf0b3d718
|
690
|
|
donatien |
0:e6ccf0b3d718
|
691
|
/// \brief Access a Mail Queue Definition
|
donatien |
0:e6ccf0b3d718
|
692
|
/// \param name name of the queue
|
donatien |
0:e6ccf0b3d718
|
693
|
/// \note CAN BE CHANGED: The parameter to \b osMailQ shall be consistent but the
|
donatien |
0:e6ccf0b3d718
|
694
|
/// macro body is implementation specific in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
695
|
#define osMailQ(name) \
|
donatien |
0:e6ccf0b3d718
|
696
|
&os_mailQ_def_##name
|
donatien |
0:e6ccf0b3d718
|
697
|
|
donatien |
0:e6ccf0b3d718
|
698
|
/// Create and Initialize mail queue
|
donatien |
0:e6ccf0b3d718
|
699
|
/// \param[in] queue_def reference to the mail queue definition obtain with \ref osMailQ
|
donatien |
0:e6ccf0b3d718
|
700
|
/// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL.
|
donatien |
0:e6ccf0b3d718
|
701
|
/// \return mail queue ID for reference by other functions or NULL in case of error.
|
donatien |
0:e6ccf0b3d718
|
702
|
/// \note MUST REMAIN UNCHANGED: \b osMailCreate shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
703
|
osMailQId osMailCreate (osMailQDef_t *queue_def, osThreadId thread_id);
|
donatien |
0:e6ccf0b3d718
|
704
|
|
donatien |
0:e6ccf0b3d718
|
705
|
/// Allocate a memory block from a mail
|
donatien |
0:e6ccf0b3d718
|
706
|
/// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
|
donatien |
0:e6ccf0b3d718
|
707
|
/// \param[in] millisec timeout value or 0 in case of no time-out
|
donatien |
0:e6ccf0b3d718
|
708
|
/// \return pointer to memory block that can be filled with mail or NULL in case error.
|
donatien |
0:e6ccf0b3d718
|
709
|
/// \note MUST REMAIN UNCHANGED: \b osMailAlloc shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
710
|
void *osMailAlloc (osMailQId queue_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
711
|
|
donatien |
0:e6ccf0b3d718
|
712
|
/// Allocate a memory block from a mail and set memory block to zero
|
donatien |
0:e6ccf0b3d718
|
713
|
/// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
|
donatien |
0:e6ccf0b3d718
|
714
|
/// \param[in] millisec timeout value or 0 in case of no time-out
|
donatien |
0:e6ccf0b3d718
|
715
|
/// \return pointer to memory block that can shall filled with mail or NULL in case error.
|
donatien |
0:e6ccf0b3d718
|
716
|
/// \note MUST REMAIN UNCHANGED: \b osMailCAlloc shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
717
|
void *osMailCAlloc (osMailQId queue_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
718
|
|
donatien |
0:e6ccf0b3d718
|
719
|
/// Put a mail to a queue
|
donatien |
0:e6ccf0b3d718
|
720
|
/// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
|
donatien |
0:e6ccf0b3d718
|
721
|
/// \param[in] mail memory block previously allocated with \ref osMailAlloc or \ref osMailCAlloc.
|
donatien |
0:e6ccf0b3d718
|
722
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
723
|
/// \note MUST REMAIN UNCHANGED: \b osMailPut shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
724
|
osStatus osMailPut (osMailQId queue_id, void *mail);
|
donatien |
0:e6ccf0b3d718
|
725
|
|
donatien |
0:e6ccf0b3d718
|
726
|
/// Get a mail from a queue
|
donatien |
0:e6ccf0b3d718
|
727
|
/// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
|
donatien |
0:e6ccf0b3d718
|
728
|
/// \param[in] millisec timeout value or 0 in case of no time-out
|
donatien |
0:e6ccf0b3d718
|
729
|
/// \return event that contains mail information or error code.
|
donatien |
0:e6ccf0b3d718
|
730
|
/// \note MUST REMAIN UNCHANGED: \b osMailGet shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
731
|
os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec);
|
donatien |
0:e6ccf0b3d718
|
732
|
|
donatien |
0:e6ccf0b3d718
|
733
|
/// Free a memory block from a mail
|
donatien |
0:e6ccf0b3d718
|
734
|
/// \param[in] queue_id mail queue ID obtained with \ref osMailCreate.
|
donatien |
0:e6ccf0b3d718
|
735
|
/// \param[in] mail pointer to the memory block that was obtained with \ref osMailGet.
|
donatien |
0:e6ccf0b3d718
|
736
|
/// \return status code that indicates the execution status of the function.
|
donatien |
0:e6ccf0b3d718
|
737
|
/// \note MUST REMAIN UNCHANGED: \b osMailFree shall be consistent in every CMSIS-RTOS.
|
donatien |
0:e6ccf0b3d718
|
738
|
osStatus osMailFree (osMailQId queue_id, void *mail);
|
donatien |
0:e6ccf0b3d718
|
739
|
|
donatien |
0:e6ccf0b3d718
|
740
|
#endif // Mail Queues available
|
donatien |
0:e6ccf0b3d718
|
741
|
|
donatien |
0:e6ccf0b3d718
|
742
|
/// Set Thread Error (for Create funcions which return IDs)
|
donatien |
0:e6ccf0b3d718
|
743
|
extern void sysThreadError(osStatus status);
|
donatien |
0:e6ccf0b3d718
|
744
|
|
donatien |
0:e6ccf0b3d718
|
745
|
#ifdef __cplusplus
|
donatien |
0:e6ccf0b3d718
|
746
|
}
|
donatien |
0:e6ccf0b3d718
|
747
|
#endif
|
donatien |
0:e6ccf0b3d718
|
748
|
|
donatien |
0:e6ccf0b3d718
|
749
|
#endif // _CMSIS_OS_H
|