Final 350 project

Dependencies:   uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed

Committer:
shoaib_ahmed
Date:
Mon Jul 31 09:16:35 2017 +0000
Revision:
0:791a779d6220
final project;

Who changed what in which revision?

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