NRF: receive, ntp, Data to Sd-card working

Dependencies:   F7_Ethernet mbed BSP_DISCO_F746NG Test_Mainboard SDFileSystem RF24

Committer:
lowlowry
Date:
Sun Jun 20 13:48:06 2021 +0000
Revision:
4:5ecb71f149bf
Parent:
0:d984976f1f1c
NRF: receive, ntp, Data to Sd-card working

Who changed what in which revision?

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