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