Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.
Dependents: denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more
Deprecated
This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.
rtx/TARGET_CORTEX_M/cmsis_os.h@114:031a41d65add, 2016-05-06 (annotated)
- Committer:
- mbed_official
- Date:
- Fri May 06 19:15:13 2016 +0100
- Revision:
- 114:031a41d65add
- Parent:
- 112:53ace74b190c
- Child:
- 118:6635230e06ba
Synchronized with git revision c5b4c543c985366d5dea828e1708a3b30889e369
Full URL: https://github.com/mbedmicro/mbed/commit/c5b4c543c985366d5dea828e1708a3b30889e369/
RTOS - fix Cortex-M version - add macros required for new kernel
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 49:77c8e4604045 | 1 | /* ---------------------------------------------------------------------- |
mbed_official | 112:53ace74b190c | 2 | * $Date: 5. February 2013 |
mbed_official | 112:53ace74b190c | 3 | * $Revision: V1.02 |
mbed_official | 49:77c8e4604045 | 4 | * |
mbed_official | 49:77c8e4604045 | 5 | * Project: CMSIS-RTOS API |
mbed_official | 49:77c8e4604045 | 6 | * Title: cmsis_os.h RTX header file |
mbed_official | 49:77c8e4604045 | 7 | * |
mbed_official | 49:77c8e4604045 | 8 | * Version 0.02 |
mbed_official | 49:77c8e4604045 | 9 | * Initial Proposal Phase |
mbed_official | 49:77c8e4604045 | 10 | * Version 0.03 |
mbed_official | 49:77c8e4604045 | 11 | * osKernelStart added, optional feature: main started as thread |
mbed_official | 49:77c8e4604045 | 12 | * osSemaphores have standard behavior |
mbed_official | 49:77c8e4604045 | 13 | * osTimerCreate does not start the timer, added osTimerStart |
mbed_official | 49:77c8e4604045 | 14 | * osThreadPass is renamed to osThreadYield |
mbed_official | 49:77c8e4604045 | 15 | * Version 1.01 |
mbed_official | 49:77c8e4604045 | 16 | * Support for C++ interface |
mbed_official | 49:77c8e4604045 | 17 | * - const attribute removed from the osXxxxDef_t typedef's |
mbed_official | 49:77c8e4604045 | 18 | * - const attribute added to the osXxxxDef macros |
mbed_official | 49:77c8e4604045 | 19 | * Added: osTimerDelete, osMutexDelete, osSemaphoreDelete |
mbed_official | 49:77c8e4604045 | 20 | * Added: osKernelInitialize |
mbed_official | 112:53ace74b190c | 21 | * Version 1.02 |
mbed_official | 112:53ace74b190c | 22 | * Control functions for short timeouts in microsecond resolution: |
mbed_official | 112:53ace74b190c | 23 | * Added: osKernelSysTick, osKernelSysTickFrequency, osKernelSysTickMicroSec |
mbed_official | 112:53ace74b190c | 24 | * Removed: osSignalGet |
mbed_official | 112:53ace74b190c | 25 | *---------------------------------------------------------------------------- |
mbed_official | 112:53ace74b190c | 26 | * |
mbed_official | 112:53ace74b190c | 27 | * Copyright (c) 2013 ARM LIMITED |
mbed_official | 112:53ace74b190c | 28 | * All rights reserved. |
mbed_official | 112:53ace74b190c | 29 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 112:53ace74b190c | 30 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 112:53ace74b190c | 31 | * - Redistributions of source code must retain the above copyright |
mbed_official | 112:53ace74b190c | 32 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 112:53ace74b190c | 33 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 112:53ace74b190c | 34 | * notice, this list of conditions and the following disclaimer in the |
mbed_official | 112:53ace74b190c | 35 | * documentation and/or other materials provided with the distribution. |
mbed_official | 112:53ace74b190c | 36 | * - Neither the name of ARM nor the names of its contributors may be used |
mbed_official | 112:53ace74b190c | 37 | * to endorse or promote products derived from this software without |
mbed_official | 112:53ace74b190c | 38 | * specific prior written permission. |
mbed_official | 112:53ace74b190c | 39 | * |
mbed_official | 112:53ace74b190c | 40 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 112:53ace74b190c | 41 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 112:53ace74b190c | 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 112:53ace74b190c | 43 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
mbed_official | 112:53ace74b190c | 44 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
mbed_official | 112:53ace74b190c | 45 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
mbed_official | 112:53ace74b190c | 46 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
mbed_official | 112:53ace74b190c | 47 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
mbed_official | 112:53ace74b190c | 48 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
mbed_official | 112:53ace74b190c | 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 112:53ace74b190c | 50 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 112:53ace74b190c | 51 | *---------------------------------------------------------------------------*/ |
mbed_official | 49:77c8e4604045 | 52 | |
mbed_official | 49:77c8e4604045 | 53 | |
mbed_official | 49:77c8e4604045 | 54 | #ifndef _CMSIS_OS_H |
mbed_official | 49:77c8e4604045 | 55 | #define _CMSIS_OS_H |
mbed_official | 49:77c8e4604045 | 56 | |
mbed_official | 49:77c8e4604045 | 57 | #define CMSIS_OS_RTX |
mbed_official | 49:77c8e4604045 | 58 | |
mbed_official | 114:031a41d65add | 59 | // __MBED_CMSIS_RTOS_CM captures our changes to the RTX kernel |
mbed_official | 114:031a41d65add | 60 | #define __MBED_CMSIS_RTOS_CM |
mbed_official | 114:031a41d65add | 61 | // we use __CMSIS_RTOS version, which changes some API in the kernel |
mbed_official | 114:031a41d65add | 62 | #define __CMSIS_RTOS |
mbed_official | 114:031a41d65add | 63 | |
mbed_official | 49:77c8e4604045 | 64 | // The stack space occupied is mainly dependent on the underling C standard library |
mbed_official | 53:c35dab33c427 | 65 | #if defined(TOOLCHAIN_GCC) || defined(TOOLCHAIN_ARM_STD) || defined(TOOLCHAIN_IAR) |
mbed_official | 49:77c8e4604045 | 66 | # define WORDS_STACK_SIZE 512 |
mbed_official | 49:77c8e4604045 | 67 | #elif defined(TOOLCHAIN_ARM_MICRO) |
mbed_official | 49:77c8e4604045 | 68 | # define WORDS_STACK_SIZE 128 |
mbed_official | 49:77c8e4604045 | 69 | #endif |
mbed_official | 49:77c8e4604045 | 70 | |
mbed_official | 49:77c8e4604045 | 71 | #define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4) |
mbed_official | 49:77c8e4604045 | 72 | |
mbed_official | 112:53ace74b190c | 73 | #define osCMSIS 0x10002U ///< CMSIS-RTOS API version (main [31:16] .sub [15:0]) |
mbed_official | 49:77c8e4604045 | 74 | |
mbed_official | 112:53ace74b190c | 75 | #define osCMSIS_RTX ((4<<16)|80) ///< RTOS identification and version (main [31:16] .sub [15:0]) |
mbed_official | 112:53ace74b190c | 76 | |
mbed_official | 112:53ace74b190c | 77 | #define osKernelSystemId "RTX V4.80" ///< RTOS identification string |
mbed_official | 112:53ace74b190c | 78 | |
mbed_official | 112:53ace74b190c | 79 | |
mbed_official | 112:53ace74b190c | 80 | #define osFeature_MainThread 1 ///< main can be thread |
mbed_official | 112:53ace74b190c | 81 | #define osFeature_Pool 1 ///< Memory Pools available |
mbed_official | 112:53ace74b190c | 82 | #define osFeature_MailQ 1 ///< Mail Queues available |
mbed_official | 112:53ace74b190c | 83 | #define osFeature_MessageQ 1 ///< Message Queues available |
mbed_official | 112:53ace74b190c | 84 | #define osFeature_Signals 16 ///< 16 Signal Flags available per thread |
mbed_official | 112:53ace74b190c | 85 | #define osFeature_Semaphore 65535 ///< Maximum count for \ref osSemaphoreCreate function |
mbed_official | 112:53ace74b190c | 86 | #define osFeature_Wait 0 ///< osWait not available |
mbed_official | 112:53ace74b190c | 87 | #define osFeature_SysTick 1 ///< osKernelSysTick functions available |
mbed_official | 49:77c8e4604045 | 88 | |
mbed_official | 49:77c8e4604045 | 89 | #if defined (__CC_ARM) |
mbed_official | 49:77c8e4604045 | 90 | #define os_InRegs __value_in_regs // Compiler specific: force struct in registers |
mbed_official | 53:c35dab33c427 | 91 | #elif defined (__ICCARM__) |
mbed_official | 53:c35dab33c427 | 92 | #define os_InRegs __value_in_regs // Compiler specific: force struct in registers |
mbed_official | 49:77c8e4604045 | 93 | #else |
mbed_official | 49:77c8e4604045 | 94 | #define os_InRegs |
mbed_official | 49:77c8e4604045 | 95 | #endif |
mbed_official | 49:77c8e4604045 | 96 | |
mbed_official | 49:77c8e4604045 | 97 | #include <stdint.h> |
mbed_official | 49:77c8e4604045 | 98 | #include <stddef.h> |
mbed_official | 49:77c8e4604045 | 99 | |
mbed_official | 49:77c8e4604045 | 100 | #ifdef __cplusplus |
mbed_official | 49:77c8e4604045 | 101 | extern "C" |
mbed_official | 49:77c8e4604045 | 102 | { |
mbed_official | 49:77c8e4604045 | 103 | #endif |
mbed_official | 49:77c8e4604045 | 104 | |
mbed_official | 49:77c8e4604045 | 105 | // ==== Enumeration, structures, defines ==== |
mbed_official | 49:77c8e4604045 | 106 | |
mbed_official | 49:77c8e4604045 | 107 | /// Priority used for thread control. |
mbed_official | 49:77c8e4604045 | 108 | typedef enum { |
mbed_official | 49:77c8e4604045 | 109 | osPriorityIdle = -3, ///< priority: idle (lowest) |
mbed_official | 49:77c8e4604045 | 110 | osPriorityLow = -2, ///< priority: low |
mbed_official | 49:77c8e4604045 | 111 | osPriorityBelowNormal = -1, ///< priority: below normal |
mbed_official | 49:77c8e4604045 | 112 | osPriorityNormal = 0, ///< priority: normal (default) |
mbed_official | 49:77c8e4604045 | 113 | osPriorityAboveNormal = +1, ///< priority: above normal |
mbed_official | 49:77c8e4604045 | 114 | osPriorityHigh = +2, ///< priority: high |
mbed_official | 49:77c8e4604045 | 115 | osPriorityRealtime = +3, ///< priority: realtime (highest) |
mbed_official | 49:77c8e4604045 | 116 | osPriorityError = 0x84 ///< system cannot determine priority or thread has illegal priority |
mbed_official | 49:77c8e4604045 | 117 | } osPriority; |
mbed_official | 49:77c8e4604045 | 118 | |
mbed_official | 49:77c8e4604045 | 119 | /// Timeout value. |
mbed_official | 112:53ace74b190c | 120 | #define osWaitForever 0xFFFFFFFFU ///< wait forever timeout value |
mbed_official | 49:77c8e4604045 | 121 | |
mbed_official | 49:77c8e4604045 | 122 | /// Status code values returned by CMSIS-RTOS functions. |
mbed_official | 49:77c8e4604045 | 123 | typedef enum { |
mbed_official | 49:77c8e4604045 | 124 | osOK = 0, ///< function completed; no error or event occurred. |
mbed_official | 49:77c8e4604045 | 125 | osEventSignal = 0x08, ///< function completed; signal event occurred. |
mbed_official | 49:77c8e4604045 | 126 | osEventMessage = 0x10, ///< function completed; message event occurred. |
mbed_official | 49:77c8e4604045 | 127 | osEventMail = 0x20, ///< function completed; mail event occurred. |
mbed_official | 49:77c8e4604045 | 128 | osEventTimeout = 0x40, ///< function completed; timeout occurred. |
mbed_official | 49:77c8e4604045 | 129 | osErrorParameter = 0x80, ///< parameter error: a mandatory parameter was missing or specified an incorrect object. |
mbed_official | 49:77c8e4604045 | 130 | osErrorResource = 0x81, ///< resource not available: a specified resource was not available. |
mbed_official | 49:77c8e4604045 | 131 | osErrorTimeoutResource = 0xC1, ///< resource not available within given time: a specified resource was not available within the timeout period. |
mbed_official | 49:77c8e4604045 | 132 | osErrorISR = 0x82, ///< not allowed in ISR context: the function cannot be called from interrupt service routines. |
mbed_official | 49:77c8e4604045 | 133 | osErrorISRRecursive = 0x83, ///< function called multiple times from ISR with same object. |
mbed_official | 49:77c8e4604045 | 134 | osErrorPriority = 0x84, ///< system cannot determine priority or thread has illegal priority. |
mbed_official | 49:77c8e4604045 | 135 | osErrorNoMemory = 0x85, ///< system is out of memory: it was impossible to allocate or reserve memory for the operation. |
mbed_official | 49:77c8e4604045 | 136 | osErrorValue = 0x86, ///< value of a parameter is out of range. |
mbed_official | 49:77c8e4604045 | 137 | osErrorOS = 0xFF, ///< unspecified RTOS error: run-time error but no other error message fits. |
mbed_official | 49:77c8e4604045 | 138 | os_status_reserved = 0x7FFFFFFF ///< prevent from enum down-size compiler optimization. |
mbed_official | 49:77c8e4604045 | 139 | } osStatus; |
mbed_official | 49:77c8e4604045 | 140 | |
mbed_official | 49:77c8e4604045 | 141 | |
mbed_official | 49:77c8e4604045 | 142 | /// Timer type value for the timer definition. |
mbed_official | 49:77c8e4604045 | 143 | typedef enum { |
mbed_official | 49:77c8e4604045 | 144 | osTimerOnce = 0, ///< one-shot timer |
mbed_official | 49:77c8e4604045 | 145 | osTimerPeriodic = 1 ///< repeating timer |
mbed_official | 49:77c8e4604045 | 146 | } os_timer_type; |
mbed_official | 49:77c8e4604045 | 147 | |
mbed_official | 49:77c8e4604045 | 148 | /// Entry point of a thread. |
mbed_official | 49:77c8e4604045 | 149 | typedef void (*os_pthread) (void const *argument); |
mbed_official | 49:77c8e4604045 | 150 | |
mbed_official | 49:77c8e4604045 | 151 | /// Entry point of a timer call back function. |
mbed_official | 49:77c8e4604045 | 152 | typedef void (*os_ptimer) (void const *argument); |
mbed_official | 49:77c8e4604045 | 153 | |
mbed_official | 49:77c8e4604045 | 154 | // >>> the following data type definitions may shall adapted towards a specific RTOS |
mbed_official | 49:77c8e4604045 | 155 | |
mbed_official | 49:77c8e4604045 | 156 | /// Thread ID identifies the thread (pointer to a thread control block). |
mbed_official | 49:77c8e4604045 | 157 | typedef struct os_thread_cb *osThreadId; |
mbed_official | 49:77c8e4604045 | 158 | |
mbed_official | 49:77c8e4604045 | 159 | /// Timer ID identifies the timer (pointer to a timer control block). |
mbed_official | 49:77c8e4604045 | 160 | typedef struct os_timer_cb *osTimerId; |
mbed_official | 49:77c8e4604045 | 161 | |
mbed_official | 49:77c8e4604045 | 162 | /// Mutex ID identifies the mutex (pointer to a mutex control block). |
mbed_official | 49:77c8e4604045 | 163 | typedef struct os_mutex_cb *osMutexId; |
mbed_official | 49:77c8e4604045 | 164 | |
mbed_official | 49:77c8e4604045 | 165 | /// Semaphore ID identifies the semaphore (pointer to a semaphore control block). |
mbed_official | 49:77c8e4604045 | 166 | typedef struct os_semaphore_cb *osSemaphoreId; |
mbed_official | 49:77c8e4604045 | 167 | |
mbed_official | 49:77c8e4604045 | 168 | /// Pool ID identifies the memory pool (pointer to a memory pool control block). |
mbed_official | 49:77c8e4604045 | 169 | typedef struct os_pool_cb *osPoolId; |
mbed_official | 49:77c8e4604045 | 170 | |
mbed_official | 49:77c8e4604045 | 171 | /// Message ID identifies the message queue (pointer to a message queue control block). |
mbed_official | 49:77c8e4604045 | 172 | typedef struct os_messageQ_cb *osMessageQId; |
mbed_official | 49:77c8e4604045 | 173 | |
mbed_official | 49:77c8e4604045 | 174 | /// Mail ID identifies the mail queue (pointer to a mail queue control block). |
mbed_official | 49:77c8e4604045 | 175 | typedef struct os_mailQ_cb *osMailQId; |
mbed_official | 49:77c8e4604045 | 176 | |
mbed_official | 49:77c8e4604045 | 177 | |
mbed_official | 49:77c8e4604045 | 178 | /// Thread Definition structure contains startup information of a thread. |
mbed_official | 49:77c8e4604045 | 179 | typedef struct os_thread_def { |
mbed_official | 112:53ace74b190c | 180 | os_pthread pthread; ///< start address of thread function |
mbed_official | 112:53ace74b190c | 181 | osPriority tpriority; ///< initial thread priority |
mbed_official | 112:53ace74b190c | 182 | uint32_t instances; ///< maximum number of instances of that thread function |
mbed_official | 112:53ace74b190c | 183 | uint32_t stacksize; ///< stack size requirements in bytes; 0 is default stack size |
mbed_official | 112:53ace74b190c | 184 | #ifdef __MBED_CMSIS_RTOS_CM |
mbed_official | 59:28712e303960 | 185 | uint32_t *stack_pointer; ///< pointer to the stack memory block |
mbed_official | 112:53ace74b190c | 186 | #endif |
mbed_official | 49:77c8e4604045 | 187 | } osThreadDef_t; |
mbed_official | 49:77c8e4604045 | 188 | |
mbed_official | 49:77c8e4604045 | 189 | /// Timer Definition structure contains timer parameters. |
mbed_official | 49:77c8e4604045 | 190 | typedef struct os_timer_def { |
mbed_official | 49:77c8e4604045 | 191 | os_ptimer ptimer; ///< start address of a timer function |
mbed_official | 49:77c8e4604045 | 192 | void *timer; ///< pointer to internal data |
mbed_official | 49:77c8e4604045 | 193 | } osTimerDef_t; |
mbed_official | 49:77c8e4604045 | 194 | |
mbed_official | 49:77c8e4604045 | 195 | /// Mutex Definition structure contains setup information for a mutex. |
mbed_official | 49:77c8e4604045 | 196 | typedef struct os_mutex_def { |
mbed_official | 49:77c8e4604045 | 197 | void *mutex; ///< pointer to internal data |
mbed_official | 49:77c8e4604045 | 198 | } osMutexDef_t; |
mbed_official | 49:77c8e4604045 | 199 | |
mbed_official | 49:77c8e4604045 | 200 | /// Semaphore Definition structure contains setup information for a semaphore. |
mbed_official | 49:77c8e4604045 | 201 | typedef struct os_semaphore_def { |
mbed_official | 49:77c8e4604045 | 202 | void *semaphore; ///< pointer to internal data |
mbed_official | 49:77c8e4604045 | 203 | } osSemaphoreDef_t; |
mbed_official | 49:77c8e4604045 | 204 | |
mbed_official | 49:77c8e4604045 | 205 | /// Definition structure for memory block allocation. |
mbed_official | 49:77c8e4604045 | 206 | typedef struct os_pool_def { |
mbed_official | 49:77c8e4604045 | 207 | uint32_t pool_sz; ///< number of items (elements) in the pool |
mbed_official | 49:77c8e4604045 | 208 | uint32_t item_sz; ///< size of an item |
mbed_official | 49:77c8e4604045 | 209 | void *pool; ///< pointer to memory for pool |
mbed_official | 49:77c8e4604045 | 210 | } osPoolDef_t; |
mbed_official | 49:77c8e4604045 | 211 | |
mbed_official | 49:77c8e4604045 | 212 | /// Definition structure for message queue. |
mbed_official | 49:77c8e4604045 | 213 | typedef struct os_messageQ_def { |
mbed_official | 49:77c8e4604045 | 214 | uint32_t queue_sz; ///< number of elements in the queue |
mbed_official | 49:77c8e4604045 | 215 | void *pool; ///< memory array for messages |
mbed_official | 49:77c8e4604045 | 216 | } osMessageQDef_t; |
mbed_official | 49:77c8e4604045 | 217 | |
mbed_official | 49:77c8e4604045 | 218 | /// Definition structure for mail queue. |
mbed_official | 49:77c8e4604045 | 219 | typedef struct os_mailQ_def { |
mbed_official | 49:77c8e4604045 | 220 | uint32_t queue_sz; ///< number of elements in the queue |
mbed_official | 49:77c8e4604045 | 221 | uint32_t item_sz; ///< size of an item |
mbed_official | 49:77c8e4604045 | 222 | void *pool; ///< memory array for mail |
mbed_official | 49:77c8e4604045 | 223 | } osMailQDef_t; |
mbed_official | 49:77c8e4604045 | 224 | |
mbed_official | 49:77c8e4604045 | 225 | /// Event structure contains detailed information about an event. |
mbed_official | 49:77c8e4604045 | 226 | typedef struct { |
mbed_official | 49:77c8e4604045 | 227 | osStatus status; ///< status code: event or error information |
mbed_official | 49:77c8e4604045 | 228 | union { |
mbed_official | 49:77c8e4604045 | 229 | uint32_t v; ///< message as 32-bit value |
mbed_official | 49:77c8e4604045 | 230 | void *p; ///< message or mail as void pointer |
mbed_official | 49:77c8e4604045 | 231 | int32_t signals; ///< signal flags |
mbed_official | 49:77c8e4604045 | 232 | } value; ///< event value |
mbed_official | 49:77c8e4604045 | 233 | union { |
mbed_official | 49:77c8e4604045 | 234 | osMailQId mail_id; ///< mail id obtained by \ref osMailCreate |
mbed_official | 49:77c8e4604045 | 235 | osMessageQId message_id; ///< message id obtained by \ref osMessageCreate |
mbed_official | 49:77c8e4604045 | 236 | } def; ///< event definition |
mbed_official | 49:77c8e4604045 | 237 | } osEvent; |
mbed_official | 49:77c8e4604045 | 238 | |
mbed_official | 49:77c8e4604045 | 239 | |
mbed_official | 49:77c8e4604045 | 240 | // ==== Kernel Control Functions ==== |
mbed_official | 49:77c8e4604045 | 241 | |
mbed_official | 49:77c8e4604045 | 242 | /// Initialize the RTOS Kernel for creating objects. |
mbed_official | 49:77c8e4604045 | 243 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 244 | osStatus osKernelInitialize (void); |
mbed_official | 49:77c8e4604045 | 245 | |
mbed_official | 49:77c8e4604045 | 246 | /// Start the RTOS Kernel. |
mbed_official | 49:77c8e4604045 | 247 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 248 | osStatus osKernelStart (void); |
mbed_official | 49:77c8e4604045 | 249 | |
mbed_official | 49:77c8e4604045 | 250 | /// Check if the RTOS kernel is already started. |
mbed_official | 49:77c8e4604045 | 251 | /// \return 0 RTOS is not started, 1 RTOS is started. |
mbed_official | 49:77c8e4604045 | 252 | int32_t osKernelRunning(void); |
mbed_official | 49:77c8e4604045 | 253 | |
mbed_official | 112:53ace74b190c | 254 | #if (defined (osFeature_SysTick) && (osFeature_SysTick != 0)) // System Timer available |
mbed_official | 112:53ace74b190c | 255 | |
mbed_official | 112:53ace74b190c | 256 | /// \cond INTERNAL_VARIABLES |
mbed_official | 112:53ace74b190c | 257 | extern uint32_t const os_tickfreq; |
mbed_official | 112:53ace74b190c | 258 | extern uint16_t const os_tickus_i; |
mbed_official | 112:53ace74b190c | 259 | extern uint16_t const os_tickus_f; |
mbed_official | 112:53ace74b190c | 260 | /// \endcond |
mbed_official | 112:53ace74b190c | 261 | |
mbed_official | 112:53ace74b190c | 262 | /// Get the RTOS kernel system timer counter. |
mbed_official | 112:53ace74b190c | 263 | /// \return RTOS kernel system timer as 32-bit value |
mbed_official | 112:53ace74b190c | 264 | uint32_t osKernelSysTick (void); |
mbed_official | 112:53ace74b190c | 265 | |
mbed_official | 112:53ace74b190c | 266 | /// The RTOS kernel system timer frequency in Hz. |
mbed_official | 112:53ace74b190c | 267 | /// \note Reflects the system timer setting and is typically defined in a configuration file. |
mbed_official | 112:53ace74b190c | 268 | #define osKernelSysTickFrequency os_tickfreq |
mbed_official | 112:53ace74b190c | 269 | |
mbed_official | 112:53ace74b190c | 270 | /// Convert a microseconds value to a RTOS kernel system timer value. |
mbed_official | 112:53ace74b190c | 271 | /// \param microsec time value in microseconds. |
mbed_official | 112:53ace74b190c | 272 | /// \return time value normalized to the \ref osKernelSysTickFrequency |
mbed_official | 112:53ace74b190c | 273 | /* |
mbed_official | 112:53ace74b190c | 274 | #define osKernelSysTickMicroSec(microsec) (((uint64_t)microsec * (osKernelSysTickFrequency)) / 1000000) |
mbed_official | 112:53ace74b190c | 275 | */ |
mbed_official | 112:53ace74b190c | 276 | #define osKernelSysTickMicroSec(microsec) ((microsec * os_tickus_i) + ((microsec * os_tickus_f) >> 16)) |
mbed_official | 112:53ace74b190c | 277 | |
mbed_official | 112:53ace74b190c | 278 | #endif // System Timer available |
mbed_official | 49:77c8e4604045 | 279 | |
mbed_official | 49:77c8e4604045 | 280 | // ==== Thread Management ==== |
mbed_official | 49:77c8e4604045 | 281 | |
mbed_official | 49:77c8e4604045 | 282 | /// Create a Thread Definition with function, priority, and stack requirements. |
mbed_official | 49:77c8e4604045 | 283 | /// \param name name of the thread function. |
mbed_official | 49:77c8e4604045 | 284 | /// \param priority initial priority of the thread function. |
mbed_official | 112:53ace74b190c | 285 | /// \param instances number of possible thread instances. |
mbed_official | 49:77c8e4604045 | 286 | /// \param stacksz stack size (in bytes) requirements for the thread function. |
mbed_official | 49:77c8e4604045 | 287 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 49:77c8e4604045 | 288 | #if defined (osObjectsExternal) // object is external |
mbed_official | 112:53ace74b190c | 289 | #define osThreadDef(name, priority, instances, stacksz) \ |
mbed_official | 112:53ace74b190c | 290 | extern const osThreadDef_t os_thread_def_##name |
mbed_official | 49:77c8e4604045 | 291 | #else // define the object |
mbed_official | 112:53ace74b190c | 292 | #ifdef __MBED_CMSIS_RTOS_CM |
mbed_official | 49:77c8e4604045 | 293 | #define osThreadDef(name, priority, stacksz) \ |
mbed_official | 59:28712e303960 | 294 | uint32_t os_thread_def_stack_##name [stacksz / sizeof(uint32_t)]; \ |
mbed_official | 112:53ace74b190c | 295 | const osThreadDef_t os_thread_def_##name = \ |
mbed_official | 112:53ace74b190c | 296 | { (name), (priority), 1, (stacksz), (os_thread_def_stack_##name) } |
mbed_official | 112:53ace74b190c | 297 | #else |
mbed_official | 112:53ace74b190c | 298 | #define osThreadDef(name, priority, instances, stacksz) \ |
mbed_official | 112:53ace74b190c | 299 | const osThreadDef_t os_thread_def_##name = \ |
mbed_official | 112:53ace74b190c | 300 | { (name), (priority), (instances), (stacksz) } |
mbed_official | 112:53ace74b190c | 301 | #endif |
mbed_official | 49:77c8e4604045 | 302 | #endif |
mbed_official | 49:77c8e4604045 | 303 | |
mbed_official | 49:77c8e4604045 | 304 | /// Access a Thread definition. |
mbed_official | 49:77c8e4604045 | 305 | /// \param name name of the thread definition object. |
mbed_official | 49:77c8e4604045 | 306 | /// macro body is implementation specific in every CMSIS-RTOS. |
mbed_official | 49:77c8e4604045 | 307 | #define osThread(name) \ |
mbed_official | 49:77c8e4604045 | 308 | &os_thread_def_##name |
mbed_official | 49:77c8e4604045 | 309 | |
mbed_official | 49:77c8e4604045 | 310 | /// Create a thread and add it to Active Threads and set it to state READY. |
mbed_official | 49:77c8e4604045 | 311 | /// \param[in] thread_def thread definition referenced with \ref osThread. |
mbed_official | 49:77c8e4604045 | 312 | /// \param[in] argument pointer that is passed to the thread function as start argument. |
mbed_official | 49:77c8e4604045 | 313 | /// \return thread ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 314 | osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument); |
mbed_official | 49:77c8e4604045 | 315 | |
mbed_official | 49:77c8e4604045 | 316 | /// Return the thread ID of the current running thread. |
mbed_official | 49:77c8e4604045 | 317 | /// \return thread ID for reference by other functions or NULL in case of error. |
mbed_official | 49:77c8e4604045 | 318 | osThreadId osThreadGetId (void); |
mbed_official | 49:77c8e4604045 | 319 | |
mbed_official | 49:77c8e4604045 | 320 | /// Terminate execution of a thread and remove it from Active Threads. |
mbed_official | 49:77c8e4604045 | 321 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 49:77c8e4604045 | 322 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 323 | osStatus osThreadTerminate (osThreadId thread_id); |
mbed_official | 49:77c8e4604045 | 324 | |
mbed_official | 49:77c8e4604045 | 325 | /// Pass control to next thread that is in state \b READY. |
mbed_official | 49:77c8e4604045 | 326 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 327 | osStatus osThreadYield (void); |
mbed_official | 49:77c8e4604045 | 328 | |
mbed_official | 49:77c8e4604045 | 329 | /// Change priority of an active thread. |
mbed_official | 49:77c8e4604045 | 330 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 49:77c8e4604045 | 331 | /// \param[in] priority new priority value for the thread function. |
mbed_official | 49:77c8e4604045 | 332 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 333 | osStatus osThreadSetPriority (osThreadId thread_id, osPriority priority); |
mbed_official | 49:77c8e4604045 | 334 | |
mbed_official | 49:77c8e4604045 | 335 | /// Get current priority of an active thread. |
mbed_official | 49:77c8e4604045 | 336 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 49:77c8e4604045 | 337 | /// \return current priority value of the thread function. |
mbed_official | 49:77c8e4604045 | 338 | osPriority osThreadGetPriority (osThreadId thread_id); |
mbed_official | 49:77c8e4604045 | 339 | |
mbed_official | 112:53ace74b190c | 340 | #ifdef __MBED_CMSIS_RTOS_CM |
mbed_official | 112:53ace74b190c | 341 | /// Get current thread state. |
mbed_official | 112:53ace74b190c | 342 | uint8_t osThreadGetState (osThreadId thread_id); |
mbed_official | 112:53ace74b190c | 343 | #endif |
mbed_official | 49:77c8e4604045 | 344 | |
mbed_official | 49:77c8e4604045 | 345 | // ==== Generic Wait Functions ==== |
mbed_official | 49:77c8e4604045 | 346 | |
mbed_official | 49:77c8e4604045 | 347 | /// Wait for Timeout (Time Delay). |
mbed_official | 112:53ace74b190c | 348 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue "Time delay" value |
mbed_official | 49:77c8e4604045 | 349 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 350 | osStatus osDelay (uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 351 | |
mbed_official | 49:77c8e4604045 | 352 | #if (defined (osFeature_Wait) && (osFeature_Wait != 0)) // Generic Wait available |
mbed_official | 49:77c8e4604045 | 353 | |
mbed_official | 49:77c8e4604045 | 354 | /// Wait for Signal, Message, Mail, or Timeout. |
mbed_official | 112:53ace74b190c | 355 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out |
mbed_official | 49:77c8e4604045 | 356 | /// \return event that contains signal, message, or mail information or error code. |
mbed_official | 49:77c8e4604045 | 357 | os_InRegs osEvent osWait (uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 358 | |
mbed_official | 49:77c8e4604045 | 359 | #endif // Generic Wait available |
mbed_official | 49:77c8e4604045 | 360 | |
mbed_official | 49:77c8e4604045 | 361 | |
mbed_official | 49:77c8e4604045 | 362 | // ==== Timer Management Functions ==== |
mbed_official | 49:77c8e4604045 | 363 | /// Define a Timer object. |
mbed_official | 49:77c8e4604045 | 364 | /// \param name name of the timer object. |
mbed_official | 49:77c8e4604045 | 365 | /// \param function name of the timer call back function. |
mbed_official | 49:77c8e4604045 | 366 | #if defined (osObjectsExternal) // object is external |
mbed_official | 49:77c8e4604045 | 367 | #define osTimerDef(name, function) \ |
mbed_official | 112:53ace74b190c | 368 | extern const osTimerDef_t os_timer_def_##name |
mbed_official | 49:77c8e4604045 | 369 | #else // define the object |
mbed_official | 49:77c8e4604045 | 370 | #define osTimerDef(name, function) \ |
mbed_official | 112:53ace74b190c | 371 | uint32_t os_timer_cb_##name[6]; \ |
mbed_official | 112:53ace74b190c | 372 | const osTimerDef_t os_timer_def_##name = \ |
mbed_official | 49:77c8e4604045 | 373 | { (function), (os_timer_cb_##name) } |
mbed_official | 49:77c8e4604045 | 374 | #endif |
mbed_official | 49:77c8e4604045 | 375 | |
mbed_official | 49:77c8e4604045 | 376 | /// Access a Timer definition. |
mbed_official | 49:77c8e4604045 | 377 | /// \param name name of the timer object. |
mbed_official | 49:77c8e4604045 | 378 | #define osTimer(name) \ |
mbed_official | 49:77c8e4604045 | 379 | &os_timer_def_##name |
mbed_official | 49:77c8e4604045 | 380 | |
mbed_official | 49:77c8e4604045 | 381 | /// Create a timer. |
mbed_official | 49:77c8e4604045 | 382 | /// \param[in] timer_def timer object referenced with \ref osTimer. |
mbed_official | 49:77c8e4604045 | 383 | /// \param[in] type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior. |
mbed_official | 49:77c8e4604045 | 384 | /// \param[in] argument argument to the timer call back function. |
mbed_official | 49:77c8e4604045 | 385 | /// \return timer ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 386 | osTimerId osTimerCreate (const osTimerDef_t *timer_def, os_timer_type type, void *argument); |
mbed_official | 49:77c8e4604045 | 387 | |
mbed_official | 49:77c8e4604045 | 388 | /// Start or restart a timer. |
mbed_official | 49:77c8e4604045 | 389 | /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. |
mbed_official | 112:53ace74b190c | 390 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue "Time delay" value of the timer. |
mbed_official | 49:77c8e4604045 | 391 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 392 | osStatus osTimerStart (osTimerId timer_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 393 | |
mbed_official | 49:77c8e4604045 | 394 | /// Stop the timer. |
mbed_official | 49:77c8e4604045 | 395 | /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. |
mbed_official | 49:77c8e4604045 | 396 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 397 | osStatus osTimerStop (osTimerId timer_id); |
mbed_official | 49:77c8e4604045 | 398 | |
mbed_official | 49:77c8e4604045 | 399 | /// Delete a timer that was created by \ref osTimerCreate. |
mbed_official | 49:77c8e4604045 | 400 | /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. |
mbed_official | 49:77c8e4604045 | 401 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 402 | osStatus osTimerDelete (osTimerId timer_id); |
mbed_official | 49:77c8e4604045 | 403 | |
mbed_official | 49:77c8e4604045 | 404 | |
mbed_official | 49:77c8e4604045 | 405 | // ==== Signal Management ==== |
mbed_official | 49:77c8e4604045 | 406 | |
mbed_official | 49:77c8e4604045 | 407 | /// Set the specified Signal Flags of an active thread. |
mbed_official | 49:77c8e4604045 | 408 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 49:77c8e4604045 | 409 | /// \param[in] signals specifies the signal flags of the thread that should be set. |
mbed_official | 49:77c8e4604045 | 410 | /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. |
mbed_official | 49:77c8e4604045 | 411 | int32_t osSignalSet (osThreadId thread_id, int32_t signals); |
mbed_official | 49:77c8e4604045 | 412 | |
mbed_official | 49:77c8e4604045 | 413 | /// Clear the specified Signal Flags of an active thread. |
mbed_official | 49:77c8e4604045 | 414 | /// \param[in] thread_id thread ID obtained by \ref osThreadCreate or \ref osThreadGetId. |
mbed_official | 49:77c8e4604045 | 415 | /// \param[in] signals specifies the signal flags of the thread that shall be cleared. |
mbed_official | 112:53ace74b190c | 416 | /// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters or call from ISR. |
mbed_official | 49:77c8e4604045 | 417 | int32_t osSignalClear (osThreadId thread_id, int32_t signals); |
mbed_official | 49:77c8e4604045 | 418 | |
mbed_official | 49:77c8e4604045 | 419 | /// Wait for one or more Signal Flags to become signaled for the current \b RUNNING thread. |
mbed_official | 49:77c8e4604045 | 420 | /// \param[in] signals wait until all specified signal flags set or 0 for any single signal flag. |
mbed_official | 112:53ace74b190c | 421 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. |
mbed_official | 49:77c8e4604045 | 422 | /// \return event flag information or error code. |
mbed_official | 49:77c8e4604045 | 423 | os_InRegs osEvent osSignalWait (int32_t signals, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 424 | |
mbed_official | 49:77c8e4604045 | 425 | |
mbed_official | 49:77c8e4604045 | 426 | // ==== Mutex Management ==== |
mbed_official | 49:77c8e4604045 | 427 | |
mbed_official | 49:77c8e4604045 | 428 | /// Define a Mutex. |
mbed_official | 49:77c8e4604045 | 429 | /// \param name name of the mutex object. |
mbed_official | 49:77c8e4604045 | 430 | #if defined (osObjectsExternal) // object is external |
mbed_official | 49:77c8e4604045 | 431 | #define osMutexDef(name) \ |
mbed_official | 112:53ace74b190c | 432 | extern const osMutexDef_t os_mutex_def_##name |
mbed_official | 49:77c8e4604045 | 433 | #else // define the object |
mbed_official | 49:77c8e4604045 | 434 | #define osMutexDef(name) \ |
mbed_official | 112:53ace74b190c | 435 | uint32_t os_mutex_cb_##name[4] = { 0 }; \ |
mbed_official | 112:53ace74b190c | 436 | const osMutexDef_t os_mutex_def_##name = { (os_mutex_cb_##name) } |
mbed_official | 49:77c8e4604045 | 437 | #endif |
mbed_official | 49:77c8e4604045 | 438 | |
mbed_official | 49:77c8e4604045 | 439 | /// Access a Mutex definition. |
mbed_official | 49:77c8e4604045 | 440 | /// \param name name of the mutex object. |
mbed_official | 49:77c8e4604045 | 441 | #define osMutex(name) \ |
mbed_official | 49:77c8e4604045 | 442 | &os_mutex_def_##name |
mbed_official | 49:77c8e4604045 | 443 | |
mbed_official | 49:77c8e4604045 | 444 | /// Create and Initialize a Mutex object. |
mbed_official | 49:77c8e4604045 | 445 | /// \param[in] mutex_def mutex definition referenced with \ref osMutex. |
mbed_official | 49:77c8e4604045 | 446 | /// \return mutex ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 447 | osMutexId osMutexCreate (const osMutexDef_t *mutex_def); |
mbed_official | 49:77c8e4604045 | 448 | |
mbed_official | 49:77c8e4604045 | 449 | /// Wait until a Mutex becomes available. |
mbed_official | 49:77c8e4604045 | 450 | /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate. |
mbed_official | 112:53ace74b190c | 451 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. |
mbed_official | 49:77c8e4604045 | 452 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 453 | osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 454 | |
mbed_official | 49:77c8e4604045 | 455 | /// Release a Mutex that was obtained by \ref osMutexWait. |
mbed_official | 49:77c8e4604045 | 456 | /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate. |
mbed_official | 49:77c8e4604045 | 457 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 458 | osStatus osMutexRelease (osMutexId mutex_id); |
mbed_official | 49:77c8e4604045 | 459 | |
mbed_official | 49:77c8e4604045 | 460 | /// Delete a Mutex that was created by \ref osMutexCreate. |
mbed_official | 49:77c8e4604045 | 461 | /// \param[in] mutex_id mutex ID obtained by \ref osMutexCreate. |
mbed_official | 49:77c8e4604045 | 462 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 463 | osStatus osMutexDelete (osMutexId mutex_id); |
mbed_official | 49:77c8e4604045 | 464 | |
mbed_official | 49:77c8e4604045 | 465 | |
mbed_official | 49:77c8e4604045 | 466 | // ==== Semaphore Management Functions ==== |
mbed_official | 49:77c8e4604045 | 467 | |
mbed_official | 49:77c8e4604045 | 468 | #if (defined (osFeature_Semaphore) && (osFeature_Semaphore != 0)) // Semaphore available |
mbed_official | 49:77c8e4604045 | 469 | |
mbed_official | 49:77c8e4604045 | 470 | /// Define a Semaphore object. |
mbed_official | 49:77c8e4604045 | 471 | /// \param name name of the semaphore object. |
mbed_official | 49:77c8e4604045 | 472 | #if defined (osObjectsExternal) // object is external |
mbed_official | 49:77c8e4604045 | 473 | #define osSemaphoreDef(name) \ |
mbed_official | 112:53ace74b190c | 474 | extern const osSemaphoreDef_t os_semaphore_def_##name |
mbed_official | 49:77c8e4604045 | 475 | #else // define the object |
mbed_official | 49:77c8e4604045 | 476 | #define osSemaphoreDef(name) \ |
mbed_official | 112:53ace74b190c | 477 | uint32_t os_semaphore_cb_##name[2] = { 0 }; \ |
mbed_official | 112:53ace74b190c | 478 | const osSemaphoreDef_t os_semaphore_def_##name = { (os_semaphore_cb_##name) } |
mbed_official | 49:77c8e4604045 | 479 | #endif |
mbed_official | 49:77c8e4604045 | 480 | |
mbed_official | 49:77c8e4604045 | 481 | /// Access a Semaphore definition. |
mbed_official | 49:77c8e4604045 | 482 | /// \param name name of the semaphore object. |
mbed_official | 49:77c8e4604045 | 483 | #define osSemaphore(name) \ |
mbed_official | 49:77c8e4604045 | 484 | &os_semaphore_def_##name |
mbed_official | 49:77c8e4604045 | 485 | |
mbed_official | 49:77c8e4604045 | 486 | /// Create and Initialize a Semaphore object used for managing resources. |
mbed_official | 49:77c8e4604045 | 487 | /// \param[in] semaphore_def semaphore definition referenced with \ref osSemaphore. |
mbed_official | 49:77c8e4604045 | 488 | /// \param[in] count number of available resources. |
mbed_official | 49:77c8e4604045 | 489 | /// \return semaphore ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 490 | osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def, int32_t count); |
mbed_official | 49:77c8e4604045 | 491 | |
mbed_official | 49:77c8e4604045 | 492 | /// Wait until a Semaphore token becomes available. |
mbed_official | 49:77c8e4604045 | 493 | /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate. |
mbed_official | 112:53ace74b190c | 494 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. |
mbed_official | 49:77c8e4604045 | 495 | /// \return number of available tokens, or -1 in case of incorrect parameters. |
mbed_official | 49:77c8e4604045 | 496 | int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 497 | |
mbed_official | 49:77c8e4604045 | 498 | /// Release a Semaphore token. |
mbed_official | 49:77c8e4604045 | 499 | /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate. |
mbed_official | 49:77c8e4604045 | 500 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 501 | osStatus osSemaphoreRelease (osSemaphoreId semaphore_id); |
mbed_official | 49:77c8e4604045 | 502 | |
mbed_official | 49:77c8e4604045 | 503 | /// Delete a Semaphore that was created by \ref osSemaphoreCreate. |
mbed_official | 49:77c8e4604045 | 504 | /// \param[in] semaphore_id semaphore object referenced with \ref osSemaphoreCreate. |
mbed_official | 49:77c8e4604045 | 505 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 506 | osStatus osSemaphoreDelete (osSemaphoreId semaphore_id); |
mbed_official | 49:77c8e4604045 | 507 | |
mbed_official | 49:77c8e4604045 | 508 | #endif // Semaphore available |
mbed_official | 49:77c8e4604045 | 509 | |
mbed_official | 49:77c8e4604045 | 510 | |
mbed_official | 49:77c8e4604045 | 511 | // ==== Memory Pool Management Functions ==== |
mbed_official | 49:77c8e4604045 | 512 | |
mbed_official | 49:77c8e4604045 | 513 | #if (defined (osFeature_Pool) && (osFeature_Pool != 0)) // Memory Pool Management available |
mbed_official | 49:77c8e4604045 | 514 | |
mbed_official | 49:77c8e4604045 | 515 | /// \brief Define a Memory Pool. |
mbed_official | 49:77c8e4604045 | 516 | /// \param name name of the memory pool. |
mbed_official | 49:77c8e4604045 | 517 | /// \param no maximum number of blocks (objects) in the memory pool. |
mbed_official | 49:77c8e4604045 | 518 | /// \param type data type of a single block (object). |
mbed_official | 49:77c8e4604045 | 519 | #if defined (osObjectsExternal) // object is external |
mbed_official | 49:77c8e4604045 | 520 | #define osPoolDef(name, no, type) \ |
mbed_official | 112:53ace74b190c | 521 | extern const osPoolDef_t os_pool_def_##name |
mbed_official | 49:77c8e4604045 | 522 | #else // define the object |
mbed_official | 49:77c8e4604045 | 523 | #define osPoolDef(name, no, type) \ |
mbed_official | 49:77c8e4604045 | 524 | uint32_t os_pool_m_##name[3+((sizeof(type)+3)/4)*(no)]; \ |
mbed_official | 112:53ace74b190c | 525 | const osPoolDef_t os_pool_def_##name = \ |
mbed_official | 49:77c8e4604045 | 526 | { (no), sizeof(type), (os_pool_m_##name) } |
mbed_official | 49:77c8e4604045 | 527 | #endif |
mbed_official | 49:77c8e4604045 | 528 | |
mbed_official | 49:77c8e4604045 | 529 | /// \brief Access a Memory Pool definition. |
mbed_official | 49:77c8e4604045 | 530 | /// \param name name of the memory pool |
mbed_official | 49:77c8e4604045 | 531 | #define osPool(name) \ |
mbed_official | 49:77c8e4604045 | 532 | &os_pool_def_##name |
mbed_official | 49:77c8e4604045 | 533 | |
mbed_official | 49:77c8e4604045 | 534 | /// Create and Initialize a memory pool. |
mbed_official | 49:77c8e4604045 | 535 | /// \param[in] pool_def memory pool definition referenced with \ref osPool. |
mbed_official | 49:77c8e4604045 | 536 | /// \return memory pool ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 537 | osPoolId osPoolCreate (const osPoolDef_t *pool_def); |
mbed_official | 49:77c8e4604045 | 538 | |
mbed_official | 49:77c8e4604045 | 539 | /// Allocate a memory block from a memory pool. |
mbed_official | 49:77c8e4604045 | 540 | /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate. |
mbed_official | 49:77c8e4604045 | 541 | /// \return address of the allocated memory block or NULL in case of no memory available. |
mbed_official | 49:77c8e4604045 | 542 | void *osPoolAlloc (osPoolId pool_id); |
mbed_official | 49:77c8e4604045 | 543 | |
mbed_official | 49:77c8e4604045 | 544 | /// Allocate a memory block from a memory pool and set memory block to zero. |
mbed_official | 49:77c8e4604045 | 545 | /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate. |
mbed_official | 49:77c8e4604045 | 546 | /// \return address of the allocated memory block or NULL in case of no memory available. |
mbed_official | 49:77c8e4604045 | 547 | void *osPoolCAlloc (osPoolId pool_id); |
mbed_official | 49:77c8e4604045 | 548 | |
mbed_official | 49:77c8e4604045 | 549 | /// Return an allocated memory block back to a specific memory pool. |
mbed_official | 49:77c8e4604045 | 550 | /// \param[in] pool_id memory pool ID obtain referenced with \ref osPoolCreate. |
mbed_official | 49:77c8e4604045 | 551 | /// \param[in] block address of the allocated memory block that is returned to the memory pool. |
mbed_official | 49:77c8e4604045 | 552 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 553 | osStatus osPoolFree (osPoolId pool_id, void *block); |
mbed_official | 49:77c8e4604045 | 554 | |
mbed_official | 49:77c8e4604045 | 555 | #endif // Memory Pool Management available |
mbed_official | 49:77c8e4604045 | 556 | |
mbed_official | 49:77c8e4604045 | 557 | |
mbed_official | 49:77c8e4604045 | 558 | // ==== Message Queue Management Functions ==== |
mbed_official | 49:77c8e4604045 | 559 | |
mbed_official | 49:77c8e4604045 | 560 | #if (defined (osFeature_MessageQ) && (osFeature_MessageQ != 0)) // Message Queues available |
mbed_official | 49:77c8e4604045 | 561 | |
mbed_official | 49:77c8e4604045 | 562 | /// \brief Create a Message Queue Definition. |
mbed_official | 49:77c8e4604045 | 563 | /// \param name name of the queue. |
mbed_official | 49:77c8e4604045 | 564 | /// \param queue_sz maximum number of messages in the queue. |
mbed_official | 49:77c8e4604045 | 565 | /// \param type data type of a single message element (for debugger). |
mbed_official | 49:77c8e4604045 | 566 | #if defined (osObjectsExternal) // object is external |
mbed_official | 49:77c8e4604045 | 567 | #define osMessageQDef(name, queue_sz, type) \ |
mbed_official | 112:53ace74b190c | 568 | extern const osMessageQDef_t os_messageQ_def_##name |
mbed_official | 49:77c8e4604045 | 569 | #else // define the object |
mbed_official | 49:77c8e4604045 | 570 | #define osMessageQDef(name, queue_sz, type) \ |
mbed_official | 112:53ace74b190c | 571 | uint32_t os_messageQ_q_##name[4+(queue_sz)] = { 0 }; \ |
mbed_official | 112:53ace74b190c | 572 | const osMessageQDef_t os_messageQ_def_##name = \ |
mbed_official | 49:77c8e4604045 | 573 | { (queue_sz), (os_messageQ_q_##name) } |
mbed_official | 49:77c8e4604045 | 574 | #endif |
mbed_official | 49:77c8e4604045 | 575 | |
mbed_official | 49:77c8e4604045 | 576 | /// \brief Access a Message Queue Definition. |
mbed_official | 49:77c8e4604045 | 577 | /// \param name name of the queue |
mbed_official | 49:77c8e4604045 | 578 | #define osMessageQ(name) \ |
mbed_official | 49:77c8e4604045 | 579 | &os_messageQ_def_##name |
mbed_official | 49:77c8e4604045 | 580 | |
mbed_official | 49:77c8e4604045 | 581 | /// Create and Initialize a Message Queue. |
mbed_official | 49:77c8e4604045 | 582 | /// \param[in] queue_def queue definition referenced with \ref osMessageQ. |
mbed_official | 49:77c8e4604045 | 583 | /// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL. |
mbed_official | 49:77c8e4604045 | 584 | /// \return message queue ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 585 | osMessageQId osMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id); |
mbed_official | 49:77c8e4604045 | 586 | |
mbed_official | 49:77c8e4604045 | 587 | /// Put a Message to a Queue. |
mbed_official | 49:77c8e4604045 | 588 | /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate. |
mbed_official | 49:77c8e4604045 | 589 | /// \param[in] info message information. |
mbed_official | 112:53ace74b190c | 590 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. |
mbed_official | 49:77c8e4604045 | 591 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 592 | osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 593 | |
mbed_official | 49:77c8e4604045 | 594 | /// Get a Message or Wait for a Message from a Queue. |
mbed_official | 49:77c8e4604045 | 595 | /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate. |
mbed_official | 112:53ace74b190c | 596 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. |
mbed_official | 49:77c8e4604045 | 597 | /// \return event information that includes status code. |
mbed_official | 49:77c8e4604045 | 598 | os_InRegs osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 599 | |
mbed_official | 49:77c8e4604045 | 600 | #endif // Message Queues available |
mbed_official | 49:77c8e4604045 | 601 | |
mbed_official | 49:77c8e4604045 | 602 | |
mbed_official | 49:77c8e4604045 | 603 | // ==== Mail Queue Management Functions ==== |
mbed_official | 49:77c8e4604045 | 604 | |
mbed_official | 49:77c8e4604045 | 605 | #if (defined (osFeature_MailQ) && (osFeature_MailQ != 0)) // Mail Queues available |
mbed_official | 49:77c8e4604045 | 606 | |
mbed_official | 49:77c8e4604045 | 607 | /// \brief Create a Mail Queue Definition. |
mbed_official | 49:77c8e4604045 | 608 | /// \param name name of the queue |
mbed_official | 49:77c8e4604045 | 609 | /// \param queue_sz maximum number of messages in queue |
mbed_official | 49:77c8e4604045 | 610 | /// \param type data type of a single message element |
mbed_official | 49:77c8e4604045 | 611 | #if defined (osObjectsExternal) // object is external |
mbed_official | 49:77c8e4604045 | 612 | #define osMailQDef(name, queue_sz, type) \ |
mbed_official | 112:53ace74b190c | 613 | extern const osMailQDef_t os_mailQ_def_##name |
mbed_official | 49:77c8e4604045 | 614 | #else // define the object |
mbed_official | 49:77c8e4604045 | 615 | #define osMailQDef(name, queue_sz, type) \ |
mbed_official | 112:53ace74b190c | 616 | uint32_t os_mailQ_q_##name[4+(queue_sz)] = { 0 }; \ |
mbed_official | 49:77c8e4604045 | 617 | uint32_t os_mailQ_m_##name[3+((sizeof(type)+3)/4)*(queue_sz)]; \ |
mbed_official | 49:77c8e4604045 | 618 | void * os_mailQ_p_##name[2] = { (os_mailQ_q_##name), os_mailQ_m_##name }; \ |
mbed_official | 112:53ace74b190c | 619 | const osMailQDef_t os_mailQ_def_##name = \ |
mbed_official | 49:77c8e4604045 | 620 | { (queue_sz), sizeof(type), (os_mailQ_p_##name) } |
mbed_official | 49:77c8e4604045 | 621 | #endif |
mbed_official | 49:77c8e4604045 | 622 | |
mbed_official | 49:77c8e4604045 | 623 | /// \brief Access a Mail Queue Definition. |
mbed_official | 49:77c8e4604045 | 624 | /// \param name name of the queue |
mbed_official | 49:77c8e4604045 | 625 | #define osMailQ(name) \ |
mbed_official | 49:77c8e4604045 | 626 | &os_mailQ_def_##name |
mbed_official | 49:77c8e4604045 | 627 | |
mbed_official | 49:77c8e4604045 | 628 | /// Create and Initialize mail queue. |
mbed_official | 49:77c8e4604045 | 629 | /// \param[in] queue_def reference to the mail queue definition obtain with \ref osMailQ |
mbed_official | 49:77c8e4604045 | 630 | /// \param[in] thread_id thread ID (obtained by \ref osThreadCreate or \ref osThreadGetId) or NULL. |
mbed_official | 49:77c8e4604045 | 631 | /// \return mail queue ID for reference by other functions or NULL in case of error. |
mbed_official | 112:53ace74b190c | 632 | osMailQId osMailCreate (const osMailQDef_t *queue_def, osThreadId thread_id); |
mbed_official | 49:77c8e4604045 | 633 | |
mbed_official | 49:77c8e4604045 | 634 | /// Allocate a memory block from a mail. |
mbed_official | 49:77c8e4604045 | 635 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 112:53ace74b190c | 636 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out |
mbed_official | 49:77c8e4604045 | 637 | /// \return pointer to memory block that can be filled with mail or NULL in case of error. |
mbed_official | 49:77c8e4604045 | 638 | void *osMailAlloc (osMailQId queue_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 639 | |
mbed_official | 49:77c8e4604045 | 640 | /// Allocate a memory block from a mail and set memory block to zero. |
mbed_official | 49:77c8e4604045 | 641 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 112:53ace74b190c | 642 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out |
mbed_official | 49:77c8e4604045 | 643 | /// \return pointer to memory block that can be filled with mail or NULL in case of error. |
mbed_official | 49:77c8e4604045 | 644 | void *osMailCAlloc (osMailQId queue_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 645 | |
mbed_official | 49:77c8e4604045 | 646 | /// Put a mail to a queue. |
mbed_official | 49:77c8e4604045 | 647 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 49:77c8e4604045 | 648 | /// \param[in] mail memory block previously allocated with \ref osMailAlloc or \ref osMailCAlloc. |
mbed_official | 49:77c8e4604045 | 649 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 650 | osStatus osMailPut (osMailQId queue_id, void *mail); |
mbed_official | 49:77c8e4604045 | 651 | |
mbed_official | 49:77c8e4604045 | 652 | /// Get a mail from a queue. |
mbed_official | 49:77c8e4604045 | 653 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 112:53ace74b190c | 654 | /// \param[in] millisec \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out |
mbed_official | 49:77c8e4604045 | 655 | /// \return event that contains mail information or error code. |
mbed_official | 49:77c8e4604045 | 656 | os_InRegs osEvent osMailGet (osMailQId queue_id, uint32_t millisec); |
mbed_official | 49:77c8e4604045 | 657 | |
mbed_official | 49:77c8e4604045 | 658 | /// Free a memory block from a mail. |
mbed_official | 49:77c8e4604045 | 659 | /// \param[in] queue_id mail queue ID obtained with \ref osMailCreate. |
mbed_official | 49:77c8e4604045 | 660 | /// \param[in] mail pointer to the memory block that was obtained with \ref osMailGet. |
mbed_official | 49:77c8e4604045 | 661 | /// \return status code that indicates the execution status of the function. |
mbed_official | 49:77c8e4604045 | 662 | osStatus osMailFree (osMailQId queue_id, void *mail); |
mbed_official | 49:77c8e4604045 | 663 | |
mbed_official | 49:77c8e4604045 | 664 | #endif // Mail Queues available |
mbed_official | 49:77c8e4604045 | 665 | |
mbed_official | 49:77c8e4604045 | 666 | |
mbed_official | 112:53ace74b190c | 667 | // ==== RTX Extensions ==== |
mbed_official | 112:53ace74b190c | 668 | |
mbed_official | 112:53ace74b190c | 669 | /// Suspend the RTX task scheduler. |
mbed_official | 112:53ace74b190c | 670 | /// \return number of ticks, for how long the system can sleep or power-down. |
mbed_official | 112:53ace74b190c | 671 | uint32_t os_suspend (void); |
mbed_official | 112:53ace74b190c | 672 | |
mbed_official | 112:53ace74b190c | 673 | /// Resume the RTX task scheduler |
mbed_official | 112:53ace74b190c | 674 | /// \param[in] sleep_time specifies how long the system was in sleep or power-down mode. |
mbed_official | 112:53ace74b190c | 675 | void os_resume (uint32_t sleep_time); |
mbed_official | 112:53ace74b190c | 676 | |
mbed_official | 112:53ace74b190c | 677 | |
mbed_official | 49:77c8e4604045 | 678 | #ifdef __cplusplus |
mbed_official | 49:77c8e4604045 | 679 | } |
mbed_official | 49:77c8e4604045 | 680 | #endif |
mbed_official | 49:77c8e4604045 | 681 | |
mbed_official | 49:77c8e4604045 | 682 | #endif // _CMSIS_OS_H |