Websocket_Sample for MurataTypeYD

Dependencies:   mbed picojson

Committer:
komoritan
Date:
Thu Mar 12 12:14:38 2015 +0000
Revision:
0:14bd24b5a77f
fixed

Who changed what in which revision?

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