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