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