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