うおーるぼっとをWiiリモコンでコントロールする新しいプログラムです。 以前のものより、Wiiリモコンが早く繋がる様になりました。 It is a program which controls A with the Wii remote. ※ A Bluetooth dongle and a Wii remote control are needed.

Dependencies:   USBHost mbed FATFileSystem mbed-rtos

Committer:
jksoft
Date:
Mon Jun 10 16:01:50 2013 +0000
Revision:
0:fccb789424fc
1.0

Who changed what in which revision?

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