Stanislav Silnitskiy / rtos
Committer:
mailgate_user
Date:
Sun Jun 24 19:47:00 2012 +0000
Revision:
0:ea15e955433d
N threads cut down to 4, stack size cut down to 1024

Who changed what in which revision?

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