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