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