Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more

Deprecated

This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.

Committer:
mbed_official
Date:
Wed Jun 17 11:15:10 2015 +0100
Revision:
85:ef0a22cdf839
Parent:
49:77c8e4604045
Child:
92:bc9729798a19
Synchronized with git revision c33e334a2273b85d12a0bf31aa2f0f86a205ee4b

Full URL: https://github.com/mbedmicro/mbed/commit/c33e334a2273b85d12a0bf31aa2f0f86a205ee4b/

RZ_A1H - Modify the OS track acquisition method

Who changed what in which revision?

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