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