ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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