]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/RTOS2/src/cmsis_os2.txt
Fixed broken document links (SDCMSIS-781)
[cmsis] / CMSIS / DoxyGen / RTOS2 / src / cmsis_os2.txt
1 /**
2 \page genRTOS2IF Generic RTOS Interface
3
4 CMSIS-RTOS2 is a generic API that is agnostic of the underlying RTOS kernel. Application programmers call CMSIS-RTOS2 API
5 functions in the user code to ensure maximum portability from one RTOS to another. Middleware using CMSIS-RTOS2 API takes
6 advantages of this approach by avoiding unnecessary porting efforts.
7
8 \image html "API_Structure.png" "CMSIS-RTOS API Structure"
9
10 A typical CMSIS-RTOS2 API implementation interfaces to an existing real-time kernel. The CMSIS-RTOS2 API provides the
11 following attributes and functionalities:
12  - Function names, identifiers, and parameters are descriptive and easy to understand. The functions are powerful and
13    flexible which reduces the number of functions exposed to the user. 
14  - \ref CMSIS_RTOS_ThreadMgmt allows you to define, create, and control threads.
15  - Interrupt Service Routines (ISR) can \ref CMSIS_RTOS_ISR_Calls "call some CMSIS-RTOS functions". When a CMSIS-RTOS
16    function cannot be called from an ISR context, it rejects the invocation and returns an error code.
17  - Three different event types support communication between multiple threads and/or ISR:
18    - \ref CMSIS_RTOS_ThreadFlagsMgmt "Thread Flags": may be used to indicate specific conditions to a thread.
19    - \ref CMSIS_RTOS_EventFlags "Event Flags": may be used to indicate events to a thread or ISR.
20    - \ref CMSIS_RTOS_Message "Messages": can be sent to a thread or an ISR. Messages are buffered in a queue.
21  - \ref CMSIS_RTOS_MutexMgmt and \ref CMSIS_RTOS_SemaphoreMgmt are incorporated.
22  - CPU time can be scheduled with the following functionalities:
23    - A \a timeout parameter is incorporated in many CMSIS-RTOS functions to avoid system lockup. When a timeout is specified,
24      the system waits until a resource is available or an event occurs. While waiting, other threads are scheduled.
25    - The \ref osDelay and \ref osDelayUntil functions put a thread into the \b WAITING state for a specified period of time.
26    - The \ref osThreadYield provides co-operative thread switching and passes execution to another thread of the same
27      priority.
28  - \ref CMSIS_RTOS_TimerMgmt  functions are used to trigger the execution of functions.
29
30 The CMSIS-RTOS2 API is designed to optionally incorporate multi-processor systems and/or access protection via the Cortex-M
31 Memory Protection Unit (MPU).
32
33 In some RTOS implementations threads may execute on different processors, thus \b message queues may reside in shared memory
34 resources.
35
36 The CMSIS-RTOS2 API encourages the software industry to evolve existing RTOS implementations. RTOS implementations can be
37 different and optimized in various aspects towards the Cortex-M processors. Optional features may be for example
38  - Support of the Cortex-M Memory Protection Unit (MPU).
39  - Support of multi-processor systems.
40  - Support of a DMA controller.
41  - Deterministic context switching.
42  - Round-robin context switching.
43  - Deadlock avoidance, for example with priority inversion.
44  - Zero interrupt latency by using Armv7-M instructions LDREX and STREX.
45
46 \section cmsis_os2_h cmsis_os2.h header file
47
48 The file \b %cmsis_os2.h is a standard header file that interfaces to every CMSIS-RTOS2 compliant real-time operating
49 systems (RTOS). Each implementation is provided the same \b cmsis_os2.h which defines the interface to the \ref rtos_api2.
50
51 Using the \b cmsis_os2.h along with dynamic object allocation allows to create source code or libraries that require no
52 modifications when using on a different CMSIS-RTOS2 implementation.
53
54 \section usingOS2 Using a CMSIS-RTOS2 Implementation
55
56 A CMSIS-RTOS2 component may be provided as library or source code (the picture below shows a library). 
57 A CMSIS-based application is extended with RTOS functionality by adding a CMSIS-RTOS2 component (and typically some configuration files).
58 The \ref cmsis_os2_h gives access to RTOS API functions and is the only interface header required when dynamic object allocation is used.
59 This enables portable application that works with every RTOS kernel event without re-compilation of the source code when the kernel is 
60 changed.
61
62 Static object allocation requires access to RTOS object control block definitions. An implementation specific header file (<i>rtos</i>.h in 
63 the picture below) provides access to such definitions. The section For RTX v5 these definitions are provided in the header file %rtx_os.h that contains this definitions for RTX v5.
64
65
66 \image html "CMSIS_RTOS_Files.png" "CMSIS-RTOS File Structure"
67
68 Once the files are added to a project, the user can start working with the CMSIS-RTOS functions.  A code example is provided
69 below:
70  
71 <b>Code Example</b>
72 \code
73 /*----------------------------------------------------------------------------
74  * CMSIS-RTOS 'main' function template
75  *---------------------------------------------------------------------------*/
76  
77 #include "RTE_Components.h"
78 #include  CMSIS_device_header
79 #include "cmsis_os2.h"
80  
81 /*----------------------------------------------------------------------------
82  * Application main thread
83  *---------------------------------------------------------------------------*/
84 void app_main (void *argument) {
85  
86   // ...
87   for (;;) {}
88 }
89  
90 int main (void) {
91  
92   // System Initialization
93   SystemCoreClockUpdate();
94 #ifdef RTE_Compiler_EventRecorder
95   // Initialize and start Event Recorder
96   EventRecorderInitialize(EventRecordError, 1U);
97 #endif
98   // ...
99  
100   osKernelInitialize();                 // Initialize CMSIS-RTOS
101   osThreadNew(app_main, NULL, NULL);    // Create application main thread
102   osKernelStart();                      // Start thread execution
103   for (;;) {}
104 }
105 \endcode
106
107
108 */
109
110
111 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
112 /**
113 \page rtx5_impl RTX v5 Implementation
114
115 Keil RTX version 5 (RTX5) implements the CMSIS-RTOS2 as a native RTOS interface for Arm Cortex-M processor-based devices.
116 A translation layer to CMSIS-RTOS API v1 is provided. Therefore, RTX5 can be used in applications that where previously based
117 on RTX version 4 and CMSIS-RTOS version 1 with minimal effort.
118
119 The following sections provide further details:
120  - \subpage cre_rtx_proj explains how to setup an RTX v5 project in Keil MDK.
121  - \subpage theory_of_operation provides general information about the operation of CMSIS-RTOS RTX v5.
122  - \subpage config_rtx5 describes configuration parameters of CMSIS-RTOS RTX v5.
123  - \subpage creating_RTX5_LIB explains how to build your own CMSIS-RTOS RTX v5 library.
124  - \subpage technicalData5 lists hardware, software, and resource requirements, supplied files, and supported tool chains.
125  - \subpage misraCompliance5 describes the violations to the MISRA standard.
126 */
127
128 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
129 /**
130 \page cre_rtx_proj Create an RTX5 Project
131
132 The steps to create a microcontroller application using RTX5 are:
133 - Create a new project and select a microcontroller device.
134 - In the Manage Run-Time Environment window, select <b>CMSIS\::CORE</b> and <b>CMSIS\::RTOS2 (API)\::Keil RTX5</b>. You can
135   choose to either add RTX as a library (Variant: \b Library) or to add the full source code (Variant: \b Source - required
136   if using the <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>):
137
138    \image html manage_rte_output.png
139
140 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
141 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
142   \b %RTX_Config.h, \b %RTX_Config.c, the library or the source code files, as well as the system and startup files:
143
144    \image html project_window.png
145
146 - If using the Variant: \b Source as statet above, you have to assure to use at least C99 compiler mode (Project Options -> C/C++ -> C99 Mode).   
147 - You can add template files to the project by right-clicking on <b>Source Group 1</b> and selecting
148   <b>Add New Item to 'Source Group 1'</b>. In the new window, click on <b>User Code Template</b>. On the right-hand side
149   you will see all available template files for CMSIS-RTOS RTX:
150   
151    \image html add_item.png
152
153 - \ref config_rtx5 "Configure" RTX5 to the application's needs using the \b %RTX_Config.h file.
154
155 \section cre_rtx_cortexa Additional requirements for RTX on Cortex-A
156
157 Cortex-A based microcontrollers are less unified with respect to the interrupt and timer implementations used compared to 
158 M-class devices. Thus RTX requires additional components when an A-class device is used, namely
159 <a href="../../Core_A/html/group__irq__ctrl__gr.html"><b>IRQ Controller (API)</b></a> and \ref CMSIS_RTOS_TickAPI "OS Tick (API)"
160 implementations. 
161
162 \image html manage_rte_cortex-a.png
163
164 The default implementations provided along with CMSIS are 
165 - Arm <a href="../../Core_A/html/group__GIC__functions.html">Generic Interrupt Controller (GIC)</a>
166 - Arm Cortex-A5, Cortex-A9 <a href="../../Core_A/html/group__PTM__timer__functions.html">Private Timer (PTIM)</a>
167 - Arm Cortex-A7 <a href="../../Core_A/html/group__PL1__timer__functions.html">Generic Physical Timer (GTIM)</a>
168
169 For devices not implementing GIC, PTIM nor GTIM please refer to the according device family pack and select the
170 proper implementations.
171
172 \section cre_UsingIRQs Using Interrupts on Cortex-M
173
174 On Cortex-M processors, the RTX5 kernel uses the following interrupt exceptions.  The table below also lists the 
175 priorities that must be assigned to these interrupts.
176
177 Handler | Priority | Interrupt/Exception
178 :-------|:---------|:----------------------------
179 SysTick | lowest   | Kernel system timer interrupt to generate periodic timer ticks
180 PendSV  | lowest   | PendSV (request for system-level service) when calling certain RTX functions from \b Handler mode
181 SCV     | lowest+1 | Supervisor Call used to enter the RTOS kernel from \b Thread mode
182
183 Other device interrupts can be used without limitation. For Arm Cortex-M3/M4/M7/M23/M33 processors, interrupts are never disabled by RTX Kernel.
184
185 <b>Usage of interrupt priority grouping</b>
186 - The interrupt priority grouping should be configured using the CMSIS-Core function NVIC_SetPriorityGrouping before calling the function 
187   \ref osKernelStart(). The RTX kernel uses the priority group value to setup the priority for SysTick and PendSV interrupts.
188 - The RTX kernel sets the priority for the interrupts/exceptions listed in above table and uses the lowest two priority levels.
189 - Do not change the priority used by the RTX kernel. If this cannot be avoided, ensure that the preempt priority of
190   SysTick/PendSV is lower than SVC.
191 - Permitted priority group values are 0 to 6. The priority group value 7 will cause RTX to fail as there is only one priority level available.
192 - The <b>main stack</b> is used to run the RTX functionality. It is therefore required to configure sufficient stack for the RTX kernel execution.
193
194 <b>Code Example</b>
195 \code
196 osKernelInitialize();                            // initialize RTX
197 NVIC_SetPriorityGrouping (3);                    // setup priority grouping
198 tread_id = osThreadNew(tread_func, NULL, NULL);  // create some threads
199 osKernelStart ();                                // start RTX kernel
200 \endcode
201
202 \section cre_rtx_proj_specifics Add support for RTX specific functions
203 If you require some of the \ref rtx5_specific "RTX specific functions" in your application code, \#include the
204 \ref rtx_os_h "header file rtx_os.h". This enables \ref lowPower "low-power" and \ref TickLess "tick-less" operation modes.
205
206 \section cre_rtx_proj_er Add Event Recorder Visibility
207
208 RTX5 interfaces to the <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a> 
209 to provide event information which helps you to understand and analyze the operation.
210
211 - To use the Event Recorder together with RTX5, select the software component <b>Compiler:Event Recorder</b>.
212 - Select the \b Source variant of the software component <b>CMSIS:RTOS2 (API):Keil RTX5</b>.
213   \image html event_recorder_rte.png "Component selection for Event Recorder"
214 - Enable the related settings under \ref evtrecConfig.
215 - Build the application code and download it to the debug hardware.
216   
217 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
218  \b Recorder.
219 */
220
221
222 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
223 /**
224 \page theory_of_operation Theory of Operation
225
226 Many aspects of the kernel are configurable and the configuration options are mentioned where applicable.
227
228 \section SystemStartup System Startup
229
230 Since main is no longer a thread RTX5 does not interfere with the system startup until main is reached.
231 Once the execution reaches \c main() there is a recommended order to initialize the hardware and start the kernel. This is
232 also reflected in the user code template file "CMSIS-RTOS2 'main' function" supplied with the RTX5 component.
233
234 Your application's \c main() should implement at least the following in the given order:
235 -# Initialization and configuration of hardware including peripherals, memory, pins, clocks and the interrupt system.
236 -# Update the system core clock using the respective
237    <a href=../../Core/html/group__system__init__gr.html>CMSIS-Core (Cortex-M)</a> or 
238    <a href=../../Core_A/html/group__system__init__gr.html>CMSIS-Core (Cortex-A)</a> function.
239 -# Initialize the CMSIS-RTOS kernel using \ref osKernelInitialize.
240 -# Optionally, create a new thread \c app_main, which is used as a main thread using \ref osThreadNew. Alternatively, threads
241    can be created in \c main() directly.
242 -# Start the RTOS scheduler using \ref osKernelStart which also configure system tick timer and RTOS specific interrupts.
243    This function does not return in case of successful execution. Any application code after \b osKernelStart will therefore not be executed.
244
245 \note Interrupts are initialized in \ref osKernelStart. Modifying basic In case priorities and
246 groupings in the NVIC are altered by the application after the above sequence it might be necessary to call
247 \ref osKernelInitialize again. Incorrect ossibly catched by \ref osRtxErrorNotify or causing a hard fault.
248
249 \note The tick timer is configured during \ref osKernelStart. 
250 \section Scheduler 
251
252 RTX5 implements a low-latency preemptive scheduler. Major parts of RTX5 are executed in handler mode such as
253   - \ref SysTick_Handler used for time-based scheduling.
254   - \ref SVC_Handler used for lock-based scheduling.
255   - \ref PendSV_Handler used for interrupt-based scheduling.
256
257 In order to be low-latency with respect to ISR execution those system exceptions are configured to use the
258 lowest priority groups available. The priorities are configured such that no preemption happens between them. Thus
259 no interrupt critical sections (i.e. interrupt locks) are needed to protect the scheduler.
260
261 \image html scheduling.png "Thread scheduling and interrupt execution"
262
263 The scheduler combines priority and round-robin based context switches. The example depicted in the image above contains
264 four threads (1, 2, 3, and 4). Threads 1 and 2 share the same priority, thread 3 has a higher one and thread 4 the highest
265 (\ref osThreadAttr_t::priority). As long as threads 3 and 4 are blocked the scheduler switches between thread 1 and 2 on
266 a time-slice basis (round-robin). The time-slice for round-robin scheduling can be configured, see Round-Robin Timeout in \ref systemConfig.
267
268 Thread 2 unblocks thread 3 by an arbitrary RTOS-call (executed in SVC handler mode) at time index 2. The scheduler switches to
269 thread 3 immediately because thread 3 has the highest priority. Thread 4 is still blocked.
270
271 At time index 4 an interrupt (ISR) occurs and preempts the SysTick_Handler. RTX does not add any latency to the interrupt
272 service execution. The ISR routine uses an RTOS-call that unblocks thread 4. Instead of switching to thread 4 immediately
273 the PendSV flag is set to defer the context switching. The PendSV_Handler is executed right after the SysTick_Handler returns
274 and the deferred context switch to thread 4 is carried out. As soon as highest priority thread 4 blocks again by using
275 a blocking RTOS-call execution is switched back to thread 3 immediately during time index 5.
276
277 At time index 5 thread 3 uses a blocking RTOS-call as well. Thus the scheduler switches back to thread 2 for time index 6.
278 At time index 7 the scheduler uses the round-robin mechanism to switch to thread 1 and so on.
279
280 \section MemoryAllocation Memory Allocation 
281
282 RTX5 objects (thread, mutex, semaphore, timer, message queue, thread and event flags, as well as memory pool) require
283 dedicated RAM memory. Objects can be created using os<i>Object</i>New() calls and deleted using os<i>Object</i>Delete()
284 calls. The related object memory needs to be available during the lifetime of the object.
285
286 RTX5 offers three different memory allocation methods for objects:
287   - \ref GlobalMemoryPool uses a single global memory pool for all objects. It is easy to configure, but may have 
288     the disadvantage for memory fragmentation when objects with different sizes are created and destroyed.
289   - \ref ObjectMemoryPool uses a fixed-size memory pool for each object type. The method is time deterministic
290      and avoids memory fragmentation.
291   - \ref StaticObjectMemory reserves memory during compile time and completely avoids that a system can be out of memory.
292     This is typically a required for some safety critical systems.
293
294 It possible to intermix all the memory allocation methods in the same application.
295
296 \subsection GlobalMemoryPool Global Memory Pool
297
298 The global memory pool allocates all objects from a memory area. This method of memory allocation is the default
299 configuration setting of RTX5.
300
301 \image html MemAllocGlob.png "Global Memory Pool for all objects"
302
303 When the memory pool does not provide sufficient memory, the creation of the object fails and the related
304 os<i>Object</i>New() function returns \token{NULL}.
305
306 Enabled in \ref systemConfig.
307
308 \subsection ObjectMemoryPool Object-specific Memory Pools
309
310 Object-specific memory pools avoids memory fragmentation with a dedicated fixed-size memory management for each object type.
311 This type of memory pools are fully time deterministic, which means that object creation and destruction takes always the
312 same fixed amount of time. As a fixed-size memory pool is specific to an object type, the handling of out-of-memory
313 situations is simplified.
314
315 \image html MemAllocSpec.png "One memory pool per object type"
316
317 Object-specific memory pools are selectively enabled for each object type, e.g: mutex or thread using the RTX configuration
318 file:
319  - Enabled in \ref threadConfig for thread objects.
320  - Enabled in \ref timerConfig for timer objects.
321  - Enabled in \ref eventFlagsConfig for event objects.
322  - Enabled in \ref mutexConfig for mutex objects.
323  - Enabled in \ref semaphoreConfig for semaphore.
324  - Enabled in \ref memPoolConfig for memory pools.
325  - Enabled in \ref msgQueueConfig for message objects.
326
327 When the memory pool does not provide sufficient memory, the creation of the object fails and the related
328 os<i>Object</i>New() function returns \token{NULL}.
329
330 \subsection StaticObjectMemory Static Object Memory
331 In contrast to the dynamic memory allocations, the static memory allocation requires compile-time allocation of object memory. 
332
333 \image html MemAllocStat.png "Statically allocated memory for all objects"
334
335 Static memory allocation can be achieved by providing user-defined memory using attributes at object creation,
336 see \ref CMSIS_RTOS_MemoryMgmt_Manual. Please take special note of the following restrictions:
337
338 Memory type                                  | Requirements
339 ---------------------------------------------|-------------------------------------------------------------------------------
340 Control Block (osXxxAttr_t::cb_mem)          | 4-Byte alignment. Size defined by \ref osRtxThreadCbSize, \ref osRtxTimerCbSize, \ref osRtxEventFlagsCbSize, \ref osRtxMutexCbSize, \ref osRtxSemaphoreCbSize, \ref osRtxMemoryPoolCbSize, \ref osRtxMessageQueueCbSize.
341 Thread Stack (osThreadAttr_t::stack_mem)     | 8-Byte alignment. Size is application specific, i.e. amount of stack variables and frames.
342 Memory Pool (osMemoryPoolAttr_t::mp_mem)     | 4-Byte alignment. Size calculated with \ref osRtxMemoryPoolMemSize.
343 Message Queue (osMessageQueueAttr_t::mq_mem) | 4-Byte alignment. Size calculated with \ref osRtxMessageQueueMemSize.
344
345
346 In order to allow RTX5 aware debugging, i.e. Component Viewer, to recognize control blocks these
347 needs to be placed in individual memory sections, i.e. using `__attribute__((section(...)))`.
348
349 RTX Object    | Linker Section 
350 --------------|------------------------
351 Thread        | `.bss.os.thread.cb`
352 Timer         | `.bss.os.timer.cb`
353 Event Flags   | `.bss.os.evflags.cb`
354 Mutex         | `.bss.os.mutex.cb`
355 Semaphore     | `.bss.os.semaphore.cb`
356 Memory Pool   | `.bss.os.mempool.cb`
357 Message Queue | `.bss.os.msgqueue.cb`
358
359 The following code example shows how to create an OS object using static memory.
360
361 <b> Code Example:</b> 
362 \code{.c}
363 /*----------------------------------------------------------------------------
364  * CMSIS-RTOS 'main' function template
365  *---------------------------------------------------------------------------*/
366
367 #include "RTE_Components.h"
368 #include  CMSIS_device_header
369 #include "cmsis_os2.h"
370  
371 //include rtx_os.h for types of RTX objects
372 #include "rtx_os.h"
373  
374 //The thread function instanced in this example
375 void worker(void *arg)
376 {
377   while(1) 
378   {
379     //work
380     osDelay(10000);
381   }  
382 }
383  
384 // Define objects that are statically allocated for worker thread 1
385 __attribute__((section(".bss.os.thread.cb")))
386 osRtxThread_t worker_thread_tcb_1;
387  
388 // Reserve two areas for the stacks of worker thread 1
389 // uint64_t makes sure the memory alignment is 8
390 uint64_t worker_thread_stk_1[64];
391  
392 // Define the attributes which are used for thread creation
393 // Optional const saves RAM memory and includes the values in periodic ROM tests 
394 const osThreadAttr_t worker_attr_1 = {
395   "wrk1",
396   osThreadJoinable,
397   &worker_thread_tcb_1,
398   sizeof(worker_thread_tcb_1),
399   &worker_thread_stk_1[0],
400   sizeof(worker_thread_stk_1),
401   osPriorityAboveNormal,
402   0
403 };
404  
405 // Define ID object for thread
406 osThreadId_t th1;
407  
408 /*----------------------------------------------------------------------------
409  * Application main thread
410  *---------------------------------------------------------------------------*/
411 void app_main (void *argument) {
412   uint32_t param = NULL;
413  
414   // Create an instance of the worker thread with static resources (TCB and stack)
415   th1 = osThreadNew(worker, &param, &worker_attr_1);
416  
417   for (;;) {}
418 }
419  
420 int main (void) {
421   // System Initialization
422   SystemCoreClockUpdate();
423   // ...
424
425   osKernelInitialize();                 // Initialize CMSIS-RTOS
426   osThreadNew(app_main, NULL, NULL);    // Create application main thread
427   osKernelStart();                      // Start thread execution
428   for (;;) {}
429 }
430 \endcode
431
432
433 \section ThreadStack Thread Stack Management
434
435 For Cortex-M processors without floating point unit the thread context requires 64 bytes on the local stack.
436
437 \note For Cortex-M4/M7 with FP the thread context requires 200 bytes on the local stack. For these devices the default stack
438 space should be increased to a minimum of 300 bytes.
439
440 Each thread is provided with a separate stack that holds the thread context and stack space for automatic variables and
441 return addresses for function call nesting. The stack sizes of RTX threads are flexibly configurable as explained in the
442 section \ref threadConfig. RTX offers a configurable checking for stack overflows and stack utilization. 
443
444
445 \section lowPower Low-Power Operation
446
447 The system thread \b osRtxIdleThread can be use to switch the system into a low-power mode. The easiest form to enter a
448 low-power mode is the execution of the \c __WFE function that puts the processor into a sleep mode where it waits for an
449 event.
450
451 <b>Code Example:</b>
452 \code
453 #include "RTE_Components.h"
454 #include CMSIS_device_header            /* Device definitions                 */
455  
456 void osRtxIdleThread (void) {
457   /* The idle demon is a system thread, running when no other thread is       */
458   /* ready to run.                                                            */
459  
460   for (;;) {
461     __WFE();                            /* Enter sleep mode                   */
462   }
463 }
464 \endcode
465
466 \note
467 \c __WFE() is not available in every Cortex-M implementation. Check device manuals for availability.
468
469
470 \section kernelTimer RTX Kernel Timer Tick
471
472 RTX uses the generic \ref CMSIS_RTOS_TickAPI to configure and control its periodic Kernel Tick.
473
474 To use an alternative timer as the Kernel Tick Timer one simply needs to implement a custom version
475 of the \ref CMSIS_RTOS_TickAPI.
476
477 \note The OS Tick implementation provided must asure that the used timer interrupt uses the same (low) priority group 
478 as the service interrupts, i.e. interrupts used by RTX must not preempt each other. Refer to the \ref Scheduler section
479 for more details.
480
481 \subsection TickLess Tick-less Low-Power Operation
482
483 RTX5 provides extension for tick-less operation which is useful for applications that use extensively low-power modes where
484 the SysTick timer is also disabled. To provide a time-tick in such power-saving modes, a wake-up timer is used to
485 derive timer intervals. The CMSIS-RTOS2 functions \ref osKernelSuspend and \ref osKernelResume control the tick-less
486 operation.
487
488 Using this functions allows the RTX5 thread scheduler to stop the periodic kernel tick interrupt. When all active threads
489 are suspended, the system enters power-down and calculates how long it can stay in this power-down mode. In the power-down
490 mode the processor and peripherals can be switched off. Only a wake-up timer must remain powered, because this timer is
491 responsible to wake-up the system after the power-down period expires.
492
493 The tick-less operation is controlled from the \b osRtxIdleThread thread. The wake-up timeout value is set before the system
494 enters the power-down mode. The function \ref osKernelSuspend calculates the wake-up timeout measured in RTX Timer Ticks;
495 this value is used to setup the wake-up timer that runs during the power-down mode of the system.
496
497 Once the system resumes operation (either by a wake-up time out or other interrupts) the RTX5 thread scheduler is started
498 with the function \ref osKernelResume. The parameter \a sleep_time specifies the time (in RTX Timer Ticks) that the system
499 was in power-down mode.
500
501 <b>Code Example:</b>
502 \code
503 #include "msp.h"                        // Device header
504
505 /*----------------------------------------------------------------------------
506  *      MSP432 Low-Power Extension Functions
507  *---------------------------------------------------------------------------*/
508 static void MSP432_LP_Entry(void) {
509   /* Enable PCM rude mode, which allows to device to enter LPM3 without waiting for peripherals */
510   PCM->CTL1 = PCM_CTL1_KEY_VAL | PCM_CTL1_FORCE_LPM_ENTRY;       
511   /* Enable all SRAM bank retentions prior to going to LPM3  */
512   SYSCTL->SRAM_BANKRET |= SYSCTL_SRAM_BANKRET_BNK7_RET;
513   __enable_interrupt();
514   NVIC_EnableIRQ(RTC_C_IRQn);
515   /* Do not wake up on exit from ISR */
516   SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
517   /* Setting the sleep deep bit */
518   SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);  
519 }
520  
521 static volatile unsigned int tc;
522 static volatile unsigned int tc_wakeup;
523  
524 void RTC_C_IRQHandler(void)
525 {
526   if (tc++ > tc_wakeup) 
527   {
528     SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;    
529     NVIC_DisableIRQ(RTC_C_IRQn);
530     NVIC_ClearPendingIRQ(RTC_C_IRQn);
531     return;
532   }
533   if (RTC_C->PS0CTL & RTC_C_PS0CTL_RT0PSIFG)
534   {
535     RTC_C->CTL0 = RTC_C_KEY_VAL;                 // Unlock RTC key protected registers
536     RTC_C->PS0CTL &= ~RTC_C_PS0CTL_RT0PSIFG;
537     RTC_C->CTL0 = 0;
538     SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);
539   }
540 }
541  
542 uint32_t g_enable_sleep = 0;
543   
544 void osRtxIdleThread (void) {
545   
546   for (;;) {
547     tc_wakeup = osKernelSuspend();
548     /* Is there some time to sleep? */
549     if (tc_wakeup > 0) {
550       tc = 0;
551       /* Enter the low power state */
552       MSP432_LP_Entry();
553       __WFE();
554     }
555     /* Adjust the kernel ticks with the amount of ticks slept */
556     osKernelResume (tc);
557   }
558 }
559 \endcode
560
561 \note
562 \c __WFE() is not available in every Arm Cortex-M implementation. Check device manuals for availability. 
563 The alternative using \c __WFI() has other issues, please take note of http://www.keil.com/support/docs/3591.htm as well.
564
565 \section rtx_os_h RTX5 Header File
566
567 Every implementation of the CMSIS-RTOS2 API can bring its own additional features. RTX5 adds a couple of
568 \ref rtx5_specific "functions" for the idle more, for error notifications, and special system timer functions. It also is
569 using macros for control block and memory sizes.
570
571 If you require some of the RTX specific functions in your application code, \#include the header file \b %rtx_os.h:
572
573 \include rtx_os.h
574
575
576 \section CMSIS_RTOS_TimeOutValue Timeout Value   
577
578 Timeout values are an argument to several \b osXxx functions to allow time for resolving a request. A timeout value of \b 0
579 means that the RTOS does not wait and the function returns instantly, even when no resource is available. A timeout value of
580 \ref osWaitForever means that the RTOS waits infinitely until a resource becomes available. Or one forces the thread to resume
581 using \ref osThreadResume which is discouraged.
582  
583 The timeout value specifies the number of timer ticks until the time delay elapses. The value is an upper bound and 
584 depends on the actual time elapsed since the last timer tick. 
585
586 Examples:
587   - timeout value \b 0 : the system does not wait, even when no resource is available the RTOS function returns instantly. 
588   - timeout value \b 1 : the system waits until the next timer tick occurs; depending on the previous timer tick, it may be a
589     very short wait time.
590   - timeout value \b 2 : actual wait time is between 1 and 2 timer ticks.
591   - timeout value \ref osWaitForever : system waits infinite until a resource becomes available. 
592   
593 \image html TimerValues.png "Example of timeout using osDelay()"
594
595
596 \section CMSIS_RTOS_ISR_Calls Calls from Interrupt Service Routines 
597
598 The following CMSIS-RTOS2 functions can be called from threads and Interrupt Service Routines (ISR):
599   - \ref osKernelGetInfo, \ref osKernelGetState,
600     \ref osKernelGetTickCount, \ref osKernelGetTickFreq, \ref osKernelGetSysTimerCount, \ref osKernelGetSysTimerFreq
601   - \ref osThreadFlagsSet
602   - \ref osEventFlagsSet, \ref osEventFlagsClear, \ref osEventFlagsGet, \ref osEventFlagsWait
603   - \ref osSemaphoreAcquire, \ref osSemaphoreRelease, \ref osSemaphoreGetCount
604   - \ref osMemoryPoolAlloc, \ref osMemoryPoolFree, \ref osMemoryPoolGetCapacity, \ref osMemoryPoolGetBlockSize,
605     \ref osMemoryPoolGetCount, \ref osMemoryPoolGetSpace
606   - \ref osMessageQueuePut, \ref osMessageQueueGet, \ref osMessageQueueGetCapacity, \ref osMessageQueueGetMsgSize,
607     \ref osMessageQueueGetCount, \ref osMessageQueueGetSpace
608
609 Functions that cannot be called from an ISR are verifying the interrupt status and return the status code \b osErrorISR, in
610 case they are called from an ISR context. In some implementations, this condition might be caught using the HARD_FAULT
611 vector.
612 */
613
614 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
615 /**
616 \page config_rtx5 Configure RTX v5
617
618 The file "RTX_Config.h" defines the configuration parameters of CMSIS-RTOS RTX and must be part of every project that is
619 using the CMSIS-RTOS RTX kernel. The configuration options are explained in detail in the following sections:
620 - \ref systemConfig covers system-wide settings for the global memory pool, tick frequency, ISR event buffer and round-robin thread switching.
621 - \ref threadConfig provides several parameters to configure the \ref CMSIS_RTOS_ThreadMgmt functions.
622 - \ref timerConfig provides several parameters to configure the \ref CMSIS_RTOS_TimerMgmt functions.
623 - \ref eventFlagsConfig provides several parameters to configure the \ref CMSIS_RTOS_EventFlags functions.
624 - \ref mutexConfig provides several parameters to configure the \ref CMSIS_RTOS_MutexMgmt functions.
625 - \ref semaphoreConfig provides several parameters to configure the \ref CMSIS_RTOS_SemaphoreMgmt functions.
626 - \ref memPoolConfig provides several parameters to configure the \ref CMSIS_RTOS_PoolMgmt functions.
627 - \ref msgQueueConfig provides several parameters to configure the \ref CMSIS_RTOS_Message functions.
628 - \ref evtrecConfig provides several parameters to configure RTX for usage with <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>.
629
630 The file "RTX_Config.c" contains default implementations of the functions \ref osRtxIdleThread and \ref osRtxErrorNotify. Both functions
631 can simply be overwritten with a customized behavior by redefining them as part of the user code.
632
633 The configuration file uses <b>Configuration Wizard Annotations</b>. Refer to <b>Pack - Configuration Wizard Annotations</b> for details.
634 Depending on the development tool, the annotations might lead to a more user-friendly graphical representation of the
635 settings. The picture below shows the µVision \b Configuration \b Wizard view in MDK:
636
637 \image html config_wizard.png "RTX_Config.h in Configuration Wizard View"
638
639 Alternatively one can provide configuration options using the compiler command line.
640
641 For example one can customize the used tick frequency to 100us by (overwriting) the configuration using
642 \code
643 cc -DOS_TICK_FREQ=100
644 \endcode
645
646 \section systemConfig System Configuration
647
648 The system configuration covers system-wide settings for the global memory pool, tick frequency, ISR event buffer and
649 round-robin thread switching.
650
651 <b>System Configuration Options</b>
652 \image html config_wizard_system.png "RTX_Config.h: System Configuration"
653
654 Name                                   | \#define                 | Description
655 ---------------------------------------|--------------------------|----------------------------------------------------------------
656 Global Dynamic Memory size [bytes]     | \c OS_DYNAMIC_MEM_SIZE   | Defines the combined global dynamic memory size for the \ref GlobalMemoryPool. Default value is \token{4096}. Value range is \token{[0-1073741824]} bytes, in multiples of \token{8} bytes.
657 Kernel Tick Frequency (Hz)             | \c OS_TICK_FREQ          | Defines base time unit for delays and timeouts in Hz. Default: 1000Hz = 1ms period.
658 Round-Robin Thread switching           | \c OS_ROBIN_ENABLE       | Enables Round-Robin Thread switching.
659 Round-Robin Timeout                    | \c OS_ROBIN_TIMEOUT      | Defines how long a thread will execute before a thread switch. Default value is \token{5}. Value range is \token{[1-1000]}.
660 ISR FIFO Queue                         | \c OS_ISR_FIFO_QUEUE     | RTOS Functions called from ISR store requests to this buffer. Default value is \token{16 entries}. Value range is \token{[4-256]} entries in multiples of \token{4}.
661 Object Memory usage counters           | \c OS_OBJ_MEM_USAGE      | Enables object memory usage counters to evaluate the maximum memory pool requirements individually for each RTOS object type.
662
663 \subsection systemConfig_glob_mem Global dynamic memory
664 Refer to \ref GlobalMemoryPool.
665
666
667 \subsection systemConfig_rr Round-Robin Thread Switching
668
669 RTX5 may be configured to use round-robin multitasking thread switching. Round-robin allows quasi-parallel execution of
670 several threads of the \a same priority. Threads are not really executed concurrently, but are scheduled where the available
671 CPU time is divided into time slices and RTX5 assigns a time slice to each thread. Because the time slice is typically short
672 (only a few milliseconds), it appears as though threads execute simultaneously.
673
674 Round-robin thread switching functions as follows:
675 - the tick is preloaded with the timeout value when a thread switch occurs
676 - the tick is decremented (if not already zero) each system tick if the same thread is still executing
677 - when the tick reaches 0 it indicates that a timeout has occurred. If there is another thread ready with the \a same
678   priority, then the system switches to that thread and the tick is preloaded with timeout again.
679
680 In other words, threads execute for the duration of their time slice (unless a thread's time slice is given up). Then, RTX
681 switches to the next thread that is in \b READY state and has the same priority. If no other thread with the same priority is
682 ready to run, the current running thread resumes it execution.
683
684 \note When switching to higher priority threads, the round-robin timeout value is reset.
685
686 Round-Robin multitasking is controlled with the <b>\#define OS_ROBIN_ENABLE</b>. The time slice period is configured (in RTX
687 timer ticks) with the <b>\#define OS_ROBIN_TIMEOUT</b>.
688
689
690 \subsection systemConfig_isr_fifo ISR FIFO Queue
691 The RTX functions (\ref CMSIS_RTOS_ISR_Calls), when called from and interrupt handler, store the request type and optional
692 parameter to the ISR FIFO queue buffer to be processed later, after the interrupt handler exits.
693
694 The scheduler is activated immediately after the IRQ handler has finished its execution to process the requests stored to the
695 FIFO queue buffer. The required size of this buffer depends on the number of functions that are called within the interrupt
696 handler. An insufficient queue size will be caught by \b osRtxErrorNotify with error code \b osRtxErrorISRQueueOverflow.
697
698
699 \subsection systemConfig_usage_counters Object Memory Usage Counters
700
701 Object memory usage counters help to evaluate the maximum memory pool requirements for each object type, just like stack
702 watermarking does for threads. The initial setup starts with a global memory pool for all object types. Consecutive runs of
703 the application with object memory usage counters enabled, help to introduce object specific memory pools for each object
704 type. Normally, this is required for applications that require a functional safety certification as global memory pools are
705 not allowed in this case.
706
707
708 \section threadConfig Thread Configuration
709
710 The RTX5 provides several parameters to configure the \ref CMSIS_RTOS_ThreadMgmt functions.
711
712 <b>Thread Configuration Options</b>
713 \image html config_wizard_threads.png "RTX_Config.h: Thread Configuration"
714
715 <br> 
716 Option                                                   | \#define               | Description
717 :--------------------------------------------------------------------------|:-------------------------------|:---------------------------------------------------------------
718 Object specific Memory allocation                        | \c OS_THREAD_OBJ_MEM   | Enables object specific memory allocation. See \ref ObjectMemoryPool.
719 Number of user Threads                                   | \c OS_THREAD_NUM       | Defines maximum number of user threads that can be active at the same time. Applies to user threads with system provided memory for control blocks. Default value is \token{1}. Value range is \token{[1-1000]}.
720 Number of user Threads with default Stack size  | \c OS_THREAD_DEF_STACK_NUM     | Defines maximum number of user threads with default stack size and applies to user threads with \token{0} stack size specified. Value range is \token{[0-1000]}.
721 Total Stack size [bytes] for user Threads with user-provided Stack size    | \c OS_THREAD_USER_STACK_SIZE | Defines the combined stack size for user threads with user-provided stack size. Default value is \token{0}. Value range is \token{[0-1073741824]} Bytes, in multiples of \token{8}. 
722 Default Thread Stack size [bytes]                        | \c OS_STACK_SIZE    | Defines stack size for threads with zero stack size specified. Default value is \token{200}. Value range is \token{[96-1073741824]} Bytes, in multiples of \token{8}. 
723 Idle Thread Stack size [bytes]                           | \c OS_IDLE_THREAD_STACK_SIZE              | Defines stack size for Idle thread. Default value is \token{200}. Value range is \token{[72-1073741824]} bytes, in multiples of \token{8}. 
724 Idle Thread TrustZone Module ID                                            | \c OS_IDLE_THREAD_TZ_MOD_ID    | Defines the \ref osThreadAttr_t::tz_module "TrustZone Module ID" the Idle Thread shall use. This needs to be set to a non-zero value if the Idle Thread need to call secure functions. Default value is \token{0}.
725 Stack overrun checking                                   | \c OS_STACK_CHECK   | Enable stack overrun checks at thread switch. 
726 Stack usage watermark                                    | \c OS_STACK_WATERMARK    | Initialize thread stack with watermark pattern for analyzing stack usage. Enabling this option increases significantly the execution time of thread creation.
727 Processor mode for Thread execution                      | \c OS_PRIVILEGE_MODE     | Controls the processor mode. Default value is \token{Privileged} mode. Value range is \token{[0=Unprivileged; 1=Privileged]} mode.
728
729 \subsection threadConfig_countstack Configuration of Thread Count and Stack Space
730
731 The RTX5 kernel uses a separate stack space for each thread and provides two methods for defining the stack requirements:
732  - <b>Static allocation</b>: when \ref osThreadAttr_t::stack_mem and \ref osThreadAttr_t::stack_size specify a memory area
733    which is used for the thread stack. \b Attention: The stack memory provided must be 64-bit aligned, i.e. by using uint64_t for declaration.
734  - <b>Dynamic allocation</b>: when \ref osThreadAttr_t is NULL or \ref osThreadAttr_t::stack_mem is NULL, the system
735    allocates the stack memory from:
736      - Object-specific Memory Pool (default Stack size) when "Object specific Memory allocation" is enabled and "Number of
737        user Threads with default Stack size" is not \token{0} and \ref osThreadAttr_t::stack_size is \token{0} (or
738        \ref osThreadAttr_t is NULL).
739      - Object-specific Memory Pool (user-provided Stack size) when "Object specific Memory allocation" is enabled and "Total
740        Stack size for user..."  is not \token{0} and \ref osThreadAttr_t::stack_size is not \token{0}.
741      - Global Memory Pool when "Object specific Memory allocation" is disabled or (\ref osThreadAttr_t::stack_size is not
742        \token{0} and "Total Stack size for user..." is \token{0}) or (\ref osThreadAttr_t::stack_size is \token{0} and
743        "Number of user Threads with default Stack size" is \token{0}).
744
745 \ref osThreadAttr_t is a parameter of the function \ref osThreadNew.
746
747 \note
748 Before the RTX kernel is started by the \ref osKernelStart() function, the main stack defined in startup_<i>device</i>.s is
749 used. The main stack is also used for:
750  - user application calls to RTX functions in \b thread \b mode using SVC calls
751  - interrupt/exception handlers.
752  
753 \subsection threadConfig_ovfcheck Stack Overflow Checking
754 RTX5 implements a software stack overflow checking that traps stack overruns. Stack is used for return addresses and
755 automatic variables. Extensive usage or incorrect stack configuration may cause a stack overflow. Software stack overflow
756 checking is controlled with the define \c OS_STACK_CHECK.
757  
758 If a stack overflow is detected, the function \ref osRtxErrorNotify with error code \ref osRtxErrorStackUnderflow is called. By
759 default, this function is implemented as an endless loop and will practically stop code execution.
760
761 \subsection threadConfig_watermark Stack Usage Watermark
762 RTX5 initializes thread stack with a watermark pattern (0xCC) when a thread is created. This allows the debugger to determine
763 the maximum stack usage for each thread. It is typically used during development but removed from the final application.
764 Stack usage watermark is controlled with the define \c OS_STACK_WATERMARK.
765   
766 Enabling this option significantly increases the execution time of \ref osThreadNew (depends on thread stack size).
767  
768 \subsection threadConfig_procmode Processor Mode for Thread Execution
769 RTX5 allows to execute threads in unprivileged or privileged processor mode. The processor mode is controlled with the
770 define \c OS_PRIVILEGE_MODE.
771  
772 In \b unprivileged processor mode, the application software:
773 - has limited access to the MSR and MRS instructions, and cannot use the CPS instruction.
774 - cannot access the system timer, NVIC, or system control block.
775 - might have restricted access to memory or peripherals.
776
777 In \b privileged processor mode, the application software can use all the instructions and has access to all resources.
778
779
780 \section timerConfig Timer Configuration
781
782 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_TimerMgmt functions.
783
784 <b>Timer Configuration Options</b>
785 \image html config_wizard_timer.png "RTX_Config.h: Timer Configuration"
786
787 Name                                   | \#define                 | Description
788 ---------------------------------------|--------------------------------|----------------------------------------------------------------
789 Object specific Memory allocation      | \c OS_TIMER_OBJ_MEM      | Enables object specific memory allocation. 
790 Number of Timer objects                | \c OS_TIMER_NUM          | Defines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is \token{[1-1000]}.
791 Timer Thread Priority                  | \c OS_TIMER_THREAD_PRIO        | Defines priority for timer thread. Default value is \token{40}. Value range is \token{[8-48]}, in multiples of \token{8}. The numbers have the following priority correlation: \token{8=Low}; \token{16=Below Normal}; \token{24=Normal}; \token{32=Above Normal}; \token{40=High}; \token{48=Realtime} 
792 Timer Thread Stack size [bytes]        | \c OS_TIMER_THREAD_STACK_SIZE  | Defines stack size for Timer thread. May be set to 0 when timers are not used. Default value is \token{200}. Value range is \token{[0-1073741824]}, in multiples of \token{8}.
793 Timer Thread TrustZone Module ID       | \c OS_TIMER_THREAD_TZ_MOD_ID   | Defines the \ref osThreadAttr_t::tz_module "TrustZone Module ID" the Timer Thread shall use. This needs to be set to a non-zero value if any Timer Callbacks need to call secure functions. Default value is \token{0}.
794 Timer Callback Queue entries           | \c OS_TIMER_CB_QUEUE           | Number of concurrent active timer callback functions. May be set to 0 when timers are not used. Default value is \token{4}. Value range is \token{[0-256]}.
795
796 \subsection timerConfig_obj Object-specific memory allocation
797 See \ref ObjectMemoryPool.
798
799 \subsection timerConfig_user User Timer Thread
800 The RTX5 function \b osRtxTimerThread executes callback functions when a time period expires. The priority of the timer
801 subsystem within the complete RTOS system is inherited from the priority of the \b osRtxTimerThread. This is configured by
802 \c OS_TIMER_THREAD_PRIO. Stack for callback functions is supplied by \b osRtxTimerThread. \c OS_TIMER_THREAD_STACK_SIZE must
803 satisfy the stack requirements of the callback function with the highest stack usage. 
804
805
806 \section eventFlagsConfig Event Flags Configuration
807
808 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_EventFlags functions.
809
810 <b>Event Configuration Options</b>
811 \image html config_wizard_eventFlags.png "RTX_Config.h: Event Flags Configuration"
812
813 Name                                   | \#define                 | Description
814 ---------------------------------------|--------------------------|----------------------------------------------------------------
815 Object specific Memory allocation      | \c OS_EVFLAGS_OBJ_MEM    | Enables object specific memory allocation. See \ref ObjectMemoryPool.
816 Number of Event Flags objects          | \c OS_EVFLAGS_NUM        | Defines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is \token{[1-1000]}.
817
818 \subsection eventFlagsConfig_obj Object-specific memory allocation
819 When object-specific memory is used, the pool size for all Event objects is specified by \c OS_EVFLAGS_NUM. Refer to
820 \ref ObjectMemoryPool.
821
822
823 \section mutexConfig Mutex Configuration
824 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_MutexMgmt functions.
825
826 <b>Mutex Configuration Options</b>
827 \image html config_wizard_mutex.png "RTX_Config.h: Mutex Configuration"
828
829
830 Name                                   | \#define                 | Description
831 ---------------------------------------|--------------------------|----------------------------------------------------------------
832 Object specific Memory allocation      | \c OS_MUTEX_OBJ_MEM      | Enables object specific memory allocation. See \ref ObjectMemoryPool.
833 Number of Mutex objects                | \c OS_MUTEX_NUM          | Defines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is \token{[1-1000]}.
834
835 \subsection mutexConfig_obj Object-specific Memory Allocation
836 When object-specific memory is used, the pool size for all Mutex objects is specified by \c OS_MUTEX_NUM. Refer to
837 \ref ObjectMemoryPool.
838
839
840 \section semaphoreConfig Semaphore Configuration
841
842 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_SemaphoreMgmt functions.
843
844 <b>Semaphore Configuration Options</b>
845 \image html config_wizard_semaphore.png "RTX_Config.h: Semaphore Configuration"
846
847
848 Name                                   | \#define                 | Description
849 ---------------------------------------|--------------------------|----------------------------------------------------------------
850 Object specific Memory allocation      | \c OS_SEMAPHORE_OBJ_MEM  | Enables object specific memory allocation. See \ref ObjectMemoryPool.
851 Number of Semaphore objects            | \c OS_SEMAPHORE_NUM      | Defines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is \token{[1-1000]}.
852
853 \subsection semaphoreConfig_obj Object-specific memory allocation
854 When Object-specific Memory is used, the pool size for all Semaphore objects is specified by \c OS_SEMAPHORE_NUM. Refer to
855 \ref ObjectMemoryPool.
856
857
858 \section memPoolConfig Memory Pool Configuration
859
860 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_PoolMgmt functions.
861
862 <b>Memory Pool Configuration Options</b>
863 \image html config_wizard_memPool.png "RTX_Config.h: Memory Pool Configuration"
864
865 Name                                   | \#define                 | Description
866 ---------------------------------------|--------------------------|----------------------------------------------------------------
867 Object specific Memory allocation      | \c OS_MEMPOOL_OBJ_MEM    | Enables object specific memory allocation. See \ref ObjectMemoryPool.
868 Number of Memory Pool objects          | \c OS_MEMPOOL_NUM        | Defines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is \token{[1-1000]}.
869 Data Storage Memory size [bytes]       | \c OS_MEMPOOL_DATA_SIZE  | Defines the combined data storage memory size. Applies to objects with system provided memory for data storage. Default value is \token{0}. Value range is \token{[0-1073741824]}, in multiples of \token{8}.
870
871 \subsection memPoolConfig_obj Object-specific memory allocation
872 When object-specific memory is used, the number of pools for all MemoryPool objects is specified by \c OS_MEMPOOL_NUM. The
873 total storage size reserved for all pools is configured in \c OS_MEMPOOL_DATA_SIZE. Refer to \ref ObjectMemoryPool.
874
875
876 \section msgQueueConfig Message Queue Configuration
877
878 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_Message functions.
879
880 <b>MessageQueue Configuration Options</b>
881 \image html config_wizard_msgQueue.png "RTX_Config.h: Message Queue Configuration"
882
883 Name                                   | \#define                 | Description
884 ---------------------------------------|--------------------------|----------------------------------------------------------------
885 Object specific Memory allocation      | \c OS_MSGQUEUE_OBJ_MEM   | Enables object specific memory allocation. See \ref ObjectMemoryPool.
886 Number of Message Queue objects        | \c OS_MSGQUEUE_NUM       | Defines maximum number of objects that can be active at the same time. Applies to objects with system provided memory for control blocks. Value range is \token{[1-1000]}.
887 Data Storage Memory size [bytes]       | \c OS_MSGQUEUE_DATA_SIZE | Defines the combined data storage memory size. Applies to objects with system provided memory for data storage. Default value is \token{0}. Value range is \token{[0-1073741824]}, in multiples of \token{8}.
888
889 \subsection msgQueueConfig_obj Object-specific memory allocation
890 When Object-specific Memory is used, the number of queues for all Message Queue objects is specified by \c OS_MSGQUEUE_NUM.
891 The total storage size reserved for all queues is configured in \c OS_MSGQUEUE_DATA_SIZE. Refer to \ref ObjectMemoryPool.
892
893
894 \section evtrecConfig Event Recorder Configuration
895
896 This section describes the configuration settings for the <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank">Event Recorder</a>
897 annotations. The usage requires the source variant of RTX5; refer to \ref cre_rtx_proj_er for more information.
898
899 \subsection evtrecConfigGlobIni Global Configuration
900 Initialize Event Recorder during the \ref osKernelInitalize and optionally start event recording.
901
902 \image html config_wizard_evtrecGlobIni.png "RTX_Config.h: Initialization and filter setup configuration"
903
904 <br/>
905
906 Name                  | \#define        | Description
907 ----------------------|-----------------|----------------------------------------------------------------
908 Global Initialization | \c OS_EVR_INIT  | Initialize Event Recorder during \ref osKernelInitialize.
909 Start Recording       | \c OS_EVR_START | Start event recording after initialization.
910
911 \note
912 - If <b>Global Initialization (\c OS_EVR_INIT)</b> is set, an explicit call to \c EventRecorderInitialize is not required.
913 - If <b>Start Recording (\c OS_EVR_START)</b> is set, an explicit call to \c EventRecorderStart is not required. You may call the function \c EventRecorderStop to stop recording.
914
915
916 <b>Global Event Filter Setup</b>
917
918 These event filter settings are applied to all software component numbers, including MDK middleware and user components.
919
920 \image html config_wizard_evtrecGlobEvtFiltSetup.png "RTX_Config.h: Global Event Filter Setup"
921
922 <br/>
923
924 Name                      | \#define         | Description
925 --------------------------|------------------|----------------------------------------------------------------
926 Error events              | \c OS_EVR_LEVEL  | Enable error events.
927 API function call events  | \c OS_EVR_LEVEL  | Enable API function call events.
928 Operation events          | \c OS_EVR_LEVEL  | Enable operation events.
929 Detailed operation events | \c OS_EVR_LEVEL  | Enable detailed operation events.
930
931 \note
932 You may disable event recording for specific software components by calling the function \c EventRecorderDisable.
933
934 <b>RTOS Event Filter Setup</b>
935
936 These event filter settings are applied to specific RTX component groups with sub-options for:
937 - Error events
938 - API function call events
939 - Operation events
940 - Detailed operation events
941
942 The generation of events must be enabled as explained under \ref evtrecConfigEvtGen.
943
944
945 \image html config_wizard_evtrecRTOSEvtFilterSetup.png "RTX_Config.h: RTOS Event Filter Setup"
946
947 <br/>
948
949 Name              | \#define                   | Description
950 ------------------|----------------------------|----------------------------------------------------------------
951 Memory Management | \c OS_EVR_MEMORY_FILTER    | Filter enable for Memory Management events.
952 Kernel            | \c OS_EVR_KERNEL_FILTER    | Filter enable for Kernel events.
953 Thread            | \c OS_EVR_THREAD_FILTER    | Filter enable for Thread events.
954 Timer             | \c OS_EVR_TIMER_FILTER     | Filter enable for Timer events.
955 Event Flags       | \c OS_EVR_EVFLAGS_FILTER   | Filter enable for Event Flags events.
956 Mutex             | \c OS_EVR_MUTEX_FILTER     | Filter enable for Mutex events.
957 Semaphore         | \c OS_EVR_SEMAPHORE_FILTER | Filter enable for Semaphore events.
958 Memory Pool       | \c OS_EVR_MEMPOOL_FILTER   | Filter enable for Memory Pool events.
959 Message Queue     | \c OS_EVR_MSGQUEUE_FILTER  | Filter enable for Message Queue events.
960  
961
962 \subsection evtrecConfigEvtGen RTOS Event Generation
963
964 Enable the event generation for specific RTX component groups. This requires the RTX source variant (refer to \ref cre_rtx_proj_er for more information).
965
966 \image html config_wizard_evtrecGeneration.png "RTX_Config.h: Event generation configuration"
967
968 <br/>
969
970 Name              | \#define                 | Description
971 ------------------|--------------------------|----------------------------------------------------------------
972 Memory Management | \c OS_EVR_MEMORY         | Enables Memory Management events recording.
973 Kernel            | \c OS_EVR_KERNEL         | Enables Kernel events recording.
974 Thread            | \c OS_EVR_THREAD         | Enables Thread events recording.
975 Timer             | \c OS_EVR_TIMER          | Enables Timer events recording.
976 Event Flags       | \c OS_EVR_EVFLAGS        | Enables Event Flags events recording.
977 Mutex             | \c OS_EVR_MUTEX          | Enables Mutex events recording.
978 Semaphore         | \c OS_EVR_SEMAPHORE      | Enables Semaphore events recording.
979 Memory Pool       | \c OS_EVR_MEMPOOL        | Enables Memory Pool events recording.
980 Message Queue     | \c OS_EVR_MSGQUEUE       | Enables Message Queue events recording.
981
982 \note
983 If event generation for a component is disabled, the code that generates the related events is not included. Thus, \ref evtrecConfigGlobIni "filters" for this
984 component will have no effect and the debugger is unable to display any events for the related component group.
985
986
987 \subsection systemConfig_event_recording Manual event configuration
988
989 To disable the generation of events for a specific RTX API call, use the following \#define settings (from <b>rtx_evrt.h</b>) and add these manually 
990 to the <b>RTX_Config.h</b> file:
991
992 \b Memory \b events \n
993 \c EVR_RTX_MEMORY_INIT_DISABLE, \c EVR_RTX_MEMORY_ALLOC_DISABLE, \c EVR_RTX_MEMORY_FREE_DISABLE,
994 \c EVR_RTX_MEMORY_BLOCK_INIT_DISABLE, \c EVR_RTX_MEMORY_BLOCK_ALLOC_DISABLE, \c EVR_RTX_MEMORY_BLOCK_FREE_DISABLE
995
996 \b Kernel \b events \n
997 \c EVR_RTX_KERNEL_ERROR_DISABLE, \c EVR_RTX_KERNEL_INITIALIZE_DISABLE, \c EVR_RTX_KERNEL_INITIALIZED_DISABLE,
998 \c EVR_RTX_KERNEL_GET_INFO_DISABLE, \c EVR_RTX_KERNEL_INFO_RETRIEVED_DISABLE, \c EVR_RTX_KERNEL_GET_STATE_DISABLE,
999 \c EVR_RTX_KERNEL_START_DISABLE, \c EVR_RTX_KERNEL_STARTED_DISABLE, \c EVR_RTX_KERNEL_LOCK_DISABLE,
1000 \c EVR_RTX_KERNEL_LOCKED_DISABLE, \c EVR_RTX_KERNEL_UNLOCK_DISABLE, \c EVR_RTX_KERNEL_UNLOCKED_DISABLE,
1001 \c EVR_RTX_KERNEL_RESTORE_LOCK_DISABLE, \c EVR_RTX_KERNEL_LOCK_RESTORED_DISABLE, \c EVR_RTX_KERNEL_SUSPEND_DISABLE,
1002 \c EVR_RTX_KERNEL_SUSPENDED_DISABLE, \c EVR_RTX_KERNEL_RESUME_DISABLE, \c EVR_RTX_KERNEL_RESUMED_DISABLE,
1003 \c EVR_RTX_KERNEL_GET_TICK_COUNT_DISABLE, \c EVR_RTX_KERNEL_GET_TICK_FREQ_DISABLE,
1004 \c EVR_RTX_KERNEL_GET_SYS_TIMER_COUNT_DISABLE, \c EVR_RTX_KERNEL_GET_SYS_TIMER_FREQ_DISABLE
1005
1006 \b Thread \b events \n
1007 \c EVR_RTX_THREAD_ERROR_DISABLE, \c EVR_RTX_THREAD_NEW_DISABLE, \c EVR_RTX_THREAD_CREATED_DISABLE,
1008 \c EVR_RTX_THREAD_GET_NAME_DISABLE, \c EVR_RTX_THREAD_GET_ID_DISABLE, \c EVR_RTX_THREAD_GET_STATE_DISABLE,
1009 \c EVR_RTX_THREAD_GET_STACK_SIZE_DISABLE, \c EVR_RTX_THREAD_GET_STACK_SPACE_DISABLE, \c EVR_RTX_THREAD_SET_PRIORITY_DISABLE,
1010 \c EVR_RTX_THREAD_GET_PRIORITY_DISABLE, \c EVR_RTX_THREAD_YIELD_DISABLE, \c EVR_RTX_THREAD_SUSPEND_DISABLE,
1011 \c EVR_RTX_THREAD_SUSPENDED_DISABLE, \c EVR_RTX_THREAD_RESUME_DISABLE, \c EVR_RTX_THREAD_RESUMED_DISABLE,
1012 \c EVR_RTX_THREAD_DETACH_DISABLE, \c EVR_RTX_THREAD_DETACHED_DISABLE, \c EVR_RTX_THREAD_JOIN_DISABLE,
1013 \c EVR_RTX_THREAD_JOIN_PENDING_DISABLE, \c EVR_RTX_THREAD_JOINED_DISABLE, \c EVR_RTX_THREAD_BLOCKED_DISABLE,
1014 \c EVR_RTX_THREAD_UNBLOCKED_DISABLE, \c EVR_RTX_THREAD_PREEMPTED_DISABLE, \c EVR_RTX_THREAD_SWITCHED_DISABLE,
1015 \c EVR_RTX_THREAD_EXIT_DISABLE, \c EVR_RTX_THREAD_TERMINATE_DISABLE, \c EVR_RTX_THREAD_DESTROYED_DISABLE,
1016 \c EVR_RTX_THREAD_GET_COUNT_DISABLE, \c EVR_RTX_THREAD_ENUMERATE_DISABLE
1017
1018 \b Thread \b flag \b events \n
1019 \c EVR_RTX_THREAD_FLAGS_SET_DISABLE, \c EVR_RTX_THREAD_FLAGS_SET_DONE_DISABLE, \c EVR_RTX_THREAD_FLAGS_CLEAR_DISABLE,
1020 \c EVR_RTX_THREAD_FLAGS_CLEAR_DONE_DISABLE, \c EVR_RTX_THREAD_FLAGS_GET_DISABLE, \c EVR_RTX_THREAD_FLAGS_WAIT_DISABLE,
1021 \c EVR_RTX_THREAD_FLAGS_WAIT_PENDING_DISABLE, \c EVR_RTX_THREAD_FLAGS_WAIT_TIMEOUT_DISABLE,
1022 \c EVR_RTX_THREAD_FLAGS_WAIT_COMPLETED_DISABLE, \c EVR_RTX_THREAD_FLAGS_WAIT_NOT_COMPLETED_DISABLE
1023
1024 \b Generic \b wait \b events \n
1025 \c EVR_RTX_THREAD_DELAY_DISABLE, \c EVR_RTX_THREAD_DELAY_UNTIL_DISABLE, \c EVR_RTX_THREAD_DELAY_COMPLETED_DISABLE
1026
1027 \b Timer \b events \n
1028 \c EVR_RTX_TIMER_ERROR_DISABLE, \c EVR_RTX_TIMER_CALLBACK_DISABLE, \c EVR_RTX_TIMER_NEW_DISABLE,
1029 \c EVR_RTX_TIMER_CREATED_DISABLE, \c EVR_RTX_TIMER_GET_NAME_DISABLE, \c EVR_RTX_TIMER_START_DISABLE,
1030 \c EVR_RTX_TIMER_STARTED_DISABLE, \c EVR_RTX_TIMER_STOP_DISABLE, \c EVR_RTX_TIMER_STOPPED_DISABLE,
1031 \c EVR_RTX_TIMER_IS_RUNNING_DISABLE, \c EVR_RTX_TIMER_DELETE_DISABLE, \c EVR_RTX_TIMER_DESTROYED_DISABLE
1032
1033 \b Event \b flag \b events \n
1034 \c EVR_RTX_EVENT_FLAGS_ERROR_DISABLE, \c EVR_RTX_EVENT_FLAGS_NEW_DISABLE, \c EVR_RTX_EVENT_FLAGS_CREATED_DISABLE,
1035 \c EVR_RTX_EVENT_FLAGS_GET_NAME_DISABLE, \c EVR_RTX_EVENT_FLAGS_SET_DISABLE, \c EVR_RTX_EVENT_FLAGS_SET_DONE_DISABLE,
1036 \c EVR_RTX_EVENT_FLAGS_CLEAR_DISABLE, \c EVR_RTX_EVENT_FLAGS_CLEAR_DONE_DISABLE, \c EVR_RTX_EVENT_FLAGS_GET_DISABLE,
1037 \c EVR_RTX_EVENT_FLAGS_WAIT_DISABLE, \c EVR_RTX_EVENT_FLAGS_WAIT_PENDING_DISABLE,
1038 \c EVR_RTX_EVENT_FLAGS_WAIT_TIMEOUT_DISABLE, \c EVR_RTX_EVENT_FLAGS_WAIT_COMPLETED_DISABLE,
1039 \c EVR_RTX_EVENT_FLAGS_WAIT_NOT_COMPLETED_DISABLE, \c EVR_RTX_EVENT_FLAGS_DELETE_DISABLE,
1040 \c EVR_RTX_EVENT_FLAGS_DESTROYED_DISABLE
1041
1042 \b Mutex \b events \n
1043 \c EVR_RTX_MUTEX_ERROR_DISABLE, \c EVR_RTX_MUTEX_NEW_DISABLE, \c EVR_RTX_MUTEX_CREATED_DISABLE,
1044 \c EVR_RTX_MUTEX_GET_NAME_DISABLE, \c EVR_RTX_MUTEX_ACQUIRE_DISABLE, \c EVR_RTX_MUTEX_ACQUIRE_PENDING_DISABLE,
1045 \c EVR_RTX_MUTEX_ACQUIRE_TIMEOUT_DISABLE, \c EVR_RTX_MUTEX_ACQUIRED_DISABLE, \c EVR_RTX_MUTEX_NOT_ACQUIRED_DISABLE,
1046 \c EVR_RTX_MUTEX_RELEASE_DISABLE, \c EVR_RTX_MUTEX_RELEASED_DISABLE, \c EVR_RTX_MUTEX_GET_OWNER_DISABLE,
1047 \c EVR_RTX_MUTEX_DELETE_DISABLE, \c EVR_RTX_MUTEX_DESTROYED_DISABLE
1048
1049 \b Semaphore \b events \n
1050 \c EVR_RTX_SEMAPHORE_ERROR_DISABLE, \c EVR_RTX_SEMAPHORE_NEW_DISABLE, \c EVR_RTX_SEMAPHORE_CREATED_DISABLE,
1051 \c EVR_RTX_SEMAPHORE_GET_NAME_DISABLE, \c EVR_RTX_SEMAPHORE_ACQUIRE_DISABLE, \c EVR_RTX_SEMAPHORE_ACQUIRE_PENDING_DISABLE,
1052 \c EVR_RTX_SEMAPHORE_ACQUIRE_TIMEOUT_DISABLE, \c EVR_RTX_SEMAPHORE_ACQUIRED_DISABLE,
1053 \c EVR_RTX_SEMAPHORE_NOT_ACQUIRED_DISABLE, \c EVR_RTX_SEMAPHORE_RELEASE_DISABLE, \c EVR_RTX_SEMAPHORE_RELEASED_DISABLE,
1054 \c EVR_RTX_SEMAPHORE_GET_COUNT_DISABLE, \c EVR_RTX_SEMAPHORE_DELETE_DISABLE, \c EVR_RTX_SEMAPHORE_DESTROYED_DISABLE
1055
1056 \b Memory \b pool \b events \n
1057 \c EVR_RTX_MEMORY_POOL_ERROR_DISABLE, \c EVR_RTX_MEMORY_POOL_NEW_DISABLE, \c EVR_RTX_MEMORY_POOL_CREATED_DISABLE,
1058 \c EVR_RTX_MEMORY_POOL_GET_NAME_DISABLE, \c EVR_RTX_MEMORY_POOL_ALLOC_DISABLE, \c EVR_RTX_MEMORY_POOL_ALLOC_PENDING_DISABLE,
1059 \c EVR_RTX_MEMORY_POOL_ALLOC_TIMEOUT_DISABLE, \c EVR_RTX_MEMORY_POOL_ALLOCATED_DISABLE,
1060 \c EVR_RTX_MEMORY_POOL_ALLOC_FAILED_DISABLE, \c EVR_RTX_MEMORY_POOL_FREE_DISABLE, \c EVR_RTX_MEMORY_POOL_DEALLOCATED_DISABLE,
1061 \c EVR_RTX_MEMORY_POOL_FREE_FAILED_DISABLE, \c EVR_RTX_MEMORY_POOL_GET_CAPACITY_DISABLE,
1062 \c EVR_RTX_MEMORY_POOL_GET_BLOCK_SZIE_DISABLE, \c EVR_RTX_MEMORY_POOL_GET_COUNT_DISABLE,
1063 \c EVR_RTX_MEMORY_POOL_GET_SPACE_DISABLE, \c EVR_RTX_MEMORY_POOL_DELETE_DISABLE, \c EVR_RTX_MEMORY_POOL_DESTROYED_DISABLE
1064
1065 \b Message \b queue \b events \n
1066 \c EVR_RTX_MESSAGE_QUEUE_ERROR_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_NEW_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_CREATED_DISABLE,
1067 \c EVR_RTX_MESSAGE_QUEUE_GET_NAME_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_PUT_DISABLE,
1068 \c EVR_RTX_MESSAGE_QUEUE_PUT_PENDING_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_PUT_TIMEOUT_DISABLE,
1069 \c EVR_RTX_MESSAGE_QUEUE_INSERT_PENDING_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_INSERTED_DISABLE,
1070 \c EVR_RTX_MESSAGE_QUEUE_NOT_INSERTED_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_GET_DISABLE,
1071 \c EVR_RTX_MESSAGE_QUEUE_GET_PENDING_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_GET_TIMEOUT_DISABLE,
1072 \c EVR_RTX_MESSAGE_QUEUE_RETRIEVED_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_NOT_RETRIEVED_DISABLE,
1073 \c EVR_RTX_MESSAGE_QUEUE_GET_CAPACITY_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_GET_MSG_SIZE_DISABLE,
1074 \c EVR_RTX_MESSAGE_QUEUE_GET_COUNT_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_GET_SPACE_DISABLE,
1075 \c EVR_RTX_MESSAGE_QUEUE_RESET_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_RESET_DONE_DISABLE,
1076 \c EVR_RTX_MESSAGE_QUEUE_DELETE_DISABLE, \c EVR_RTX_MESSAGE_QUEUE_DESTROYED_DISABLE
1077
1078
1079 */
1080
1081
1082 /* ========================================================================================================================== */
1083 /** 
1084 \page creating_RTX5_LIB Building the RTX5 Library
1085
1086 The CMSIS Pack contains a µVision project for building the complete set of RTX5 libraries. This project can also be used as
1087 a reference for building the RTX5 libraries using a tool-chain of your choice.
1088
1089 -# Open the project \b RTX_CM.uvprojx from the pack folder <b>CMSIS/RTOS2/RTX/Library/ARM/MDK</b> in µVision.
1090 -# Select the project target that matches your device's processor core. 
1091    \n The project provides target configuration for all supported Cortex-M targets supported by RTX5.
1092 -# You can find out about the required preprocessor defines in the dialogs <b>Options for Target - C/C++</b> and
1093    <b>Options for Target - Asm</b>. Note the need to use at least the C99 compiler mode when building RTX from source.
1094 -# From the <b>Project</b> window you find the list of source files required for a complete library build.
1095 -# Build the library of your choice using \b Project - \b Build \b Target (or press F7).
1096
1097 \image html own_lib_projwin.png "Project with files for Armv8-M Mainline"
1098 */
1099
1100
1101
1102 /* ========================================================================================================================== */
1103 /** 
1104 \page technicalData5 Technical Data
1105
1106 The following section contains technical information about RTX v5.
1107
1108  - \subpage pHardwareRequirements lists the resource requirements of the RTX v5 kernel along with hardware dependencies.
1109  - \subpage pControlBlockSizes provides memory size information for \ref StaticObjectMemory "object-specific control block memory allocation".
1110  - \subpage pDirectory_Files is an overview of the supplied files that belong to RTX v5
1111  - \subpage pToolchains details about the compiler support which includes ArmCC (MDK, DS-5), IAR EW-ARM, and GCC.
1112  
1113
1114
1115 \page pHardwareRequirements Hardware Requirements
1116
1117 The following section lists the hardware requirements for RTX v5 on the various supported target processors:
1118
1119 \section tpProcessor Processor Requirements
1120
1121 RTX assumes a fully function-able processor and uses the following hardware features. It does not implement any confidence test for processor validation which should be provided by an user-supplied software test library.
1122
1123
1124 \subsection tpCortexM0_M0P_M23 Cortex-M0/M0+/M23 target processor
1125
1126
1127 Hardware Requirement       | Description
1128 :--------------------------|:------------------------------------------------------
1129 SysTick timer              | The SysTick timer generates the kernel tick interrupts and the interface is implemented in %os_systick.c using the \ref CMSIS_RTOS_TickAPI
1130 Exception Handler          | RTX implements exception handlers for SVC, PendSV, and SysTick interrupt
1131 Core Registers             | The processor status is read using the following core registers: CONTROL, IPSR, PRIMASK
1132 System Control Block (SBC) | To control and setup the processor exceptions including PendSV and SVC
1133 Interrupt Control          | The CMSIS-Core functions __disable_irq and __enable_irq to control the interrupt system via the CPSR core register.
1134
1135 The interface files to the processor hardware are: 
1136  - <b>%irq_cm0.s</b> defines exception handlers for Cortex-M0/M0+
1137  - <b>%irq_armv8mbl_common.s</b> defines exception handlers for Cortex-M23
1138  - <b>%rtx_core_cm.h</b> defines processor specific helper functions and the interfaces to Core Registers and Core Peripherals.
1139  - <b>%os_tick.h</b> is the \ref CMSIS_RTOS_TickAPI that defines the interface functions to the SysTick timer.
1140
1141 \note
1142  - The CMSIS-Core variable \c SystemCoreClock is used to configure the SysTick timer. 
1143
1144 \subsection tpCortexM3_M4_M7_M33 Cortex-M3/M4/M7/M33 target processor
1145
1146 RTX assumes a fully function-able processor and uses the following hardware features:
1147
1148 Hardware Requirement       | Description
1149 :--------------------------|:------------------------------------------------------
1150 SysTick timer              | The SysTick timer generates the kernel tick interrupts and the interface is implemented in %os_systick.c using the \ref CMSIS_RTOS_TickAPI
1151 Exception Handler          | RTX implements exception handlers for SVC, PendSV, and SysTick interrupt
1152 Core Registers             | The processor status is read using the following core registers: CONTROL, IPSR, PRIMASK, BASEPRI
1153 System Control Block (SBC) | To control and setup the processor exceptions including PendSV and SVC
1154 NVIC Interface             | The CMSIS-Core function NVIC_GetPriorityGrouping to setup interrupt priorities.
1155 LDREX, STREX instruction   | Atomic execution avoids the requirement to disable interrupts and is implemented via exclusive access instructions.
1156
1157 The interface files to the processor hardware are: 
1158  - <b>%irq_cm3.s</b> defines exception handlers for Cortex-M3 and Cortex-M4/M7 without floating point unit.
1159  - <b>%irq_cm4f.s</b> defines exception handlers for Cortex-M4/M7 with floating point unit.
1160  - <b>%irq_armv8mml_common.s</b> defines exception handlers for Cortex-M33
1161  - <b>%rtx_core_cm.h</b> defines processor specific helper functions and the interfaces to Core Registers and Core Peripherals.
1162  - <b>%os_tick.h</b> is the \ref CMSIS_RTOS_TickAPI that defines the interface functions to the SysTick timer.
1163
1164 \note
1165  - The CMSIS-Core variable \c SystemCoreClock is used to configure the SysTick timer. 
1166
1167 \subsection tpCortexA5_A7_A9 Cortex-A5/A7/A9 target processor
1168
1169
1170
1171 \section rMemory Memory Requirements
1172 RTX requires RAM memory that is accessible with contiguous linear addressing.  When memory is split across multiple memory banks, some systems 
1173 do not accept multiple load or store operations on this memory blocks. 
1174
1175 RTX does not implement any confidence test for memory validation. This should be implemented by an user-supplied software test library.
1176
1177
1178
1179 \page pControlBlockSizes Control Block Sizes
1180
1181 Keil RTX v5 specific control block definitions (including sizes) as well as memory pool and message queue memory requirements
1182 are defined in the header file <b>rtx_os.h</b>:
1183
1184 If you provide memory for the RTOS objects, you need to know the size that is required for each object control block.
1185 The memory of the control block is provided by the parameter \em attr of the related \em osXxxxNew function.
1186 The element \em cb_mem is the memory address, \em cb_size is the size of the control block memory.
1187
1188 Refer to \ref StaticObjectMemory for more information.
1189
1190 The following table lists the control block sizes:
1191
1192 Category                      | Control Block Size Attribute      | Size       | \#define symbol
1193 :-----------------------------|:----------------------------------|:-----------|:--------------------
1194 \ref CMSIS_RTOS_ThreadMgmt    | \ref osThreadAttr_t::cb_mem       | 68 bytes   | \ref osRtxThreadCbSize
1195 \ref CMSIS_RTOS_TimerMgmt     | \ref osTimerAttr_t::cb_mem        | 32 bytes   | \ref osRtxTimerCbSize
1196 \ref CMSIS_RTOS_EventFlags    | \ref osEventFlagsAttr_t::cb_mem   | 16 bytes   | \ref osRtxEventFlagsCbSize
1197 \ref CMSIS_RTOS_MutexMgmt     | \ref osMutexAttr_t::cb_mem        | 28 bytes   | \ref osRtxMutexCbSize
1198 \ref CMSIS_RTOS_SemaphoreMgmt | \ref osSemaphoreAttr_t::cb_mem    | 16 bytes   | \ref osRtxSemaphoreCbSize
1199 \ref CMSIS_RTOS_PoolMgmt      | \ref osMemoryPoolAttr_t::cb_mem   | 36 bytes   | \ref osRtxMemoryPoolCbSize
1200 \ref CMSIS_RTOS_Message       | \ref osMessageQueueAttr_t::cb_mem | 52 bytes   | \ref osRtxMessageQueueCbSize
1201
1202
1203
1204 \page pDirectory_Files Directory Structure and File Overview
1205
1206 The following section provides an overview of the directory structure and the files that are relevant for the user's for
1207 CMSIS-RTOS RTX v5. The following directory references start below the CMSIS pack installation path, for example
1208 ARM/CMSIS/<i>version</i>/CMSIS/RTOS2.
1209
1210 \section Folders RTX v5 Directory Structure
1211
1212 The CMSIS-RTOS RTX v5 is delivered in source code and several examples are provided. 
1213
1214 <table class="cmtable" summary="CMSIS-RTOS RTX Library Files">
1215     <tr>
1216       <th>Directory</th>
1217       <th>Content</th>
1218     </tr>
1219     <tr>
1220       <td>Include</td>
1221       <td>Header files: \b %cmsis_os2.h for \ref rtos_api2 and \b %os_tick.h for \ref rtos_os_tick_api.</td>
1222     </tr>
1223     <tr>
1224       <td>Source</td>
1225       <td>Generic <b>OS tick</b> implementations for various processors based on \ref rtos_os_tick_api.</td>
1226     </tr>
1227     <tr>
1228       <td>Template</td>
1229       <td><a class="el" href="../../RTOS/html/index.html">CMSIS-RTOS API v1</a> template source and header file.</td>
1230     </tr>
1231     <tr>
1232       <td>RTX</td>
1233       <td>Directory with RTX specific files and folders. Also contains the component viewer description file.</td>
1234     </tr>
1235     <tr>
1236       <td>RTX/Config</td>
1237       <td>CMSIS-RTOS RTX configuration files %RTX_Config.h and %RTX_Config.c.</td>
1238     </tr>
1239     <tr>
1240       <td>RTX/Examples</td>
1241       <td>Example projects that can be directly used in development tools.</td>
1242     </tr>
1243     <tr>
1244       <td>RTX/Include</td>
1245       <td>RTX v5 specific include files.</td>
1246     </tr>
1247     <tr>
1248       <td>RTX/Include1</td>
1249       <td>CMSIS-RTOS v1 API header file.</td>
1250     </tr>
1251     <tr>
1252       <td>RTX/Library</td>
1253       <td>Pre-built libraries (see next table for details).</td>
1254     </tr>
1255     <tr>
1256       <td>RTX/Source</td>
1257       <td>Source code that can be used with ARMCC and GCC.</td>
1258     </tr>
1259     <tr>
1260       <td>RTX/Template</td>
1261       <td>User code templates for creating application projects with CMSIS-RTOS RTX v5.</td>
1262     </tr>
1263 </table>
1264
1265 \section libFiles RTX v5 Library Files
1266
1267 The CMSIS-RTOS RTX Library is available pre-compiled for ARMCC and GCC compilers and supports all Cortex-M
1268 processor variants in every configuration, including Arm Cortex-M23 and Cortex-M33.
1269
1270 <table class="cmtable" summary="CMSIS-RTOS RTX Library Files">
1271     <tr>
1272       <th>Library File</th>
1273       <th>Processor Configuration</th>
1274     </tr>
1275     <tr>
1276       <td>Library/ARM/RTX_CM0.lib</td>
1277       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Cortex-M0 and M1, little-endian.</td>
1278     </tr>
1279     <tr>
1280       <td>Library/ARM/RTX_CM3.lib</td>
1281       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Cortex-M3, M4, and M7 without FPU, little-endian.</td>
1282     </tr>
1283     <tr>
1284       <td>Library/ARM/RTX_CM4F.lib</td>
1285       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Cortex-M4 and M7 with FPU, little-endian.</td>
1286     </tr>
1287     <tr>
1288       <td>Library/ARM/RTX_V8MB.lib</td>
1289       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Armv8-M Baseline.</td>
1290     </tr>
1291     <tr>
1292       <td>Library/ARM/RTX_V8MBN.lib</td>
1293       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Armv8-M Baseline, non-secure.</td>
1294     </tr>
1295     <tr>
1296       <td>Library/ARM/RTX_V8MM.lib</td>
1297       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Armv8-M Mainline.</td>
1298     </tr>
1299     <tr>
1300       <td>Library/ARM/RTX_V8MMF.lib</td>
1301       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Armv8-M Mainline with FPU.</td>
1302     </tr>
1303     <tr>
1304       <td>Library/ARM/RTX_V8MMFN.lib</td>
1305       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Armv8-M Mainline with FPU, non-secure.</td>
1306     </tr>
1307     <tr>
1308       <td>Library/ARM/RTX_V8MMN.lib</td>
1309       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Armv8-M Mainline, non-secure.</td>
1310     </tr>
1311     <tr>
1312       <td>Library/GCC/libRTX_CM0.a</td>
1313       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Cortex-M0 and M1, little-endian.</td>
1314     </tr>
1315     <tr>
1316       <td>Library/GCC/libRTX_CM3.a</td>
1317       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Cortex-M3, M4, and M7 without FPU, little-endian.</td>
1318     </tr>
1319     <tr>
1320       <td>Library/GCC/libRTX_CM4F.a</td>
1321       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Cortex-M4 and M7 with FPU, little-endian.</td>
1322     </tr>
1323     <tr>
1324       <td>Library/GCC/libRTX_V8MB.a</td>
1325       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Armv8-M Baseline.</td>
1326     </tr>
1327     <tr>
1328       <td>Library/GCC/libRTX_V8MBN.a</td>
1329       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Armv8-M Baseline, non-secure.</td>
1330     </tr>
1331     <tr>
1332       <td>Library/GCC/libRTX_V8MM.a</td>
1333       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Armv8-M Mainline.</td>
1334     </tr>
1335     <tr>
1336       <td>Library/GCC/libRTX_V8MMF.a</td>
1337       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Armv8-M Mainline with FPU.</td>
1338     </tr>
1339     <tr>
1340       <td>Library/GCC/libRTX_V8MMFN.a</td>
1341       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Armv8-M Mainline with FPU, non-secure.</td>
1342     </tr>
1343     <tr>
1344       <td>Library/GCC/libRTX_V8MMN.a</td>
1345       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Armv8-M Mainline, non-secure.</td>
1346     </tr>
1347 </table>
1348
1349  
1350 \page pToolchains Supported Toolchains
1351
1352 Keil RTX5 is developed and tested using the common toolchains and development environments.
1353
1354 \section technicalData_Toolchain_ARM Arm Compiler (Arm/Keil MDK, uVision5)
1355
1356 RTX5 is initially developed and optimized using Arm Compiler and Arm/Keil MDK.
1357 The current release is tested with the following versions:
1358 <ul>
1359  <li>Arm Compiler 5.06 Update 6</li>
1360  <li>Arm Compiler 6.6.2 (Long Term Maintenance)</li>
1361  <li>Arm Compiler 6.9</li>
1362  <li>RTOS-aware debugging with uVision 5.24</li>
1363 </ul>
1364
1365 \section technicalData_Toolchain_IAR IAR Embedded Workbench
1366
1367 RTX5 has been ported to the IAR Embedded Workbench. The following releases are known to work:
1368 <ul>
1369  <li>IAR Embedded Workbench 7.7 (<a href="https://github.com/ARM-software/CMSIS_5/issues/201">community report</a>)</li>
1370  <li>IAR Embedded Workbench 7.80.4</li>
1371  <li><b>IAR Embedded Workbench 8.20.1</b></li>
1372 </ul>
1373
1374 \section technicalData_Toolchain_GCC GNU Compiler Collection
1375
1376 RTX5 has also been ported to support GCC, maintenance mainly relays on community contribution.
1377 Active development is currently tested with:
1378 <ul>
1379  <li>GNU Tools for Arm Embedded 6.3.1 20170620</li>
1380 </ul>
1381
1382 */
1383
1384 /* ========================================================================================================================== */
1385 /** 
1386 \page CodingRules Coding Rules
1387
1388 CMSIS components use <a href="../../General/html/index.html#CodingRules"><b>general coding rules</b></a> across the various components.
1389
1390 The CMSIS-RTOS2 API is using the following <b>Namespace</b> prefixes:
1391   - <b>os</b> for all definitions and function names.
1392   - <b>os</b> with postfix <b>_t</b> for all typedefs.
1393   
1394 The CMSIS-RTOS2 RTX v5 implementation is using the following <b>Namespace</b> prefixes for public symbol definitions:
1395   - <b>osRtx</b> for all general definitions and function names that relate to the RTX kernel.
1396   - <b>osRtx</b> with postfix <b>_t</b> for all typedefs.
1397   - <b>OS_Tick_</b> for interface functions to the hardware system tick timer.
1398   - <b>EvrRtx</b> for event function annotations that interface to the Event Recorder.
1399 */
1400
1401 /* ========================================================================================================================== */
1402 /** 
1403 \page misraCompliance5 MISRA C:2012 Compliance 
1404 The RTX5 C source files use <b><a class=el href="http://www.misra.org.uk/" target="_blank">MISRA C:2012</a></b> guidelines as underlying coding standard.
1405
1406 For MISRA validation, <b><a class=el href="http://www.gimpel.com/" target="_blank">PC-lint</a></b> V9.00L is used with configuration for Arm Compiler V6.9.
1407 The PC-Lint validation setup is part of the project file <b>.\\CMSIS\\RTOS2\\RTX\\Library\\ARM\\MDK\\RTX_CM.uvprojx</b> as shown below. 
1408 Refer to <b><a class=el href="http://www.keil.com/support/man/docs/uv4/uv4_ut_pclint_validation.htm" target="_blank">Setup for PC-Lint</a></b> for more information.
1409
1410 \image html "PC-Lint.png" "Running PC-Lint within MDK - uVision"
1411
1412 The PC-Lint configuration uses the following Options under <b>Tools - PC-Lint Setup...</b>:
1413  - Config File: co-ARMCC-6.lnt (20-Mar-2017) with additional options:
1414 \code
1415    +rw(__restrict)
1416    -esym(526,__builtin_*) -esym(628,__builtin_*)
1417    -sem(__builtin_clz, pure)
1418    +doffsetof(t,m)=((size_t)&((t*)0)->m) -emacro((413,923,9078),offsetof)
1419    -ecall(534,__disable_irq)
1420 \endcode
1421  - Included Project Information: 
1422    - Enable: Add 'Include' paths
1423    - Enable: Add 'Software Packs' paths
1424    - Enable: Verify 'Software Packs' includes
1425    - Enable: Add 'Preprocessor' symbols
1426    - Enable: Add 'Define' symbols
1427  - MISRA  Rules Setup and Configuration: 
1428    - MISRQ_C_2012_Config.lnt; all rules enabled
1429    - includes definition file: au-misra3.lnt (12-Jun-2014)
1430  - Additional Lint Commands (for both single and mutiple files):
1431 \code
1432    - emacro(835,osRtxConfigPrivilegedMode)
1433 \endcode
1434
1435 The C source code is annotated with PC-Lint control comments to allows MISRA deviations.
1436 These deviations with the underlaying design decisions are described in the following.
1437    
1438 Deviations
1439 ----------
1440
1441 The RTX source code has the following deviations from MISRA:
1442   - \ref MISRA_1
1443   - \ref MISRA_2
1444   - \ref MISRA_3
1445   - \ref MISRA_4
1446   - \ref MISRA_5
1447   - \ref MISRA_6
1448   - \ref MISRA_7
1449   - \ref MISRA_8
1450   - \ref MISRA_9
1451   - \ref MISRA_10
1452   - \ref MISRA_11
1453   - \ref MISRA_12
1454   - \ref MISRA_13
1455
1456 All source code deviations are clearly marked and in summary these deviations affect the following MISRA rules:
1457  - [MISRA 2012 Directive  4.9,  advisory]: A function should be used in preference to a function-like macro where yet are interchangeable
1458  - [MISRA 2012 Rule       1.3,  required]: There shall be no occurrence of undefined or critical unspecified behavior
1459  - [MISRA 2012 Rule      10.3,  required]: Expression assigned to a narrower or different essential type
1460  - [MISRA 2012 Rule      10.5,  advisory]: Impermissible cast; cannot cast from 'essentially unsigned' to 'essentially enum\<i\>'
1461  - [MISRA 2012 Rule      11.1,  required]: Conversions shall not be performed between a pointer to a function and any other type
1462  - [MISRA 2012 Rule      11.3,  required]: A cast shall not be performed between a pointer to object type and a pointer to a different object type
1463  - [MISRA 2012 Rule      11.4,  advisory]: A conversion should not be performed between a pointer to object and an integer type
1464  - [MISRA 2012 Rule      11.5,  advisory]: A conversion should not be performed from pointer to void into pointer to object
1465  - [MISRA 2012 Rule      11.6,  required]: A cast shall not be performed between pointer to void and an arithmetic type
1466  - [MISRA 2012 Rule      15.5,  advisory]: A function should have a single point of exit at the end
1467  - [MISRA 2012 Rule      20.10, advisory]: The # and ## preprocessor operators should not be used
1468
1469 In the following all deviations are described in detail.
1470
1471 \section MISRA_1 [MISRA Note 1]: Return statements for parameter checking
1472
1473 Return statements are used at the beginning of several functions to validate parameter values and object states.
1474 The function returns immediately without any side-effects and typically an error status is set. This structure
1475 keeps the source code better structured and easier to understand.
1476
1477 This design decision implies the following MISRA deviation:
1478  - [MISRA 2012 Rule      15.5,  advisory]: A function should have a single point of exit at the end
1479
1480 All locations in the source code are marked with: 
1481 \code
1482   //lint -e{904} "Return statement before end of function" [MISRA Note 1]
1483 \endcode 
1484
1485
1486 \section MISRA_2 [MISRA Note 2]: Object identifiers are void pointers
1487
1488 CMSIS-RTOS is independant of an underlying RTOS implementation. The object idenifiers are therefore defined as void pointers to:
1489   - allow application programs that are agnostic from an underlying RTOS implementation.
1490   - avoid accidently accesses an RTOS control block from an application program.
1491
1492 This design decisions imply the following MISRA deviations:
1493  - [MISRA 2012 Rule      11.3,  required]: A cast shall not be performed between a pointer to object type and a pointer to a different object type
1494  - [MISRA 2012 Rule      11.5,  advisory]: A conversion should not be performed from pointer to void into pointer to object
1495
1496 All locations in the source code are marked with: 
1497 \code
1498   //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 2]
1499 \endcode 
1500
1501 In the RTX5 implementation the requried pointer conversions are implemented in the header file rtx_lib.h with the following inline functions:
1502
1503 \code
1504 osRtxThread_t       *osRtxThreadId (osThread_t thread_id);
1505 osRtxTimer_t        *osRtxTimerId (osTimer_t timer_id);
1506 osRtxEventFlags_t   *osRtxEventFlagsId (osEventFlags_t ef_id);
1507 osRtxMutex_t        *osRtxMutexId (osMutex_t mutex_id);
1508 osRtxSemaphore_t    *osRtxSemaphoreId (osSemaphore_t semaphore_id);
1509 osRtxMemoryPool_t   *osRtxMemoryPoolId (osMemoryPoolId_t mp_id);
1510 osRtxMessageQueue_t *osRtxMessageQueueId(osMessageQueueId_t mq_id);
1511 \endcode
1512
1513 \section MISRA_3 [MISRA Note 3]: Conversion to unified object control blocks
1514
1515 RTX uses a unified object control block structure that contains common object members.
1516 The unified control blocks use a fixed layout at the beginning of the sturcture and starts always with an object identifier.
1517 This allows common object functions that receive a pointer to a unified object control block and reference only the
1518 pointer or the members in the fixed layout. Using common object functions and data (for example the ISR queue) reduces 
1519 code complexity and keeps the source code better structured.  Refer also to \ref MISRA_4
1520
1521 This design decisions imply the following MISRA deviations:
1522  - [MISRA 2012 Rule      11.3,  required]: A cast shall not be performed between a pointer to object type and a pointer to a different object type
1523  - [MISRA 2012 Rule      11.5,  advisory]: A conversion should not be performed from pointer to void into pointer to object
1524
1525 All locations in the source code are marked with: 
1526 \code
1527   //lint -e{9079} -e{9087} "cast from pointer to void to pointer to object type" [MISRA Note 3]
1528 \endcode 
1529
1530
1531 In the RTX5 implementation the requried pointer conversions are implemented in the header file \em rtx_lib.h with the following inline function:
1532
1533 \code
1534 osRtxObject_t *osRtxObject (void *object);
1535 \endcode
1536
1537
1538 \section MISRA_4 [MISRA Note 4]: Conversion from unified object control blocks
1539
1540 RTX uses a unified object control block structure that contains common object members. Refer to \ref MISRA_3 for more information.
1541 To process specifc control block data, pointer conversions are required.
1542
1543 This design decisions imply the following MISRA deviations:
1544  - [MISRA 2012 Rule       1.3,  required]: There shall be no occurrence of undefined or critical unspecified behavior
1545  - [MISRA 2012 Rule      11.3,  required]: A cast shall not be performed between a pointer to object type and a pointer to a different object type
1546 In addition PC-Lint issues:
1547  - Info  826: Suspicious pointer-to-pointer conversion (area too small)
1548
1549 All locations in the source code are marked with: 
1550 \code
1551   //lint -e{740} -e{826} -e{9087} "cast from pointer to generic object to specific object" [MISRA Note 4]
1552 \endcode 
1553
1554 In the RTX5 source code the requried pointer conversions are implemented in the header file \em rtx_lib.h with the following inline functions:
1555
1556 \code
1557 osRtxThread_t       *osRtxThreadObject (osRtxObject_t *object);
1558 osRtxTimer_t        *osRtxTimerObject (osRtxObject_t *object);
1559 osRtxEventFlags_t   *osRtxEventFlagsObject (osRtxObject_t *object);
1560 osRtxMutex_t        *osRtxMutexObject (osRtxObject_t *object);
1561 osRtxSemaphore_t    *osRtxSemaphoreObject (osRtxObject_t *object);
1562 osRtxMemoryPool_t   *osRtxMemoryPoolObject (osRtxObject_t *object);
1563 osRtxMessageQueue_t *osRtxMessageQueueObject (osRtxObject_t *object);
1564 osRtxMessage_t      *osRtxMessageObject (osRtxObject_t *object);
1565 \endcode
1566
1567 \section MISRA_5 [MISRA Note 5]: Conversion to object types
1568
1569 The RTX5 kernel has common memory management functions that use void pointers. These memory allocation fuctions returns 
1570 a void pointer which is correctly aligned for object types.
1571
1572 This design decision implies the following MISRA deviations:
1573  - [MISRA 2012 Rule      11.5,  advisory]: A conversion should not be performed from pointer to void into pointer to object
1574
1575 All locations in the source code are marked with: 
1576 \code
1577   //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5]
1578 \endcode 
1579
1580 Code example:
1581
1582 \code 
1583   os_thread_t  *thread;
1584    :
1585   //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5]
1586   thread = osRtxMemoryPoolAlloc(osRtxInfo.mpi.thread);
1587 \endcode
1588
1589
1590
1591 \section MISRA_6 [MISRA Note 6]: Conversion from user provided storage
1592
1593 CMSIS-RTOS2 and RTX5 support user provided storage for object control blocks, stack, and data storage.
1594 The API uses void pointers to define the location of this user provided storage. It is therefore
1595 required to cast the void pointer to underlying storage types. Alignment restrictions of user provided storage 
1596 are checked before accessing memory. Refer also to \ref MISRA_7.
1597
1598 This design decisions imply the following MISRA deviations:
1599  - [MISRA 2012 Rule      11.3,  required]: A cast shall not be performed between a pointer to object type and a pointer to a different object type
1600  - [MISRA 2012 Rule      11.5,  advisory]: A conversion should not be performed from pointer to void into pointer to object
1601
1602 All locations in the source code are marked with: 
1603 \code
1604   //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6]
1605 \endcode 
1606
1607 Code example:
1608 \code
1609 static osTimerId_t svcRtxTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) {
1610   os_timer_t *timer;
1611     :
1612   if (attr != NULL) {
1613     :
1614     //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6]
1615     timer = attr->cb_mem;
1616         :
1617 \endcode        
1618
1619 \section MISRA_7 [MISRA Note 7]: Check for proper pointer alignment
1620
1621 RTX5 verifies the alignment of user provided storage for object control blocks, stack, and data storage.
1622 Refer also to \ref MISRA_6 for more information.
1623
1624 This design decision implies the following MISRA deviations:
1625  - [MISRA 2012 Rule      11.4,  advisory]: A conversion should not be performed between a pointer to object and an integer type
1626  - [MISRA 2012 Rule      11.6,  required]: A cast shall not be performed between pointer to void and an arithmetic type
1627
1628 All locations in the source code are marked with: 
1629 \code
1630   //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7]
1631 \endcode
1632
1633 Code example:
1634 \code
1635 static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
1636     :
1637   void         *stack_mem;
1638     :
1639   if (stack_mem != NULL) {
1640     //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7]
1641     if ((((uint32_t)stack_mem & 7U) != 0U) || (stack_size == 0U)) {
1642     :
1643 \endcode        
1644
1645 \section MISRA_8 [MISRA Note 8]: Memory allocation management
1646
1647 RTX5 implements memory allocation functions which require pointer arithmetic to manage memory.
1648 The structure with the type \em mem_block_t that is used to menage memory allocation blocks is defined in \em rtx_memory.c
1649
1650 This design decision implies the following MISRA deviations:
1651  - [MISRA 2012 Rule      11.4,  advisory]: A conversion should not be performed between a pointer to object and an integer type
1652  - [MISRA 2012 Rule      11.6,  required]: A cast shall not be performed between pointer to void and an arithmetic type
1653
1654 All locations in the source code are marked with: 
1655 \code
1656   //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 8]
1657 \endcode
1658
1659 The required pointer arithmetic is implemented in \em rtx_memory.c with the following function:
1660 \code
1661 __STATIC_INLINE mem_block_t *MemBlockPtr (void *mem, uint32_t offset) {
1662   uint32_t     addr;
1663   mem_block_t *ptr;
1664
1665   //lint --e{923} --e{9078} "cast between pointer and unsigned int" [MISRA Note 8]
1666   addr = (uint32_t)mem + offset;
1667   ptr  = (mem_block_t *)addr;
1668
1669   return ptr;
1670 }
1671 \endcode
1672
1673 \section MISRA_9 [MISRA Note 9]: Pointer conversions for register access
1674
1675 The CMSIS-Core peripheral register blocks are accessed using a structure. The memory address of this structure 
1676 is specified as unsigned integer number. Pointer conversions are required to access the specific registers.
1677
1678 This design decision implies the following MISRA deviations:
1679  - [MISRA 2012 Rule      11.4,  advisory]: A conversion should not be performed between a pointer to object and an integer type
1680  - [MISRA 2012 Rule      11.6,  required]: A cast shall not be performed between pointer to void and an arithmetic type
1681
1682 All locations in the source code are marked with: 
1683 \code
1684   //lint -emacro((923,9078),SCB) "cast from unsigned long to pointer" [MISRA Note 9]
1685 \endcode
1686
1687
1688 Code example:
1689 \code
1690 #define SCS_BASE  (0xE000E000UL)
1691 #define SCB      ((SCB_Type *)SCB_BASE)
1692 typedef struct {...} SCB_Type;
1693
1694 SCB->... = ...;
1695 \endcode
1696
1697 \section MISRA_10 [MISRA Note 10]: SVC calls use function-like macros
1698
1699 RTX5 is using SVC (Service Calls) to switch between thread mode (for user code execution) and handler mode (for RTOS kernel execution).
1700 The SVC function call mechanism is implemented with assembly instructions to construct the code for SVC.
1701 The source code uses C macros and are designed as C function-like macros to generate parameter passing
1702 for variables depending on macro parameters. An alternative replacement code would be complex.
1703 The C macros use multiple '##' operators however it has been verified that the order of evaluation is irrelevant 
1704 and result of macro expansion is always predictable.
1705
1706 This design decision implies the following MISRA deviations:
1707  - [MISRA 2012 Directive  4.9,  advisory]: A function should be used in preference to a function-like macro where yet are interchangeable
1708  - [MISRA 2012 Rule       1.3,  required]: There shall be no occurrence of undefined or critical unspecified behavior
1709  - [MISRA 2012 Rule      20.10, advisory]: The # and ## preprocessor operators should not be used
1710
1711 The relevant source code is in the file \em rtx_core_cm.h and is marked with: 
1712 \code
1713   //lint -save -e9023 -e9024 -e9026 "Function-like macros using '#/##'" [MISRA Note 10]
1714 \endcode
1715
1716
1717 \section MISRA_11 [MISRA Note 11]: SVC calls use assembly code
1718
1719 The SVC (Service Call) functions are constructed as a mix of C and inline assembly as it is required to access CPU registers
1720 for parameter passing. The function parameters are mapped to the CPU registers R0..R3 and SVC function number to 
1721 CPU register R12 (or R7). For assembly inter-working the function parameters are casted to unsigned int values.
1722
1723 The function return value after SVC call is mapped to the CPU register R0. Return value is casted from unsigned int 
1724 to the target value. 
1725
1726 It has been verified that this method has has no side-effects and is well defined.
1727
1728 This design decision implies the following MISRA deviations:
1729  - [MISRA 2012 Rule      10.3,  required]: Expression assigned to a narrower or different essential type
1730  - [MISRA 2012 Rule      10.5,  advisory]: Impermissible cast; cannot cast from 'essentially unsigned' to 'essentially enum\<i\>'
1731  - [MISRA 2012 Rule      11.1,  required]: Conversions shall not be performed between a pointer to a function and any other type
1732  - [MISRA 2012 Rule      11.4,  advisory]: A conversion should not be performed between a pointer to object and an integer type
1733  - [MISRA 2012 Rule      11.6,  required]: A cast shall not be performed between pointer to void and an arithmetic type
1734
1735 SVC functions are marked as library modules and not processed by PC-lint. The relevant source code is marked with: 
1736 \code
1737   //lint ++flb "Library Begin" [MISRA Note 11]
1738     :
1739   //lint --flb "Library End"
1740 \endcode
1741
1742 Code example:
1743 \code
1744 //  Service Calls definitions
1745 //lint ++flb "Library Begin" [MISRA Note 11]
1746 SVC0_1(Delay,      osStatus_t, uint32_t)
1747 SVC0_1(DelayUntil, osStatus_t, uint32_t)
1748 //lint --flb "Library End"
1749 \endcode
1750
1751 PC-lint does not process ASM input/output operand lists and therefore falsely identifies issues:
1752  - Last value assigned to variable not used
1753  - Symbol not subsequently referenced
1754 \todo: what has been done to mitigate that?
1755
1756
1757 \section MISRA_12 [MISRA Note 12]: Usage of exclusive access instructions
1758
1759 The RTX5 implementation uses the CPU instructions LDREX and STREX (when supported by the processor) to implement atomic operations.
1760 This atomic operations elimite the requirement for interrupt lock-outs. The atomic operations are implemented using 
1761 inline assembly.
1762
1763 PC-lint cannot process assembler instructions including the input/output operand lists and therefore falsely identifies issues:
1764  - Symbol not initialized
1765  - Symbol not subsequently referenced
1766  - Symbol not referenced
1767  - Pointer parameter could be declared as pointing to const
1768
1769 It has been verified that atomic operations have no side-effects and are well defined.
1770
1771 The functions that implement atomic instructions are marked as library modules and not processed by PC-lint. The relevant source code is marked with: 
1772 \code
1773   //lint ++flb "Library Begin" [MISRA Note 12]
1774     :
1775   //lint --flb "Library End"
1776 \endcode
1777
1778
1779 \section MISRA_13 [MISRA Note 13]: Usage of Event Recorder
1780
1781 The Event Recorder is a generic event logger and the related functions are called to record an event.
1782 The function parameters are 32-bit id, 32-bit values, pointer to void (data) and are recorded as 32-bit numbers.
1783 The parameters for the Event Recorder may require cast opertions to unsigned int which however has no side-effects 
1784 and is well defined. 
1785
1786 The return value indicates success or failure. There is no need to check the return value since no action is 
1787 taken when a Event Recorder function fail. The EventID macro (part of external Event Recorder) constructs the 
1788 ID based on input parameters which are shifted, masked with '&' and combined with '|'.
1789 Zero value input parameters are valid and cause zero used with '&' and '|'.
1790
1791 The usage of the Event Recorder implies the following MISRA deviations:
1792  - [MISRA 2012 Rule      11.1,  required]: Conversions shall not be performed between a pointer to a function and any other type
1793  - [MISRA 2012 Rule      11.4,  advisory]: A conversion should not be performed between a pointer to object and an integer type
1794  - [MISRA 2012 Rule      11.6,  required]: A cast shall not be performed between pointer to void and an arithmetic type
1795 In addition PC-Lint issues:
1796  - Info  835: A zero has been given as left argument to operator '&'
1797  - Info  845: The right argument to operator '|' is certain to be 0
1798
1799 The functions that call the Event Recorder are in the module \em rtx_evr.c and the related PC-Lint messages are disabled with:
1800 \code
1801   //lint -e923 -e9074 -e9078 -emacro((835,845),EventID) [MISRA Note 13]
1802 \endcode
1803
1804 */
1805
1806 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1807 /**
1808 \page functionOverview Function Overview
1809
1810 CMSIS-RTOS2 provides multiple API interfaces:
1811   - \subpage rtos_api2 is the new C function interface that supports dynamic object creation and Armv8-M (Arm Cortex-M23 and
1812     Cortex-M33).
1813   - <a class="el" href="../../RTOS/html/functionOverview.html">CMSIS-RTOS C API v1</a> is a C function API that is backward
1814     compatible with CMSIS-RTOS v1.
1815   - \subpage rtos_apicpp is a C++ class function API (future extension).
1816
1817 It is possible to intermix the different API variants in the same application and even in the same C/C++ source module.
1818 However, the functions of the <a class="el" href="../../RTOS/html/functionOverview.html">CMSIS-RTOS C API v1</a> may be deprecated in future versions of CMSIS-RTOS.
1819
1820 CMSIS-RTOS2 defines also a generic system timer interface that works across the supported Arm Cortex processors:
1821   - \subpage rtos_os_tick_api is the interface to a kernel system timer.
1822 */
1823
1824 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1825 /**
1826 \page rtos_api2 CMSIS-RTOS C API v2
1827
1828 Overview of all CMSIS-RTOS C API v2 functions that are implemented in the \subpage cmsis_os2_h. 
1829
1830 \section rtos_api2_basics Common Design Concepts
1831
1832 All RTOS objects share a common design concept. The overall life-cycle of
1833 an object can be summarized as created -> in use -> destroyed.
1834
1835 <b>Create Objects</b>
1836
1837 An object is created by calling its `osXxxNew` function. The new function returns an identifier
1838 that can be used to operate with the new object. The actual state of an object is typically stored
1839 in an object specific control block. The memory layout (and size needed) for the control
1840 block is implementation specific. One should not make any specific assumptions about the control
1841 block. The control block layout might change and hence should be seen as an implementation
1842 internal detail.
1843
1844 In order to expose control about object specific options all `osXxxNew` functions provide an
1845 optional `attr` argument, which can be left as \token{NULL} by default. It takes a pointer to
1846 an object specific attribute structure, commonly containing the fields
1847  - `name` to attach a human readable name to the object for identification,
1848  - `attr_bits` to control object-specific options,
1849  - `cb_mem` to provide memory for the control block manually, and
1850  - `cb_size` to quantify the memory size provided for the control block.
1851
1852 The `name` attribute is only used for object identification, e.g. using RTOS-aware debugging. The
1853 attached string is not used for any other purposes internally.
1854
1855 The `cb_mem` and `cb_size` attributes can be used to provide memory for the control block manually
1856 instead of relying on the implementation internal memory allocation. One has to assure that the
1857 amount of memory pointed to by `cb_mem` is sufficient for the objects control block structure. If
1858 the size given as `cb_size` is not sufficient the `osXxxNew` function returns with an error, i.e.
1859 returning \token{NULL}. Furthermore providing control block memory manually is less portable. Thus
1860 one has to take care about implementation specific alignment and placement requirements for instance.
1861 Refer to \ref CMSIS_RTOS_MemoryMgmt for further details.
1862
1863 <b>Object Usage</b>
1864
1865 After an object has been created successfully it can be used until it is destroyed. The actions
1866 defined for an object depends on its type. Commonly all the `osXxxDoSomething` access function
1867 require the reference to the object to work with as the first `xxx_id` parameter.
1868
1869 The access function can be assumed to apply some sort of sanity checking on the id parameter. So
1870 that it is assured one cannot accidentally call an access function with a \token{NULL} object
1871 reference. Furthermore the concrete object type is verified, i.e. one cannot call access functions
1872 of one object type with a reference to another object type.
1873
1874 All further parameter checks applied are either object and action specific or may even be implementation
1875 specific. Thus one should always check action function return values for `osErrorParameter` to asure the
1876 provided arguments were accepted.
1877
1878 As a rule of thumb only non-blocking access function can be used from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines" (ISR).
1879 This incorporates `osXxxWait` functions (and similar) limited to be called with parameter `timeout`
1880 set to \token{0}, i.e. usage of try-semantics.
1881
1882 <b>Object Destruction</b>
1883
1884 Objects that are not needed anymore can be destructed on demand to free the control block memory. Objects
1885 are not destructed implicitly. Thus one can assume an object id to be valid until `osXxxDelete` is called
1886 explicitly. The delete function finally frees the control block memory. In case of user provided control
1887 block memory, see above, the memory must be freed manually as well. 
1888
1889 The only exception one has to take care of are Threads which do not have an explicit `osThreadDelete` function.
1890 Threads can either be `detached` or `joinable`. Detached threads are automatically destroyed on termination,
1891 i.e. call to \ref osThreadTerminate or \ref osThreadExit or return from thread function. On the other hand joinable
1892 threads are kept alive until one explicitly calls \ref osThreadJoin.
1893
1894 \section rtos_api2_functions Function Reference
1895
1896  - \ref CMSIS_RTOS_KernelCtrl
1897    - \ref osKernelGetInfo : \copybrief osKernelGetInfo
1898    - \ref osKernelGetState : \copybrief osKernelGetState
1899    - \ref osKernelGetSysTimerCount : \copybrief osKernelGetSysTimerCount
1900    - \ref osKernelGetSysTimerFreq : \copybrief osKernelGetSysTimerFreq
1901    - \ref osKernelInitialize : \copybrief osKernelInitialize
1902    - \ref osKernelLock : \copybrief osKernelLock
1903    - \ref osKernelUnlock : \copybrief osKernelUnlock
1904    - \ref osKernelRestoreLock : \copybrief osKernelRestoreLock
1905    - \ref osKernelResume : \copybrief osKernelResume
1906    - \ref osKernelStart : \copybrief osKernelStart
1907    - \ref osKernelSuspend : \copybrief osKernelSuspend
1908    - \ref osKernelGetTickCount : \copybrief osKernelGetTickCount
1909    - \ref osKernelGetTickFreq : \copybrief osKernelGetTickFreq
1910
1911  - \ref CMSIS_RTOS_ThreadMgmt
1912    - \ref osThreadDetach : \copybrief osThreadDetach
1913    - \ref osThreadEnumerate : \copybrief osThreadEnumerate
1914    - \ref osThreadExit : \copybrief osThreadExit
1915    - \ref osThreadGetCount : \copybrief osThreadGetCount
1916    - \ref osThreadGetId : \copybrief osThreadGetId
1917    - \ref osThreadGetName : \copybrief osThreadGetName
1918    - \ref osThreadGetPriority : \copybrief osThreadGetPriority
1919    - \ref osThreadGetStackSize : \copybrief osThreadGetStackSize
1920    - \ref osThreadGetStackSpace : \copybrief osThreadGetStackSpace
1921    - \ref osThreadGetState : \copybrief osThreadGetState
1922    - \ref osThreadJoin : \copybrief osThreadJoin
1923    - \ref osThreadNew : \copybrief osThreadNew
1924    - \ref osThreadResume : \copybrief osThreadResume
1925    - \ref osThreadSetPriority : \copybrief osThreadSetPriority
1926    - \ref osThreadSuspend : \copybrief osThreadSuspend
1927    - \ref osThreadTerminate : \copybrief osThreadTerminate
1928    - \ref osThreadYield : \copybrief osThreadYield
1929
1930  - \ref CMSIS_RTOS_ThreadFlagsMgmt
1931    - \ref osThreadFlagsSet : \copybrief osThreadFlagsSet
1932    - \ref osThreadFlagsClear : \copybrief osThreadFlagsClear
1933    - \ref osThreadFlagsGet : \copybrief osThreadFlagsGet
1934    - \ref osThreadFlagsWait : \copybrief osThreadFlagsWait
1935
1936  - \ref CMSIS_RTOS_EventFlags
1937    - \ref osEventFlagsGetName : \copybrief osEventFlagsGetName
1938    - \ref osEventFlagsNew : \copybrief osEventFlagsNew
1939    - \ref osEventFlagsDelete : \copybrief osEventFlagsDelete
1940    - \ref osEventFlagsSet : \copybrief osEventFlagsSet
1941    - \ref osEventFlagsClear : \copybrief osEventFlagsClear
1942    - \ref osEventFlagsGet : \copybrief osEventFlagsGet
1943    - \ref osEventFlagsWait : \copybrief osEventFlagsWait
1944
1945  - \ref CMSIS_RTOS_Wait
1946    - \ref osDelay : \copybrief osDelay
1947    - \ref osDelayUntil : \copybrief osDelayUntil
1948
1949  - \ref CMSIS_RTOS_TimerMgmt
1950    - \ref osTimerDelete : \copybrief osTimerDelete
1951    - \ref osTimerGetName : \copybrief osTimerGetName
1952    - \ref osTimerIsRunning : \copybrief osTimerIsRunning
1953    - \ref osTimerNew : \copybrief osTimerNew
1954    - \ref osTimerStart : \copybrief osTimerStart
1955    - \ref osTimerStop : \copybrief osTimerStop
1956
1957  - \ref CMSIS_RTOS_MutexMgmt
1958    - \ref osMutexAcquire : \copybrief osMutexAcquire
1959    - \ref osMutexDelete : \copybrief osMutexDelete
1960    - \ref osMutexGetName : \copybrief osMutexGetName
1961    - \ref osMutexGetOwner : \copybrief osMutexGetOwner
1962    - \ref osMutexNew : \copybrief osMutexNew
1963    - \ref osMutexRelease : \copybrief osMutexRelease
1964
1965  - \ref CMSIS_RTOS_SemaphoreMgmt
1966    - \ref osSemaphoreAcquire : \copybrief osSemaphoreAcquire
1967    - \ref osSemaphoreDelete : \copybrief osSemaphoreDelete
1968    - \ref osSemaphoreGetCount : \copybrief osSemaphoreGetCount
1969    - \ref osSemaphoreGetName : \copybrief osSemaphoreGetName
1970    - \ref osSemaphoreNew : \copybrief osSemaphoreNew
1971    - \ref osSemaphoreRelease : \copybrief osSemaphoreRelease
1972
1973  - \ref CMSIS_RTOS_PoolMgmt
1974    - \ref osMemoryPoolAlloc : \copybrief osMemoryPoolAlloc
1975    - \ref osMemoryPoolDelete : \copybrief osMemoryPoolDelete
1976    - \ref osMemoryPoolFree : \copybrief osMemoryPoolFree
1977    - \ref osMemoryPoolGetBlockSize : \copybrief osMemoryPoolGetBlockSize
1978    - \ref osMemoryPoolGetCapacity : \copybrief osMemoryPoolGetCapacity
1979    - \ref osMemoryPoolGetCount : \copybrief osMemoryPoolGetCount
1980    - \ref osMemoryPoolGetName : \copybrief osMemoryPoolGetName
1981    - \ref osMemoryPoolGetSpace : \copybrief osMemoryPoolGetSpace
1982    - \ref osMemoryPoolNew : \copybrief osMemoryPoolNew
1983
1984  - \ref CMSIS_RTOS_Message
1985    - \ref osMessageQueueDelete : \copybrief osMessageQueueDelete
1986    - \ref osMessageQueueGet : \copybrief osMessageQueueGet
1987    - \ref osMessageQueueGetCapacity : \copybrief osMessageQueueGetCapacity
1988    - \ref osMessageQueueGetCount : \copybrief osMessageQueueGetCount
1989    - \ref osMessageQueueGetMsgSize : \copybrief osMessageQueueGetMsgSize
1990    - \ref osMessageQueueGetName : \copybrief osMessageQueueGetName
1991    - \ref osMessageQueueGetSpace : \copybrief osMessageQueueGetSpace
1992    - \ref osMessageQueueNew : \copybrief osMessageQueueNew
1993    - \ref osMessageQueuePut : \copybrief osMessageQueuePut
1994    - \ref osMessageQueueReset : \copybrief osMessageQueueReset
1995  
1996 \todo restructure
1997  - \ref rtx5_specific
1998    - \ref osRtxErrorNotify : \copybrief osRtxErrorNotify
1999    - \ref osRtxIdleThread : \copybrief osRtxIdleThread
2000
2001 The following CMSIS-RTOS C API v2 functions can be called from threads and \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines"
2002 (ISR):
2003    - \ref osKernelGetInfo, \ref osKernelGetState,
2004      \ref osKernelGetTickCount, \ref osKernelGetTickFreq, \ref osKernelGetSysTimerCount, \ref osKernelGetSysTimerFreq
2005    - \ref osThreadFlagsSet
2006    - \ref osEventFlagsSet, \ref osEventFlagsClear, \ref osEventFlagsGet, \ref osEventFlagsWait
2007    - \ref osSemaphoreAcquire, \ref osSemaphoreRelease, \ref osSemaphoreGetCount
2008    - \ref osMemoryPoolAlloc, \ref osMemoryPoolFree, \ref osMemoryPoolGetCapacity, \ref osMemoryPoolGetBlockSize,
2009      \ref osMemoryPoolGetCount, \ref osMemoryPoolGetSpace
2010    - \ref osMessageQueuePut, \ref osMessageQueueGet, \ref osMessageQueueGetCapacity, \ref osMessageQueueGetMsgSize,
2011      \ref osMessageQueueGetCount, \ref osMessageQueueGetSpace
2012 */
2013
2014
2015 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2016 /**
2017 \page rtos_apicpp CMSIS-RTOS C++ API
2018
2019 A C++11/C++14 interface is planned for the future.
2020 */
2021
2022 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2023 /**
2024 \page rtos_os_tick_api OS Tick API
2025
2026 The CMSIS OS Tick API may be used by an RTOS implementation to be easily potable across the different Cortex-M and Cortex-A processors.
2027 It provides a generic interface to a kernel system tick timer and defines the following functions:
2028
2029  - The Reference for \ref CMSIS_RTOS_TickAPI provides details about these functions:
2030    - \ref OS_Tick_Setup : \copybrief OS_Tick_Setup
2031    - \ref OS_Tick_Enable : \copybrief OS_Tick_Enable
2032    - \ref OS_Tick_Disable : \copybrief OS_Tick_Disable
2033    - \ref OS_Tick_AcknowledgeIRQ : \copybrief OS_Tick_AcknowledgeIRQ
2034    - \ref OS_Tick_GetIRQn : \copybrief OS_Tick_GetIRQn
2035    - \ref OS_Tick_GetClock : \copybrief OS_Tick_GetClock
2036    - \ref OS_Tick_GetInterval : \copybrief OS_Tick_GetInterval
2037    - \ref OS_Tick_GetCount : \copybrief OS_Tick_GetCount
2038    - \ref OS_Tick_GetOverflow : \copybrief OS_Tick_GetOverflow
2039
2040 */
2041
2042
2043 /* ======================================================================================================================== */
2044 // Group creation for Reference 
2045 /* 
2046 \addtogroup CMSIS_RTOS1 CMSIS-RTOS API v1
2047 \brief This section describes the CMSIS-RTOS API v1. 
2048 \details 
2049 The CMSIS-RTOS is a generic API layer that interfaces to an existing RTOS kernel.
2050
2051 CMSIS-RTOS2 provides an translation layer for the
2052 <a class="el" href="../../RTOS/html/index.html">CMSIS-RTOS API v1</a> that simplifies migration.
2053
2054 Refer to the <a class="el" href="../../RTOS/html/modules.html">Reference</a> guide of the CMSIS-RTOS API v1 for details.
2055 */
2056
2057 // Group creation for Reference 
2058 /** 
2059 \addtogroup CMSIS_RTOS CMSIS-RTOS API v2
2060 \brief C interface of \ref rtos_api2 defined in cmsis_os2.h
2061 \details 
2062 The CMSIS-RTOS2 is a generic API layer that interfaces to an RTOS kernel.
2063
2064 The complete API interface is defined in the \ref cmsis_os2_h. When using dynamic memory allocation for objects, source code
2065 or libraries require no modifications when using on a different CMSIS-RTOS2 implementation.
2066
2067 Refer to \ref rtos_api2_basics for further details.
2068 */
2069
2070 /**
2071 \addtogroup CMSIS_RTOS_MemoryMgmt Memory Management
2072 \ingroup CMSIS_RTOS
2073 \brief Information about memory management possibilities
2074 \details
2075 The \ref CMSIS_RTOS offers two options for memory management the user can choose. For object storage one can either use
2076  - \ref CMSIS_RTOS_MemoryMgmt_Automatic (fully portable), or
2077  - \ref CMSIS_RTOS_MemoryMgmt_Manual (implementation specific).
2078  
2079 In order to affect the memory allocation scheme all RTOS objects that can be created on request, i.e. those having a `osXxxNew`
2080 function, accept an optional `osXxxAttr_t attr` argument on creation. As a rule of thumb the object attributes at least have
2081 members to assign custom control block memory, i.e. `cb_mem` and `cb_size` members. By default, i.e. `attr` is `NULL`
2082 or `cb_mem` is `NULL`, \ref CMSIS_RTOS_MemoryMgmt_Automatic is used. Providing a pointer to user memory in `cb_mem` switches
2083 to \ref CMSIS_RTOS_MemoryMgmt_Manual.
2084
2085 \note For detailed information about memory allocation strategies provided in RTX5 refer to \ref MemoryAllocation.
2086
2087 \section CMSIS_RTOS_MemoryMgmt_Automatic Automatic Dynamic Allocation
2088
2089 The automatic allocation is the default and viable for many use-cases. Moreover it is fully portable across different
2090 implementations of the \ref CMSIS_RTOS. The common drawback of dynamic memory allocation is the possibility of memory
2091 fragmentation and exhaustion. Given that all needed objects are created once upon system initialization and never
2092 deleted at runtime this class of runtime failures can be prevented, though.
2093
2094 The actual allocation strategy used is implementation specific, i.e. whether global heap or preallocated memory pools are used.
2095
2096 <b> Code Example:</b> 
2097 \code{.c}
2098 #include "cmsis_os2.h"                          // implementation agnostic
2099   
2100 osMutexId_t mutex_id;
2101 osMutexId_t mutex2_id;
2102   
2103 const osMutexAttr_t Thread_Mutex_attr = {
2104   "myThreadMutex",                              // human readable mutex name
2105   osMutexRecursive | osMutexPrioInherit,        // attr_bits
2106   NULL,                                         // memory for control block (default)
2107   0U                                            // size for control block (default)
2108 };
2109   
2110 void CreateMutex (void)  {
2111   mutex_id = osMutexNew(NULL);                  // use default values for all attributes
2112   mutex2_id = osMutexNew(&Thread_Mutex_attr);   // use attributes from defined structure
2113   :
2114 }
2115 \endcode
2116
2117 The Mutexes in this example are created using automatic memory allocation.
2118
2119 \section CMSIS_RTOS_MemoryMgmt_Manual Manual User-defined Allocation
2120
2121 One can get fine grained control over memory allocation by providing user-defined memory.
2122 The actual requirements such user-defined memory are implementation specific. Thus one
2123 needs to carefully refer to the size and alignment rules of the implementation used, e.g.
2124 for RTX see \ref StaticObjectMemory.
2125
2126 <b> Code Example:</b> 
2127 \code{.c}
2128 #include "rtx_os.h"                             // implementation specific
2129   
2130 osMutexId_t mutex_id;
2131   
2132 static uint32_t mutex_cb[osRtxMutexCbSize/4U];  // implementation specific
2133   
2134 const osMutexAttr_t Thread_Mutex_attr = {
2135   "myThreadMutex",                              // human readable mutex name
2136   osMutexRecursive | osMutexPrioInherit,        // attr_bits
2137   mutex_cb,                                     // memory for control block (user-defined)
2138   sizeof(mutex_cb)                              // size for control block (user-defined)
2139 };
2140   
2141 void CreateMutex (void)  {
2142   mutex_id = osMutexNew(&Thread_Mutex_attr);    // use attributes from defined structure
2143   :
2144 }
2145 \endcode
2146
2147 The above example uses user-defined memory for the mutex control block. Depending on the actual
2148 implementation used one needs to include the specific header file, `rtx_os.h` in this case.
2149
2150 */
2151
2152 // Group creation for Reference 
2153 /** 
2154 \addtogroup CMSIS_RTOS CMSIS-RTOS API v2
2155 \brief C interface of \ref rtos_api2 defined in <b>%cmsis_os2.h</b>
2156 \details 
2157 The CMSIS-RTOS2 is a generic API layer that interfaces to an RTOS kernel.
2158
2159 The complete API interface is defined in the \ref cmsis_os2_h. When using dynamic memory allocation for objects, source code
2160 or libraries require no modifications when using on a different CMSIS-RTOS2 implementation.
2161
2162 Refer to \ref rtos_api2_basics for further details.
2163 */
2164