Code for our FYDP -only one IMU works right now -RTOS is working

Dependencies:   mbed

Committer:
majik
Date:
Wed Mar 18 22:23:48 2015 +0000
Revision:
0:964eb6a2ef00
This is our FYDP code, but only one IMU works with the RTOS.

Who changed what in which revision?

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