in OS_TSK, rename run as tsk_run and new as tsk_new.

Committer:
jonathonfletcher
Date:
Sun Sep 02 03:24:20 2012 +0000
Revision:
0:5f46ebd8588e
in OS_TSK, rename run as tsk_run and new as tsk_new.

Who changed what in which revision?

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