Anasse Abdoul / Mbed 2 deprecated Test_MPU6050

Dependencies:   mbed

Committer:
anasse
Date:
Thu Mar 31 07:43:50 2022 +0000
Revision:
0:a59a3d743804
vers0

Who changed what in which revision?

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