mbed rtos - modified for the final project of the course "Advanced Operating Systems"

Dependents:   aos_mbed

Fork of mbed-rtos by mbed official

Committer:
aos
Date:
Sun Feb 02 10:44:57 2014 +0000
Revision:
16:3474615e591f
Parent:
13:869ef732a8a2
Final Project V1: Integrated WAV player + File management via ethernet connection

Who changed what in which revision?

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