sdf

Dependencies:   mbed-rtos

Fork of mbed-rtos by mbed official

Committer:
jboettcher
Date:
Sat Dec 03 02:40:18 2016 +0000
Revision:
124:6f44319dda9b
Parent:
80:2dab120a94c2
sdf;

Who changed what in which revision?

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