Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.
Dependencies: EthernetInterface
Fork of mbed-rtos by
rtx_ca/cmsis_os.h@48:e9a2c7cb57a4, 2014-11-06 (annotated)
- Committer:
- mbed_official
- Date:
- Thu Nov 06 11:00:33 2014 +0000
- Revision:
- 48:e9a2c7cb57a4
Synchronized with git revision 8724eb616b6e07a3bd111d3022652eb5bbefe9b7
Full URL: https://github.com/mbedmicro/mbed/commit/8724eb616b6e07a3bd111d3022652eb5bbefe9b7/
[RZ/A1H] mbed-RZ first release
Who changed what in which revision?
User | Revision | Line number | New 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 | 48:e9a2c7cb57a4 | 267 | } osThreadDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 268 | |
mbed_official | 48:e9a2c7cb57a4 | 269 | /// Timer Definition structure contains timer parameters. |
mbed_official | 48:e9a2c7cb57a4 | 270 | /// \note CAN BE CHANGED: \b os_timer_def is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 271 | typedef struct os_timer_def { |
mbed_official | 48:e9a2c7cb57a4 | 272 | os_ptimer ptimer; ///< start address of a timer function |
mbed_official | 48:e9a2c7cb57a4 | 273 | void *timer; ///< pointer to internal data |
mbed_official | 48:e9a2c7cb57a4 | 274 | } osTimerDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 275 | |
mbed_official | 48:e9a2c7cb57a4 | 276 | /// Mutex Definition structure contains setup information for a mutex. |
mbed_official | 48:e9a2c7cb57a4 | 277 | /// \note CAN BE CHANGED: \b os_mutex_def is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 278 | typedef struct os_mutex_def { |
mbed_official | 48:e9a2c7cb57a4 | 279 | void *mutex; ///< pointer to internal data |
mbed_official | 48:e9a2c7cb57a4 | 280 | } osMutexDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 281 | |
mbed_official | 48:e9a2c7cb57a4 | 282 | /// Semaphore Definition structure contains setup information for a semaphore. |
mbed_official | 48:e9a2c7cb57a4 | 283 | /// \note CAN BE CHANGED: \b os_semaphore_def is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 284 | typedef struct os_semaphore_def { |
mbed_official | 48:e9a2c7cb57a4 | 285 | void *semaphore; ///< pointer to internal data |
mbed_official | 48:e9a2c7cb57a4 | 286 | } osSemaphoreDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 287 | |
mbed_official | 48:e9a2c7cb57a4 | 288 | /// Definition structure for memory block allocation. |
mbed_official | 48:e9a2c7cb57a4 | 289 | /// \note CAN BE CHANGED: \b os_pool_def is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 290 | typedef struct os_pool_def { |
mbed_official | 48:e9a2c7cb57a4 | 291 | uint32_t pool_sz; ///< number of items (elements) in the pool |
mbed_official | 48:e9a2c7cb57a4 | 292 | uint32_t item_sz; ///< size of an item |
mbed_official | 48:e9a2c7cb57a4 | 293 | void *pool; ///< pointer to memory for pool |
mbed_official | 48:e9a2c7cb57a4 | 294 | } osPoolDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 295 | |
mbed_official | 48:e9a2c7cb57a4 | 296 | /// Definition structure for message queue. |
mbed_official | 48:e9a2c7cb57a4 | 297 | /// \note CAN BE CHANGED: \b os_messageQ_def is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 298 | typedef struct os_messageQ_def { |
mbed_official | 48:e9a2c7cb57a4 | 299 | uint32_t queue_sz; ///< number of elements in the queue |
mbed_official | 48:e9a2c7cb57a4 | 300 | void *pool; ///< memory array for messages |
mbed_official | 48:e9a2c7cb57a4 | 301 | } osMessageQDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 302 | |
mbed_official | 48:e9a2c7cb57a4 | 303 | /// Definition structure for mail queue. |
mbed_official | 48:e9a2c7cb57a4 | 304 | /// \note CAN BE CHANGED: \b os_mailQ_def is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 305 | typedef struct os_mailQ_def { |
mbed_official | 48:e9a2c7cb57a4 | 306 | uint32_t queue_sz; ///< number of elements in the queue |
mbed_official | 48:e9a2c7cb57a4 | 307 | uint32_t item_sz; ///< size of an item |
mbed_official | 48:e9a2c7cb57a4 | 308 | void *pool; ///< memory array for mail |
mbed_official | 48:e9a2c7cb57a4 | 309 | } osMailQDef_t; |
mbed_official | 48:e9a2c7cb57a4 | 310 | |
mbed_official | 48:e9a2c7cb57a4 | 311 | /// Event structure contains detailed information about an event. |
mbed_official | 48:e9a2c7cb57a4 | 312 | /// \note MUST REMAIN UNCHANGED: \b os_event shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 313 | /// However the struct may be extended at the end. |
mbed_official | 48:e9a2c7cb57a4 | 314 | typedef struct { |
mbed_official | 48:e9a2c7cb57a4 | 315 | osStatus status; ///< status code: event or error information |
mbed_official | 48:e9a2c7cb57a4 | 316 | union { |
mbed_official | 48:e9a2c7cb57a4 | 317 | uint32_t v; ///< message as 32-bit value |
mbed_official | 48:e9a2c7cb57a4 | 318 | void *p; ///< message or mail as void pointer |
mbed_official | 48:e9a2c7cb57a4 | 319 | int32_t signals; ///< signal flags |
mbed_official | 48:e9a2c7cb57a4 | 320 | } value; ///< event value |
mbed_official | 48:e9a2c7cb57a4 | 321 | union { |
mbed_official | 48:e9a2c7cb57a4 | 322 | osMailQId mail_id; ///< mail id obtained by \ref osMailCreate |
mbed_official | 48:e9a2c7cb57a4 | 323 | osMessageQId message_id; ///< message id obtained by \ref osMessageCreate |
mbed_official | 48:e9a2c7cb57a4 | 324 | } def; ///< event definition |
mbed_official | 48:e9a2c7cb57a4 | 325 | } osEvent; |
mbed_official | 48:e9a2c7cb57a4 | 326 | |
mbed_official | 48:e9a2c7cb57a4 | 327 | |
mbed_official | 48:e9a2c7cb57a4 | 328 | // ==== Kernel Control Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 329 | |
mbed_official | 48:e9a2c7cb57a4 | 330 | /// Initialize the RTOS Kernel for creating objects. |
mbed_official | 48:e9a2c7cb57a4 | 331 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 332 | /// \note MUST REMAIN UNCHANGED: \b osKernelInitialize shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 333 | osStatus osKernelInitialize (void); |
mbed_official | 48:e9a2c7cb57a4 | 334 | |
mbed_official | 48:e9a2c7cb57a4 | 335 | /// Start the RTOS Kernel. |
mbed_official | 48:e9a2c7cb57a4 | 336 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 337 | /// \note MUST REMAIN UNCHANGED: \b osKernelStart shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 338 | osStatus osKernelStart (void); |
mbed_official | 48:e9a2c7cb57a4 | 339 | |
mbed_official | 48:e9a2c7cb57a4 | 340 | /// Check if the RTOS kernel is already started. |
mbed_official | 48:e9a2c7cb57a4 | 341 | /// \note MUST REMAIN UNCHANGED: \b osKernelRunning shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 342 | /// \return 0 RTOS is not started, 1 RTOS is started. |
mbed_official | 48:e9a2c7cb57a4 | 343 | int32_t osKernelRunning(void); |
mbed_official | 48:e9a2c7cb57a4 | 344 | |
mbed_official | 48:e9a2c7cb57a4 | 345 | |
mbed_official | 48:e9a2c7cb57a4 | 346 | // ==== Thread Management ==== |
mbed_official | 48:e9a2c7cb57a4 | 347 | |
mbed_official | 48:e9a2c7cb57a4 | 348 | /// Create a Thread Definition with function, priority, and stack requirements. |
mbed_official | 48:e9a2c7cb57a4 | 349 | /// \param name name of the thread function. |
mbed_official | 48:e9a2c7cb57a4 | 350 | /// \param priority initial priority of the thread function. |
mbed_official | 48:e9a2c7cb57a4 | 351 | /// \param instances number of possible thread instances. |
mbed_official | 48:e9a2c7cb57a4 | 352 | /// \param stacksz stack size (in bytes) requirements for the thread function. |
mbed_official | 48:e9a2c7cb57a4 | 353 | /// \note CAN BE CHANGED: The parameters to \b osThreadDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 354 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 355 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 356 | #define osThreadDef(name, priority, instances, stacksz) \ |
mbed_official | 48:e9a2c7cb57a4 | 357 | extern const osThreadDef_t os_thread_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 358 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 359 | #if defined (__MBED_CMSIS_RTOS_CA9) |
mbed_official | 48:e9a2c7cb57a4 | 360 | #define osThreadDef(name, priority, stacksz) \ |
mbed_official | 48:e9a2c7cb57a4 | 361 | const osThreadDef_t os_thread_def_##name = \ |
mbed_official | 48:e9a2c7cb57a4 | 362 | { (name), (priority), 1, (stacksz) } |
mbed_official | 48:e9a2c7cb57a4 | 363 | #else |
mbed_official | 48:e9a2c7cb57a4 | 364 | #define osThreadDef(name, priority, instances, stacksz) \ |
mbed_official | 48:e9a2c7cb57a4 | 365 | const osThreadDef_t os_thread_def_##name = \ |
mbed_official | 48:e9a2c7cb57a4 | 366 | { (name), (priority), (instances), (stacksz) } |
mbed_official | 48:e9a2c7cb57a4 | 367 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 368 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 369 | |
mbed_official | 48:e9a2c7cb57a4 | 370 | /// Access a Thread definition. |
mbed_official | 48:e9a2c7cb57a4 | 371 | /// \param name name of the thread definition object. |
mbed_official | 48:e9a2c7cb57a4 | 372 | /// \note CAN BE CHANGED: The parameter to \b osThread shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 373 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 374 | #define osThread(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 375 | &os_thread_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 376 | |
mbed_official | 48:e9a2c7cb57a4 | 377 | /// Create a thread and add it to Active Threads and set it to state READY. |
mbed_official | 48:e9a2c7cb57a4 | 378 | /// \param[in] thread_def thread definition referenced with \ref osThread. |
mbed_official | 48:e9a2c7cb57a4 | 379 | /// \param[in] argument pointer that is passed to the thread function as start argument. |
mbed_official | 48:e9a2c7cb57a4 | 380 | /// \return thread ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 381 | /// \note MUST REMAIN UNCHANGED: \b osThreadCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 382 | osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument); |
mbed_official | 48:e9a2c7cb57a4 | 383 | |
mbed_official | 48:e9a2c7cb57a4 | 384 | /// Return the thread ID of the current running thread. |
mbed_official | 48:e9a2c7cb57a4 | 385 | /// \return thread ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 386 | /// \note MUST REMAIN UNCHANGED: \b osThreadGetId shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 387 | osThreadId osThreadGetId (void); |
mbed_official | 48:e9a2c7cb57a4 | 388 | |
mbed_official | 48:e9a2c7cb57a4 | 389 | /// Terminate execution of a thread and remove it from Active Threads. |
mbed_official | 48:e9a2c7cb57a4 | 390 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 48:e9a2c7cb57a4 | 391 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 392 | /// \note MUST REMAIN UNCHANGED: \b osThreadTerminate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 393 | osStatus osThreadTerminate (osThreadId thread_id); |
mbed_official | 48:e9a2c7cb57a4 | 394 | |
mbed_official | 48:e9a2c7cb57a4 | 395 | /// Pass control to next thread that is in state \b READY. |
mbed_official | 48:e9a2c7cb57a4 | 396 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 397 | /// \note MUST REMAIN UNCHANGED: \b osThreadYield shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 398 | osStatus osThreadYield (void); |
mbed_official | 48:e9a2c7cb57a4 | 399 | |
mbed_official | 48:e9a2c7cb57a4 | 400 | /// Change priority of an active thread. |
mbed_official | 48:e9a2c7cb57a4 | 401 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 48:e9a2c7cb57a4 | 402 | /// \param[in] priority new priority value for the thread function. |
mbed_official | 48:e9a2c7cb57a4 | 403 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 404 | /// \note MUST REMAIN UNCHANGED: \b osThreadSetPriority shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 405 | osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority); |
mbed_official | 48:e9a2c7cb57a4 | 406 | |
mbed_official | 48:e9a2c7cb57a4 | 407 | /// Get current priority of an active thread. |
mbed_official | 48:e9a2c7cb57a4 | 408 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 48:e9a2c7cb57a4 | 409 | /// \return current priority value of the thread function. |
mbed_official | 48:e9a2c7cb57a4 | 410 | /// \note MUST REMAIN UNCHANGED: \b osThreadGetPriority shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 411 | osPriority osThreadGetPriority (osThreadId thread_id); |
mbed_official | 48:e9a2c7cb57a4 | 412 | |
mbed_official | 48:e9a2c7cb57a4 | 413 | #ifdef __MBED_CMSIS_RTOS_CA9 |
mbed_official | 48:e9a2c7cb57a4 | 414 | /// Get current thread state. |
mbed_official | 48:e9a2c7cb57a4 | 415 | uint8_t osThreadGetState (osThreadId thread_id); |
mbed_official | 48:e9a2c7cb57a4 | 416 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 417 | |
mbed_official | 48:e9a2c7cb57a4 | 418 | // ==== Generic Wait Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 419 | |
mbed_official | 48:e9a2c7cb57a4 | 420 | /// Wait for Timeout (Time Delay). |
mbed_official | 48:e9a2c7cb57a4 | 421 | /// \param[in] millisec time delay value |
mbed_official | 48:e9a2c7cb57a4 | 422 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 423 | osStatus osDelay (uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 424 | |
mbed_official | 48:e9a2c7cb57a4 | 425 | #if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available |
mbed_official | 48:e9a2c7cb57a4 | 426 | |
mbed_official | 48:e9a2c7cb57a4 | 427 | /// Wait for Signal, Message, Mail, or Timeout. |
mbed_official | 48:e9a2c7cb57a4 | 428 | /// \param[in] millisec timeout value or 0 in case of no time-out |
mbed_official | 48:e9a2c7cb57a4 | 429 | /// \return event that contains signal, message, or mail information or error code. |
mbed_official | 48:e9a2c7cb57a4 | 430 | /// \note MUST REMAIN UNCHANGED: \b osWait shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 431 | os_InRegs osEvent osWait (uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 432 | |
mbed_official | 48:e9a2c7cb57a4 | 433 | #endif // Generic Wait available |
mbed_official | 48:e9a2c7cb57a4 | 434 | |
mbed_official | 48:e9a2c7cb57a4 | 435 | |
mbed_official | 48:e9a2c7cb57a4 | 436 | // ==== Timer Management Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 437 | /// Define a Timer object. |
mbed_official | 48:e9a2c7cb57a4 | 438 | /// \param name name of the timer object. |
mbed_official | 48:e9a2c7cb57a4 | 439 | /// \param function name of the timer call back function. |
mbed_official | 48:e9a2c7cb57a4 | 440 | /// \note CAN BE CHANGED: The parameter to \b osTimerDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 441 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 442 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 443 | #define osTimerDef(name, function) \ |
mbed_official | 48:e9a2c7cb57a4 | 444 | extern const osTimerDef_t os_timer_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 445 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 446 | #define osTimerDef(name, function) \ |
mbed_official | 48:e9a2c7cb57a4 | 447 | uint32_t os_timer_cb_##name[5]; \ |
mbed_official | 48:e9a2c7cb57a4 | 448 | const osTimerDef_t os_timer_def_##name = \ |
mbed_official | 48:e9a2c7cb57a4 | 449 | { (function), (os_timer_cb_##name) } |
mbed_official | 48:e9a2c7cb57a4 | 450 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 451 | |
mbed_official | 48:e9a2c7cb57a4 | 452 | /// Access a Timer definition. |
mbed_official | 48:e9a2c7cb57a4 | 453 | /// \param name name of the timer object. |
mbed_official | 48:e9a2c7cb57a4 | 454 | /// \note CAN BE CHANGED: The parameter to \b osTimer shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 455 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 456 | #define osTimer(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 457 | &os_timer_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 458 | |
mbed_official | 48:e9a2c7cb57a4 | 459 | /// Create a timer. |
mbed_official | 48:e9a2c7cb57a4 | 460 | /// \param[in] timer_def timer object referenced with \ref osTimer. |
mbed_official | 48:e9a2c7cb57a4 | 461 | /// \param[in] type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior. |
mbed_official | 48:e9a2c7cb57a4 | 462 | /// \param[in] argument argument to the timer call back function. |
mbed_official | 48:e9a2c7cb57a4 | 463 | /// \return timer ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 464 | /// \note MUST REMAIN UNCHANGED: \b osTimerCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 465 | osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument); |
mbed_official | 48:e9a2c7cb57a4 | 466 | |
mbed_official | 48:e9a2c7cb57a4 | 467 | /// Start or restart a timer. |
mbed_official | 48:e9a2c7cb57a4 | 468 | /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. |
mbed_official | 48:e9a2c7cb57a4 | 469 | /// \param[in] millisec time delay value of the timer. |
mbed_official | 48:e9a2c7cb57a4 | 470 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 471 | /// \note MUST REMAIN UNCHANGED: \b osTimerStart shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 472 | osStatus osTimerStart (osTimerId timer_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 473 | |
mbed_official | 48:e9a2c7cb57a4 | 474 | /// Stop the timer. |
mbed_official | 48:e9a2c7cb57a4 | 475 | /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. |
mbed_official | 48:e9a2c7cb57a4 | 476 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 477 | /// \note MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 478 | osStatus osTimerStop (osTimerId timer_id); |
mbed_official | 48:e9a2c7cb57a4 | 479 | |
mbed_official | 48:e9a2c7cb57a4 | 480 | /// Delete a timer that was created by \ref osTimerCreate. |
mbed_official | 48:e9a2c7cb57a4 | 481 | /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. |
mbed_official | 48:e9a2c7cb57a4 | 482 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 483 | /// \note MUST REMAIN UNCHANGED: \b osTimerDelete shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 484 | osStatus osTimerDelete (osTimerId timer_id); |
mbed_official | 48:e9a2c7cb57a4 | 485 | |
mbed_official | 48:e9a2c7cb57a4 | 486 | |
mbed_official | 48:e9a2c7cb57a4 | 487 | // ==== Signal Management ==== |
mbed_official | 48:e9a2c7cb57a4 | 488 | |
mbed_official | 48:e9a2c7cb57a4 | 489 | /// Set the specified Signal Flags of an active thread. |
mbed_official | 48:e9a2c7cb57a4 | 490 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 48:e9a2c7cb57a4 | 491 | /// \param[in] signals specifies the signal flags of the thread that should be set. |
mbed_official | 48:e9a2c7cb57a4 | 492 | /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. |
mbed_official | 48:e9a2c7cb57a4 | 493 | /// \note MUST REMAIN UNCHANGED: \b osSignalSet shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 494 | int32_t osSignalSet (osThreadId thread_id, int32_t signals); |
mbed_official | 48:e9a2c7cb57a4 | 495 | |
mbed_official | 48:e9a2c7cb57a4 | 496 | /// Clear the specified Signal Flags of an active thread. |
mbed_official | 48:e9a2c7cb57a4 | 497 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 48:e9a2c7cb57a4 | 498 | /// \param[in] signals specifies the signal flags of the thread that shall be cleared. |
mbed_official | 48:e9a2c7cb57a4 | 499 | /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. |
mbed_official | 48:e9a2c7cb57a4 | 500 | /// \note MUST REMAIN UNCHANGED: \b osSignalClear shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 501 | int32_t osSignalClear (osThreadId thread_id, int32_t signals); |
mbed_official | 48:e9a2c7cb57a4 | 502 | |
mbed_official | 48:e9a2c7cb57a4 | 503 | /// Get Signal Flags status of an active thread. |
mbed_official | 48:e9a2c7cb57a4 | 504 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 48:e9a2c7cb57a4 | 505 | /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. |
mbed_official | 48:e9a2c7cb57a4 | 506 | /// \note MUST REMAIN UNCHANGED: \b osSignalGet shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 507 | int32_t osSignalGet (osThreadId thread_id); |
mbed_official | 48:e9a2c7cb57a4 | 508 | |
mbed_official | 48:e9a2c7cb57a4 | 509 | /// Wait for one or more Signal Flags to become signaled for the current \b RUNNING thread. |
mbed_official | 48:e9a2c7cb57a4 | 510 | /// \param[in] signals wait until all specified signal flags set or 0 for any single signal flag. |
mbed_official | 48:e9a2c7cb57a4 | 511 | /// \param[in] millisec timeout value or 0 in case of no time-out. |
mbed_official | 48:e9a2c7cb57a4 | 512 | /// \return event flag information or error code. |
mbed_official | 48:e9a2c7cb57a4 | 513 | /// \note MUST REMAIN UNCHANGED: \b osSignalWait shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 514 | os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 515 | |
mbed_official | 48:e9a2c7cb57a4 | 516 | |
mbed_official | 48:e9a2c7cb57a4 | 517 | // ==== Mutex Management ==== |
mbed_official | 48:e9a2c7cb57a4 | 518 | |
mbed_official | 48:e9a2c7cb57a4 | 519 | /// Define a Mutex. |
mbed_official | 48:e9a2c7cb57a4 | 520 | /// \param name name of the mutex object. |
mbed_official | 48:e9a2c7cb57a4 | 521 | /// \note CAN BE CHANGED: The parameter to \b osMutexDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 522 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 523 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 524 | #define osMutexDef(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 525 | extern const osMutexDef_t os_mutex_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 526 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 527 | #define osMutexDef(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 528 | uint32_t os_mutex_cb_##name[3]; \ |
mbed_official | 48:e9a2c7cb57a4 | 529 | const osMutexDef_t os_mutex_def_##name = { (os_mutex_cb_##name) } |
mbed_official | 48:e9a2c7cb57a4 | 530 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 531 | |
mbed_official | 48:e9a2c7cb57a4 | 532 | /// Access a Mutex definition. |
mbed_official | 48:e9a2c7cb57a4 | 533 | /// \param name name of the mutex object. |
mbed_official | 48:e9a2c7cb57a4 | 534 | /// \note CAN BE CHANGED: The parameter to \b osMutex shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 535 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 536 | #define osMutex(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 537 | &os_mutex_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 538 | |
mbed_official | 48:e9a2c7cb57a4 | 539 | /// Create and Initialize a Mutex object. |
mbed_official | 48:e9a2c7cb57a4 | 540 | /// \param[in] mutex_def mutex definition referenced with \ref osMutex. |
mbed_official | 48:e9a2c7cb57a4 | 541 | /// \return mutex ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 542 | /// \note MUST REMAIN UNCHANGED: \b osMutexCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 543 | osMutexId osMutexCreate (const osMutexDef_t *mutex_def); |
mbed_official | 48:e9a2c7cb57a4 | 544 | |
mbed_official | 48:e9a2c7cb57a4 | 545 | /// Wait until a Mutex becomes available. |
mbed_official | 48:e9a2c7cb57a4 | 546 | /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate. |
mbed_official | 48:e9a2c7cb57a4 | 547 | /// \param[in] millisec timeout value or 0 in case of no time-out. |
mbed_official | 48:e9a2c7cb57a4 | 548 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 549 | /// \note MUST REMAIN UNCHANGED: \b osMutexWait shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 550 | osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 551 | |
mbed_official | 48:e9a2c7cb57a4 | 552 | /// Release a Mutex that was obtained by \ref osMutexWait. |
mbed_official | 48:e9a2c7cb57a4 | 553 | /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate. |
mbed_official | 48:e9a2c7cb57a4 | 554 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 555 | /// \note MUST REMAIN UNCHANGED: \b osMutexRelease shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 556 | osStatus osMutexRelease (osMutexId mutex_id); |
mbed_official | 48:e9a2c7cb57a4 | 557 | |
mbed_official | 48:e9a2c7cb57a4 | 558 | /// Delete a Mutex that was created by \ref osMutexCreate. |
mbed_official | 48:e9a2c7cb57a4 | 559 | /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate. |
mbed_official | 48:e9a2c7cb57a4 | 560 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 561 | /// \note MUST REMAIN UNCHANGED: \b osMutexDelete shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 562 | osStatus osMutexDelete (osMutexId mutex_id); |
mbed_official | 48:e9a2c7cb57a4 | 563 | |
mbed_official | 48:e9a2c7cb57a4 | 564 | |
mbed_official | 48:e9a2c7cb57a4 | 565 | // ==== Semaphore Management Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 566 | |
mbed_official | 48:e9a2c7cb57a4 | 567 | #if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0)) // Semaphore available |
mbed_official | 48:e9a2c7cb57a4 | 568 | |
mbed_official | 48:e9a2c7cb57a4 | 569 | /// Define a Semaphore object. |
mbed_official | 48:e9a2c7cb57a4 | 570 | /// \param name name of the semaphore object. |
mbed_official | 48:e9a2c7cb57a4 | 571 | /// \note CAN BE CHANGED: The parameter to \b osSemaphoreDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 572 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 573 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 574 | #define osSemaphoreDef(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 575 | extern const osSemaphoreDef_t os_semaphore_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 576 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 577 | #define osSemaphoreDef(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 578 | uint32_t os_semaphore_cb_##name[2]; \ |
mbed_official | 48:e9a2c7cb57a4 | 579 | const osSemaphoreDef_t os_semaphore_def_##name = { (os_semaphore_cb_##name) } |
mbed_official | 48:e9a2c7cb57a4 | 580 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 581 | |
mbed_official | 48:e9a2c7cb57a4 | 582 | /// Access a Semaphore definition. |
mbed_official | 48:e9a2c7cb57a4 | 583 | /// \param name name of the semaphore object. |
mbed_official | 48:e9a2c7cb57a4 | 584 | /// \note CAN BE CHANGED: The parameter to \b osSemaphore shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 585 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 586 | #define osSemaphore(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 587 | &os_semaphore_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 588 | |
mbed_official | 48:e9a2c7cb57a4 | 589 | /// Create and Initialize a Semaphore object used for managing resources. |
mbed_official | 48:e9a2c7cb57a4 | 590 | /// \param[in] semaphore_def semaphore definition referenced with \ref osSemaphore. |
mbed_official | 48:e9a2c7cb57a4 | 591 | /// \param[in] count number of available resources. |
mbed_official | 48:e9a2c7cb57a4 | 592 | /// \return semaphore ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 593 | /// \note MUST REMAIN UNCHANGED: \b osSemaphoreCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 594 | osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count); |
mbed_official | 48:e9a2c7cb57a4 | 595 | |
mbed_official | 48:e9a2c7cb57a4 | 596 | /// Wait until a Semaphore token becomes available. |
mbed_official | 48:e9a2c7cb57a4 | 597 | /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate. |
mbed_official | 48:e9a2c7cb57a4 | 598 | /// \param[in] millisec timeout value or 0 in case of no time-out. |
mbed_official | 48:e9a2c7cb57a4 | 599 | /// \return number of available tokens, or -1 in case of incorrect parameters. |
mbed_official | 48:e9a2c7cb57a4 | 600 | /// \note MUST REMAIN UNCHANGED: \b osSemaphoreWait shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 601 | int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 602 | |
mbed_official | 48:e9a2c7cb57a4 | 603 | /// Release a Semaphore token. |
mbed_official | 48:e9a2c7cb57a4 | 604 | /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate. |
mbed_official | 48:e9a2c7cb57a4 | 605 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 606 | /// \note MUST REMAIN UNCHANGED: \b osSemaphoreRelease shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 607 | osStatus osSemaphoreRelease (osSemaphoreId semaphore_id); |
mbed_official | 48:e9a2c7cb57a4 | 608 | |
mbed_official | 48:e9a2c7cb57a4 | 609 | /// Delete a Semaphore that was created by \ref osSemaphoreCreate. |
mbed_official | 48:e9a2c7cb57a4 | 610 | /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate. |
mbed_official | 48:e9a2c7cb57a4 | 611 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 612 | /// \note MUST REMAIN UNCHANGED: \b osSemaphoreDelete shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 613 | osStatus osSemaphoreDelete (osSemaphoreId semaphore_id); |
mbed_official | 48:e9a2c7cb57a4 | 614 | |
mbed_official | 48:e9a2c7cb57a4 | 615 | #endif // Semaphore available |
mbed_official | 48:e9a2c7cb57a4 | 616 | |
mbed_official | 48:e9a2c7cb57a4 | 617 | |
mbed_official | 48:e9a2c7cb57a4 | 618 | // ==== Memory Pool Management Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 619 | |
mbed_official | 48:e9a2c7cb57a4 | 620 | #if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available |
mbed_official | 48:e9a2c7cb57a4 | 621 | |
mbed_official | 48:e9a2c7cb57a4 | 622 | /// \brief Define a Memory Pool. |
mbed_official | 48:e9a2c7cb57a4 | 623 | /// \param name name of the memory pool. |
mbed_official | 48:e9a2c7cb57a4 | 624 | /// \param no maximum number of blocks (objects) in the memory pool. |
mbed_official | 48:e9a2c7cb57a4 | 625 | /// \param type data type of a single block (object). |
mbed_official | 48:e9a2c7cb57a4 | 626 | /// \note CAN BE CHANGED: The parameter to \b osPoolDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 627 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 628 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 629 | #define osPoolDef(name, no, type) \ |
mbed_official | 48:e9a2c7cb57a4 | 630 | extern const osPoolDef_t os_pool_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 631 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 632 | #define osPoolDef(name, no, type) \ |
mbed_official | 48:e9a2c7cb57a4 | 633 | uint32_t os_pool_m_##name[3+((sizeof(type)+3)/4)*(no)]; \ |
mbed_official | 48:e9a2c7cb57a4 | 634 | const osPoolDef_t os_pool_def_##name = \ |
mbed_official | 48:e9a2c7cb57a4 | 635 | { (no), sizeof(type), (os_pool_m_##name) } |
mbed_official | 48:e9a2c7cb57a4 | 636 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 637 | |
mbed_official | 48:e9a2c7cb57a4 | 638 | /// \brief Access a Memory Pool definition. |
mbed_official | 48:e9a2c7cb57a4 | 639 | /// \param name name of the memory pool |
mbed_official | 48:e9a2c7cb57a4 | 640 | /// \note CAN BE CHANGED: The parameter to \b osPool shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 641 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 642 | #define osPool(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 643 | &os_pool_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 644 | |
mbed_official | 48:e9a2c7cb57a4 | 645 | /// Create and Initialize a memory pool. |
mbed_official | 48:e9a2c7cb57a4 | 646 | /// \param[in] pool_def memory pool definition referenced with \ref osPool. |
mbed_official | 48:e9a2c7cb57a4 | 647 | /// \return memory pool ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 648 | /// \note MUST REMAIN UNCHANGED: \b osPoolCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 649 | osPoolId osPoolCreate (const osPoolDef_t *pool_def); |
mbed_official | 48:e9a2c7cb57a4 | 650 | |
mbed_official | 48:e9a2c7cb57a4 | 651 | /// Allocate a memory block from a memory pool. |
mbed_official | 48:e9a2c7cb57a4 | 652 | /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate. |
mbed_official | 48:e9a2c7cb57a4 | 653 | /// \return address of the allocated memory block or NULL in case of no memory available. |
mbed_official | 48:e9a2c7cb57a4 | 654 | /// \note MUST REMAIN UNCHANGED: \b osPoolAlloc shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 655 | void *osPoolAlloc (osPoolId pool_id); |
mbed_official | 48:e9a2c7cb57a4 | 656 | |
mbed_official | 48:e9a2c7cb57a4 | 657 | /// Allocate a memory block from a memory pool and set memory block to zero. |
mbed_official | 48:e9a2c7cb57a4 | 658 | /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate. |
mbed_official | 48:e9a2c7cb57a4 | 659 | /// \return address of the allocated memory block or NULL in case of no memory available. |
mbed_official | 48:e9a2c7cb57a4 | 660 | /// \note MUST REMAIN UNCHANGED: \b osPoolCAlloc shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 661 | void *osPoolCAlloc (osPoolId pool_id); |
mbed_official | 48:e9a2c7cb57a4 | 662 | |
mbed_official | 48:e9a2c7cb57a4 | 663 | /// Return an allocated memory block back to a specific memory pool. |
mbed_official | 48:e9a2c7cb57a4 | 664 | /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate. |
mbed_official | 48:e9a2c7cb57a4 | 665 | /// \param[in] block address of the allocated memory block that is returned to the memory pool. |
mbed_official | 48:e9a2c7cb57a4 | 666 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 667 | /// \note MUST REMAIN UNCHANGED: \b osPoolFree shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 668 | osStatus osPoolFree (osPoolId pool_id, void *block); |
mbed_official | 48:e9a2c7cb57a4 | 669 | |
mbed_official | 48:e9a2c7cb57a4 | 670 | #endif // Memory Pool Management available |
mbed_official | 48:e9a2c7cb57a4 | 671 | |
mbed_official | 48:e9a2c7cb57a4 | 672 | |
mbed_official | 48:e9a2c7cb57a4 | 673 | // ==== Message Queue Management Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 674 | |
mbed_official | 48:e9a2c7cb57a4 | 675 | #if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queues available |
mbed_official | 48:e9a2c7cb57a4 | 676 | |
mbed_official | 48:e9a2c7cb57a4 | 677 | /// \brief Create a Message Queue Definition. |
mbed_official | 48:e9a2c7cb57a4 | 678 | /// \param name name of the queue. |
mbed_official | 48:e9a2c7cb57a4 | 679 | /// \param queue_sz maximum number of messages in the queue. |
mbed_official | 48:e9a2c7cb57a4 | 680 | /// \param type data type of a single message element (for debugger). |
mbed_official | 48:e9a2c7cb57a4 | 681 | /// \note CAN BE CHANGED: The parameter to \b osMessageQDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 682 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 683 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 684 | #define osMessageQDef(name, queue_sz, type) \ |
mbed_official | 48:e9a2c7cb57a4 | 685 | extern const osMessageQDef_t os_messageQ_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 686 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 687 | #define osMessageQDef(name, queue_sz, type) \ |
mbed_official | 48:e9a2c7cb57a4 | 688 | uint32_t os_messageQ_q_##name[4+(queue_sz)]; \ |
mbed_official | 48:e9a2c7cb57a4 | 689 | const osMessageQDef_t os_messageQ_def_##name = \ |
mbed_official | 48:e9a2c7cb57a4 | 690 | { (queue_sz), (os_messageQ_q_##name) } |
mbed_official | 48:e9a2c7cb57a4 | 691 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 692 | |
mbed_official | 48:e9a2c7cb57a4 | 693 | /// \brief Access a Message Queue Definition. |
mbed_official | 48:e9a2c7cb57a4 | 694 | /// \param name name of the queue |
mbed_official | 48:e9a2c7cb57a4 | 695 | /// \note CAN BE CHANGED: The parameter to \b osMessageQ shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 696 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 697 | #define osMessageQ(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 698 | &os_messageQ_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 699 | |
mbed_official | 48:e9a2c7cb57a4 | 700 | /// Create and Initialize a Message Queue. |
mbed_official | 48:e9a2c7cb57a4 | 701 | /// \param[in] queue_def queue definition referenced with \ref osMessageQ. |
mbed_official | 48:e9a2c7cb57a4 | 702 | /// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL. |
mbed_official | 48:e9a2c7cb57a4 | 703 | /// \return message queue ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 704 | /// \note MUST REMAIN UNCHANGED: \b osMessageCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 705 | osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id); |
mbed_official | 48:e9a2c7cb57a4 | 706 | |
mbed_official | 48:e9a2c7cb57a4 | 707 | /// Put a Message to a Queue. |
mbed_official | 48:e9a2c7cb57a4 | 708 | /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate. |
mbed_official | 48:e9a2c7cb57a4 | 709 | /// \param[in] info message information. |
mbed_official | 48:e9a2c7cb57a4 | 710 | /// \param[in] millisec timeout value or 0 in case of no time-out. |
mbed_official | 48:e9a2c7cb57a4 | 711 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 712 | /// \note MUST REMAIN UNCHANGED: \b osMessagePut shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 713 | osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 714 | |
mbed_official | 48:e9a2c7cb57a4 | 715 | /// Get a Message or Wait for a Message from a Queue. |
mbed_official | 48:e9a2c7cb57a4 | 716 | /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate. |
mbed_official | 48:e9a2c7cb57a4 | 717 | /// \param[in] millisec timeout value or 0 in case of no time-out. |
mbed_official | 48:e9a2c7cb57a4 | 718 | /// \return event information that includes status code. |
mbed_official | 48:e9a2c7cb57a4 | 719 | /// \note MUST REMAIN UNCHANGED: \b osMessageGet shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 720 | os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 721 | |
mbed_official | 48:e9a2c7cb57a4 | 722 | #endif // Message Queues available |
mbed_official | 48:e9a2c7cb57a4 | 723 | |
mbed_official | 48:e9a2c7cb57a4 | 724 | |
mbed_official | 48:e9a2c7cb57a4 | 725 | // ==== Mail Queue Management Functions ==== |
mbed_official | 48:e9a2c7cb57a4 | 726 | |
mbed_official | 48:e9a2c7cb57a4 | 727 | #if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queues available |
mbed_official | 48:e9a2c7cb57a4 | 728 | |
mbed_official | 48:e9a2c7cb57a4 | 729 | /// \brief Create a Mail Queue Definition. |
mbed_official | 48:e9a2c7cb57a4 | 730 | /// \param name name of the queue |
mbed_official | 48:e9a2c7cb57a4 | 731 | /// \param queue_sz maximum number of messages in queue |
mbed_official | 48:e9a2c7cb57a4 | 732 | /// \param type data type of a single message element |
mbed_official | 48:e9a2c7cb57a4 | 733 | /// \note CAN BE CHANGED: The parameter to \b osMailQDef shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 734 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 735 | #if defined (osObjectsExternal) // object is external |
mbed_official | 48:e9a2c7cb57a4 | 736 | #define osMailQDef(name, queue_sz, type) \ |
mbed_official | 48:e9a2c7cb57a4 | 737 | extern const osMailQDef_t os_mailQ_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 738 | #else // define the object |
mbed_official | 48:e9a2c7cb57a4 | 739 | #define osMailQDef(name, queue_sz, type) \ |
mbed_official | 48:e9a2c7cb57a4 | 740 | uint32_t os_mailQ_q_##name[4+(queue_sz)]; \ |
mbed_official | 48:e9a2c7cb57a4 | 741 | uint32_t os_mailQ_m_##name[3+((sizeof(type)+3)/4)*(queue_sz)]; \ |
mbed_official | 48:e9a2c7cb57a4 | 742 | void * os_mailQ_p_##name[2] = { (os_mailQ_q_##name), os_mailQ_m_##name }; \ |
mbed_official | 48:e9a2c7cb57a4 | 743 | const osMailQDef_t os_mailQ_def_##name = \ |
mbed_official | 48:e9a2c7cb57a4 | 744 | { (queue_sz), sizeof(type), (os_mailQ_p_##name) } |
mbed_official | 48:e9a2c7cb57a4 | 745 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 746 | |
mbed_official | 48:e9a2c7cb57a4 | 747 | /// \brief Access a Mail Queue Definition. |
mbed_official | 48:e9a2c7cb57a4 | 748 | /// \param name name of the queue |
mbed_official | 48:e9a2c7cb57a4 | 749 | /// \note CAN BE CHANGED: The parameter to \b osMailQ shall be consistent but the |
mbed_official | 48:e9a2c7cb57a4 | 750 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 751 | #define osMailQ(name) \ |
mbed_official | 48:e9a2c7cb57a4 | 752 | &os_mailQ_def_##name |
mbed_official | 48:e9a2c7cb57a4 | 753 | |
mbed_official | 48:e9a2c7cb57a4 | 754 | /// Create and Initialize mail queue. |
mbed_official | 48:e9a2c7cb57a4 | 755 | /// \param[in] queue_def reference to the mail queue definition obtain with \ref osMailQ |
mbed_official | 48:e9a2c7cb57a4 | 756 | /// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL. |
mbed_official | 48:e9a2c7cb57a4 | 757 | /// \return mail queue ID for reference by other functions or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 758 | /// \note MUST REMAIN UNCHANGED: \b osMailCreate shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 759 | osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id); |
mbed_official | 48:e9a2c7cb57a4 | 760 | |
mbed_official | 48:e9a2c7cb57a4 | 761 | /// Allocate a memory block from a mail. |
mbed_official | 48:e9a2c7cb57a4 | 762 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 48:e9a2c7cb57a4 | 763 | /// \param[in] millisec timeout value or 0 in case of no time-out |
mbed_official | 48:e9a2c7cb57a4 | 764 | /// \return pointer to memory block that can be filled with mail or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 765 | /// \note MUST REMAIN UNCHANGED: \b osMailAlloc shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 766 | void *osMailAlloc (osMailQId queue_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 767 | |
mbed_official | 48:e9a2c7cb57a4 | 768 | /// Allocate a memory block from a mail and set memory block to zero. |
mbed_official | 48:e9a2c7cb57a4 | 769 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 48:e9a2c7cb57a4 | 770 | /// \param[in] millisec timeout value or 0 in case of no time-out |
mbed_official | 48:e9a2c7cb57a4 | 771 | /// \return pointer to memory block that can be filled with mail or NULL in case of error. |
mbed_official | 48:e9a2c7cb57a4 | 772 | /// \note MUST REMAIN UNCHANGED: \b osMailCAlloc shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 773 | void *osMailCAlloc (osMailQId queue_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 774 | |
mbed_official | 48:e9a2c7cb57a4 | 775 | /// Put a mail to a queue. |
mbed_official | 48:e9a2c7cb57a4 | 776 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 48:e9a2c7cb57a4 | 777 | /// \param[in] mail memory block previously allocated with \ref osMailAlloc or \ref osMailCAlloc. |
mbed_official | 48:e9a2c7cb57a4 | 778 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 779 | /// \note MUST REMAIN UNCHANGED: \b osMailPut shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 780 | osStatus osMailPut (osMailQId queue_id, void *mail); |
mbed_official | 48:e9a2c7cb57a4 | 781 | |
mbed_official | 48:e9a2c7cb57a4 | 782 | /// Get a mail from a queue. |
mbed_official | 48:e9a2c7cb57a4 | 783 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 48:e9a2c7cb57a4 | 784 | /// \param[in] millisec timeout value or 0 in case of no time-out |
mbed_official | 48:e9a2c7cb57a4 | 785 | /// \return event that contains mail information or error code. |
mbed_official | 48:e9a2c7cb57a4 | 786 | /// \note MUST REMAIN UNCHANGED: \b osMailGet shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 787 | os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec); |
mbed_official | 48:e9a2c7cb57a4 | 788 | |
mbed_official | 48:e9a2c7cb57a4 | 789 | /// Free a memory block from a mail. |
mbed_official | 48:e9a2c7cb57a4 | 790 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 48:e9a2c7cb57a4 | 791 | /// \param[in] mail pointer to the memory block that was obtained with \ref osMailGet. |
mbed_official | 48:e9a2c7cb57a4 | 792 | /// \return status code that indicates the execution status of the function. |
mbed_official | 48:e9a2c7cb57a4 | 793 | /// \note MUST REMAIN UNCHANGED: \b osMailFree shall be consistent in every CMSIS-RTOS. |
mbed_official | 48:e9a2c7cb57a4 | 794 | osStatus osMailFree (osMailQId queue_id, void *mail); |
mbed_official | 48:e9a2c7cb57a4 | 795 | |
mbed_official | 48:e9a2c7cb57a4 | 796 | #endif // Mail Queues available |
mbed_official | 48:e9a2c7cb57a4 | 797 | |
mbed_official | 48:e9a2c7cb57a4 | 798 | |
mbed_official | 48:e9a2c7cb57a4 | 799 | #ifdef __cplusplus |
mbed_official | 48:e9a2c7cb57a4 | 800 | } |
mbed_official | 48:e9a2c7cb57a4 | 801 | #endif |
mbed_official | 48:e9a2c7cb57a4 | 802 | |
mbed_official | 48:e9a2c7cb57a4 | 803 | #endif // _CMSIS_OS_H |