mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

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