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