Renesas GR-PEACH OpenCV Development / gr-peach-opencv-project-sd-card_update

Fork of gr-peach-opencv-project-sd-card by the do

Committer:
thedo
Date:
Fri Jul 21 01:26:02 2017 +0000
Revision:
166:240bc5a0f42a
gr-peach-opencv-project-sd-card

Who changed what in which revision?

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