]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/RTOS2/src/cmsis_os2.txt
RTOS2: added definitions for Flags Errors (issue #133)
[cmsis] / CMSIS / DoxyGen / RTOS2 / src / cmsis_os2.txt
1 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2 /**
3 \mainpage
4
5 The <b>CMSIS-RTOS API Version 2 (CMSIS-RTOS2)</b> is a generic RTOS interface for ARM&reg; Cortex&reg;-M processor-based
6 devices. It provides a standardized API for software components that require RTOS functionality and gives therefore serious
7 benefits to the users and the software industry:
8  - CMSIS-RTOS2 provides basic features that are required in many applications.
9  - The unified feature set of the CMSIS-RTOS2 reduces learning efforts and simplifies sharing of software components.
10  - Middleware components that use the CMSIS-RTOS2 are RTOS agnostic and are easier to adapt.
11  - Standard project templates of the CMSIS-RTOS2 may be shipped with freely available CMSIS-RTOS2 implementations.
12
13 \note The CMSIS-RTOS API Version 2 defines a minimum feature set. Implementations with extended features may be provided by
14       the RTOS vendors.
15
16 The CMSIS-RTOS2 manages the resources of the microcontroller system and implements the concept of parallel threads that run
17 concurrently.
18
19 Applications frequently require several concurrent activities. CMSIS-RTOS2 can manage multiple concurrent activities at the
20 time when they are needed. Each activity gets a separate thread which executes a specific task and this simplifies the
21 overall program structure. The CMSIS-RTOS2 system is scalable and additional threads can be added easily at a later time.
22 Threads have a priority allowing faster execution of time-critical parts of a user application.
23
24 The CMSIS-RTOS2 offers services needed in many real-time applications, for example, periodical activation of timer functions, 
25 memory management, and message exchange between threads with time limits.
26
27 The CMSIS-RTOS2 addresses the following new requirements:
28  - Dynamic object creation no longer requires static memory, static memory buffers are now optional.
29  - Support for ARMv8-M architecture that provides a secure and non-secure state of code execution.
30  - Provisions for message passing in multi-core systems.
31  - Full support of C++ run-time environments.
32  - C interface which is binary compatible across
33    <a href="http://infocenter.arm.com/help/topic/com.arm.doc.subset.swdev.abi/index.html">ABI compatible compilers</a>.
34
35 As a consequence of these requirements the CMSIS-RTOS2 has the following fundamental modifications:
36  - The functions osXxxxNew replace osXxxxCreate functions; osXxxxNew and osXxxxDelete create and destroy objects.
37  - The C function \c main is no longer started as a thread (this was an optional feature in CMSIS-RTOS v1).
38  - Functions that return osEvent have been replaced.
39
40 CMSIS-RTOS2 provides an translation layer for the <a class="el" href="../../RTOS/html/index.html">CMSIS-RTOS API v1</a>. It
41 is possible to intermix CMSIS-RTOS API Version 2 and CMSIS-RTOS API Version 1 within the same application. Over time, you may
42 migrate to the new API as explained in \ref os2Migration.
43
44 CMSIS-RTOS2 is not POSIX compliant, but has provisions to enable a C++11/C++14 interface.
45
46 The following sections provide further details about CMSIS-RTOS2 and the RTX reference implementation.
47  - \subpage rtos_revisionHistory documents changes made in each version for CMSIS-RTOS API v2 and RTX v5.
48  - \subpage genRTOS2IF provides an overview about the CMSIS-RTOS API v2.
49  - \subpage functionOverview lists the CMSIS-RTOS2 API functions and the header file cmsis_os2.h.
50  - \subpage rtosValidation describes the validation suite that is publicly available.
51  - \subpage os2Migration shows how to use CMSIS-RTOS2 in existing projects and lists function differences to CMSIS-RTOS v1.
52  - \subpage rtx5_impl provides general information about the operation and usage of RTX v5.
53
54 <hr>
55
56 CMSIS-RTOS2 in ARM::CMSIS Pack
57 -----------------------------
58
59 The following files relevant to CMSIS-RTOS2 are present in the <b>ARM::CMSIS</b> Pack directories:
60 File/Folder                  | Content                                                                
61 -----------------------------|------------------------------------------------------------------------
62 \b CMSIS/Documentation/RTOS2 | This documentation                                                     
63 \b CMSIS/RTOS2/Include       | \ref cmsis_os2_h                                                 
64 \b CMSIS/RTOS2/RTX           | CMSIS-RTOS v2 reference implementation based on RTX version 5
65 \b CMSIS/RTOS2/Template      | Compatibility layer to CMSIS-RTOS v1
66 */
67
68
69 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
70 /**
71 \page rtos_revisionHistory Revision History
72
73 \section GenRTOS2Rev CMSIS-RTOS API Version 2
74
75 <table class="cmtable" summary="Revision History">
76     <tr>
77       <th>Version</th>
78       <th>Description</th>
79     </tr>
80     <tr>
81       <td>V2.1.0</td>
82       <td>
83         Support for critical and uncritical sections (nesting safe):\n 
84          - updated: osKernelLock, osKernelUnlock\n
85          - added: osKernelRestoreLock\n
86         Updated Thread and Event Flags:\n
87          - changed flags parameter and return type from int32_t to uint32_t\n
88      </td>
89     </tr>
90     <tr>
91       <td>V2.0.0</td>
92       <td>
93         New API Version 2.0 available. 
94          - See \ref rtos_api2 for a detailed function reference.
95          - See \ref os2Migration for details on the migration process from API Version 1.
96      </td>
97     </tr>
98     <tr>
99       <td>V1.02 - only documentation changes</td>
100       <td>
101       Added: Overview of the \ref rtosValidation "CMSIS-RTOS Validation" Software Pack.\n
102       Clarified: Behavior of \ref CMSIS_RTOS_TimeOutValue.
103      </td>
104     </tr>
105     <tr>
106       <td>V1.02</td>
107       <td>Added: New control functions for short timeouts in microsecond resolution \b osKernelSysTick,
108       \b osKernelSysTickFrequency, \b osKernelSysTickMicroSec.\n
109       Removed: osSignalGet.
110      </td>
111     </tr>
112     <tr>
113       <td>V1.01</td>
114       <td>Added capabilities for C++, kernel initialization and object deletion.\n
115       Prepared for C++ class interface. In this context to \em const attribute has been moved from osXxxxDef_t typedefs to
116       the osXxxxDef macros.\n
117       Added: \ref osTimerDelete, \ref osMutexDelete, \ref osSemaphoreDelete.\n
118       Added: \ref osKernelInitialize that prepares the kernel for object creation.\n
119       </td>
120     </tr>
121     <tr>
122       <td>
123       V1.00</td>
124       <td>First official Release.\n
125       Added: \ref osKernelStart; starting 'main' as a thread is now an optional feature.\n
126       Semaphores have now the standard behavior.\n
127       \b osTimerCreate does no longer start the timer. Added: \ref osTimerStart (replaces osTimerRestart).\n
128       Changed: osThreadPass is renamed to \ref osThreadYield.
129       </td>
130     </tr>
131     <tr>
132       <td>V0.02</td>
133       <td>Preview Release.</td>
134     </tr>
135 </table>
136
137
138 \section RTX5RevisionHistory CMSIS-RTOS RTX Version 5
139
140 <table class="cmtable" summary="Revision History">
141     <tr>
142       <th>Version</th>
143       <th>Description</th>
144     </tr>
145     <tr>
146       <td>V5.1.0</td>
147       <td>
148        Based on CMSIS-RTOS API V2.1.\n
149        Added support for Event recording.\n
150        Added support for IAR compiler.\n
151        Configuration file split into .h and .c file.\n
152        osRtx name-space for RTX specific symbols.\n
153       </td>
154     </tr>
155     <tr>
156       <td>V5.0.0</td>
157       <td>
158        Initial release compliant to CMSIS-RTOS2.\n
159       </td>
160     </tr>
161 </table>
162 */
163
164
165 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
166 /**
167 \page genRTOS2IF Generic RTOS Interface
168
169 CMSIS-RTOS2 is a generic API that is agnostic of the underlying RTOS kernel. Application programmers call CMSIS-RTOS2 API
170 functions in the user code to ensure maximum portability from one RTOS to another. Middleware using CMSIS-RTOS2 API takes
171 advantages of this approach by avoiding unnecessary porting efforts.
172
173 \image html "API_Structure.png" "CMSIS-RTOS API Structure"
174
175 A typical CMSIS-RTOS2 API implementation interfaces to an existing real-time kernel. The CMSIS-RTOS2 API provides the
176 following attributes and functionalities:
177  - Function names, identifiers, and parameters are descriptive and easy to understand. The functions are powerful and
178    flexible which reduces the number of functions exposed to the user. 
179  - \ref CMSIS_RTOS_ThreadMgmt allows you to define, create, and control threads.
180  - Interrupt Service Routines (ISR) can \ref CMSIS_RTOS_ISR_Calls "call some CMSIS-RTOS functions". When a CMSIS-RTOS
181    function cannot be called from an ISR context, it rejects the invocation and returns an error code.
182  - Three different event types support communication between multiple threads and/or ISR:
183    - \ref CMSIS_RTOS_ThreadFlagsMgmt "Thread Flags": may be used to indicate specific conditions to a thread.
184    - \ref CMSIS_RTOS_EventFlags "Event Flags": may be used to indicate events to a thread or ISR.
185    - \ref CMSIS_RTOS_Message "Messages": can be sent to a thread or an ISR. Messages are buffered in a queue.
186  - \ref CMSIS_RTOS_MutexMgmt and \ref CMSIS_RTOS_SemaphoreMgmt are incorporated.
187  - CPU time can be scheduled with the following functionalities:
188    - A \a timeout parameter is incorporated in many CMSIS-RTOS functions to avoid system lockup. When a timeout is specified,
189      the system waits until a resource is available or an event occurs. While waiting, other threads are scheduled.
190    - The \ref osDelay and \ref osDelayUntil functions put a thread into the \b WAITING state for a specified period of time.
191    - The \ref osThreadYield provides co-operative thread switching and passes execution to another thread of the same
192      priority.
193  - \ref CMSIS_RTOS_TimerMgmt  functions are used to trigger the execution of functions.
194
195 The CMSIS-RTOS2 API is designed to optionally incorporate multi-processor systems and/or access protection via the Cortex-M
196 Memory Protection Unit (MPU).
197
198 In some RTOS implementations threads may execute on different processors, thus \b message queues may reside in shared memory
199 resources.
200
201 The CMSIS-RTOS2 API encourages the software industry to evolve existing RTOS implementations. RTOS implementations can be
202 different and optimized in various aspects towards the Cortex-M processors. Optional features may be for example
203  - Support of the Cortex-M Memory Protection Unit (MPU).
204  - Support of multi-processor systems.
205  - Support of a DMA controller.
206  - Deterministic context switching.
207  - Round-robin context switching.
208  - Deadlock avoidance, for example with priority inversion.
209  - Zero interrupt latency by using ARMv7-M instructions LDREX and STREX.
210  
211 \section usingOS2 Using a CMSIS-RTOS2 Implementation
212
213 A CMSIS-RTOS2 implementation is typically provided as a library. To add the RTOS functionality to an existing CMSIS-based
214 application, the RTOS library (and typically one or more configuration files) needs to be added. There is a single new header
215 file %cmsis_os2.h available. This is the only header file required for a completely portable application. In such a case,
216 user provided memory for control blocks, objects data and thread stack cannot be used. Alternatively, you can include an
217 implementation specific header file (for example rtx_os.h) which provides definitions also for resource allocation (such as
218 size of control blocks, required memory for object data and thread stack). This is optional and implies that the application
219 code is not completely portable.
220
221 \image html "CMSIS_RTOS_Files.png" "CMSIS-RTOS File Structure"
222
223 Once the files are added to a project, the user can start working with the CMSIS-RTOS functions.  A code example is provided
224 below:
225  
226 <b>Code Example</b>
227 \code
228 /*----------------------------------------------------------------------------
229  * CMSIS-RTOS 'main' function template
230  *---------------------------------------------------------------------------*/
231  
232 #include "RTE_Components.h"
233 #include  CMSIS_device_header
234 #include "cmsis_os2.h"
235  
236 /*----------------------------------------------------------------------------
237  * Application main thread
238  *---------------------------------------------------------------------------*/
239 void app_main (void *argument) {
240  
241   // ...
242   for (;;) {}
243 }
244  
245 int main (void) {
246  
247   // System Initialization
248   SystemCoreClockUpdate();
249 #ifdef RTE_Compiler_EventRecorder
250   // Initialize and start Event Recorder
251   EventRecorderInitialize(EventRecordError, 1U);
252 #endif
253   // ...
254  
255   osKernelInitialize();                 // Initialize CMSIS-RTOS
256   osThreadNew(app_main, NULL, NULL);    // Create application main thread
257   osKernelStart();                      // Start thread execution
258   for (;;) {}
259 }
260 \endcode
261
262
263 \section cmsis_os2_h cmsis_os2.h header file
264
265 The file \b cmsis_os2.h is a standard header file that interfaces to every CMSIS-RTOS2 compliant real-time operating
266 systems (RTOS). Each implementation is provided the same \b cmsis_os2.h which defines the interface to the \ref rtos_api2.
267
268 Using the \b cmsis_os2.h along with dynamic object allocation allows to create source code or libraries that require no
269 modifications when using on a different CMSIS-RTOS2 implementation.
270
271 <b>Header file %cmsis_os2.h</b>
272
273 \include cmsis_os2.h
274 */
275
276
277 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
278 /**
279 \page rtx5_impl RTX v5 Implementation
280
281 Keil RTX version 5 (RTX5) implements the CMSIS-RTOS2 as a native RTOS interface for ARM Cortex-M processor-based devices.
282 A translation layer to CMSIS-RTOS API v1 is provided. Therefore, RTX5 can be used in applications that where previously based
283 on RTX version 4 and CMSIS-RTOS version 1 with minimal effort.
284
285 The following sections provide further details:
286  - \subpage cre_rtx_proj explains how to setup an RTX v5 project in Keil MDK.
287  - \subpage theory_of_operation provides general information about the operation of CMSIS-RTOS RTX v5.
288  - \subpage config_rtx5 describes configuration parameters of CMSIS-RTOS RTX v5.
289  - \subpage creating_RTX5_LIB explains how to build your own CMSIS-RTOS RTX v5 library.
290  - \subpage dirstructfiles5 explains the directories and files that are supplied as part of CMSIS-RTOS RTX v5.
291  - \subpage technicalData5 lists microcontroller hardware requirements and limitations such as number of concurrent threads.
292  - \subpage misraCompliance5 describes the violations to the MISRA standard.
293 */
294
295 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
296 /**
297 \page cre_rtx_proj Create an RTX5 Project
298
299 The steps to create a microcontroller application using RTX5 are:
300 - Create a new project and select a microcontroller device.
301 - In the Manage Run-Time Environment window, select <b>CMSIS\::CORE</b> and <b>CMSIS\::RTOS2 (API)\::Keil RTX5</b>. You can
302   choose to either add RTX as a library (Variant: \b Library) or to add the full source code (Variant: \b Source - required
303   if using the <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a>):
304
305    \image html manage_rte_output.png
306
307 - If the <b>Validation Output</b> requires other components to be present, try to use the \b Resolve button.
308 - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as
309   \b %RTX_Config.h, \b %RTX_Config.c, the library or the source code files, as well as the system and startup files:
310
311    \image html project_window.png
312    
313 - You can add template files to the project by right-clicking on <b>Source Group 1</b> and selecting
314   <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
315   you will see all available template files for CMSIS-RTOS RTX:
316   
317    \image html add_item.png
318
319 - \ref config_rtx5 "Configure" RTX5 to the application's needs using the \b %RTX_Config.h file.
320
321 \section cre_rtx_proj_specifics Add support for RTX specific functions
322 If you require some of the \ref rtx5_specific "RTX specific functions" in your application code, \#include the
323 \ref rtx_os_h "header file rtx_os.h". This enables \ref lowPower "low-power" and \ref TickLess "tick-less" operation modes.
324   
325   
326 \section cre_rtx_proj_er Add Event Recorder Visibility
327 - To use the Event Recorder together with RTX5, select the software component <b>Compiler:Event Recorder</b>.
328 - Select the \b Source variant of the software component <b>CMSIS:RTOS2 (API):Keil RTX5</b>.
329   \image html event_recorder_rte.png "Component selection for Event Recorder"
330 - Call the function <b>EventRecorderInitialize()</b> in your application code (ideally in \c main()).
331 - Build the application code and download it to the debug hardware.
332   
333 Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event
334  \b Recorder.
335  */
336
337
338 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
339 /**
340 \page theory_of_operation Theory of Operation
341
342 Many aspects of the kernel are configurable and the configuration options are mentioned where applicable.
343
344 \section SystemStartup System Startup
345
346 Since main is no longer a thread RTX5 does not interfere with the system startup until main is reached.
347 Once the execution reaches \c main() there is a recommended order to initialize the hardware and start the kernel. This is
348 also reflected in the user code template file "CMSIS-RTOS2 'main' function" supplied with the RTX5 component.
349
350 Your application's \c main() should implement at least the following in the given order:
351 -# Initialization and configuration of hardware including peripherals, memory, pins, clocks and the interrupt system.
352 -# Update the system core clock using the respective
353    <a href=../../Core/html/group__system__init__gr.html>CMSIS-CORE function</a>.
354 -# Initialize the CMSIS-RTOS kernel using \ref osKernelInitialize.
355 -# Optionally, create a new thread \c app_main, which is used as a main thread using \ref osThreadNew. Alternatively, threads
356    can be created in \c main() directly.
357 -# Start the RTOS scheduler using \ref osKernelStart. This function does not return in case of successful execution. Any
358    application code after \b osKernelStart will not be executed unless \b osKernelStart fails.            
359
360 \note Interrupts (like SVC for example) used by the kernel are initialized in \ref osKernelInitialize. In case priorities and
361 groupings in the NVIC are altered by the application after the above sequence it might be necessary to call
362 \ref osKernelInitialize again.
363
364 \section MemoryAllocation Memory Allocation 
365
366 RTX5 objects (thread, mutex, semaphore, timer, message queue, thread and event flags, as well as memory pool) require
367 dedicated RAM memory. Objects can be created using os<i>object</i>New() calls and deleted using os<i>object</i>Delete()
368 calls. The related object memory needs to be available during the lifetime of the object.
369
370 RTX5 offers three different memory allocation methods for objects:
371   - \ref GlobalMemoryPool uses a single global memory pool for all objects. It is easy to configure, but may have 
372     the disadvantage for memory fragmentation when objects with different sizes are created and destroyed.
373   - \ref ObjectMemoryPool uses a fixed-size memory pool for each object type. The method is time deterministic
374      and avoids memory fragmentation.
375   - \ref StaticObjectMemory reserves memory during compile time and completely avoids that a system can be out of memory.
376     This is typically a required for some safety critical systems.
377
378 It possible to intermix all the memory allocation methods in the same application.
379
380 \subsection GlobalMemoryPool Global Memory Pool
381
382 The global memory pool allocates all objects from a memory area. This method of memory allocation is the default
383 configuration setting of RTX5.
384
385 \image html MemAllocGlob.png "Global Memory Pool for all objects"
386
387 When the memory pool does not provide sufficient memory, the creation of the object fails and the related
388 os<i>object</i>New() function returns \token{NULL}.
389
390 Enabled in \ref systemConfig.
391
392 \subsection ObjectMemoryPool Object-specific Memory Pools
393
394 Object-specific memory pools avoids memory fragmentation with a dedicated fixed-size memory management for each object type.
395 This type of memory pools are fully time deterministic, which means that object creation and destruction takes always the
396 same fixed amount of time. As a fixed-size memory pool is specific to an object type, the handling of out-of-memory
397 situations is simplified.
398
399 \image html MemAllocSpec.png "One memory pool per object type"
400
401 Object-specific memory pools are selectively enabled for each object type, e.g: mutex or thread using the RTX configuration
402 file:
403  - Enabled in \ref threadConfig for thread objects.
404  - Enabled in \ref timerConfig for timer objects.
405  - Enabled in \ref eventFlagsConfig for event objects.
406  - Enabled in \ref mutexConfig for mutex objects.
407  - Enabled in \ref semaphoreConfig for semaphore.
408  - Enabled in \ref memPoolConfig for memory pools.
409  - Enabled in \ref msgQueueConfig for message objects.
410
411 When the memory pool does not provide sufficient memory, the creation of the object fails and the related
412 os<i>object</i>New() function returns \token{NULL}.
413
414 \subsection StaticObjectMemory Static Object Memory
415 In contrast to the dynamic memory allocations, the static memory allocation requires compile-time allocation of object memory. 
416
417 \image html MemAllocStat.png "Statically allocated memory for all objects"
418
419 The following code example shows how to create an OS object using static memory.
420
421 <b> Code Example:</b> 
422 \code{.c}
423 /*----------------------------------------------------------------------------
424  * CMSIS-RTOS 'main' function template
425  *---------------------------------------------------------------------------*/
426
427 #include "RTE_Components.h"
428 #include  CMSIS_device_header
429 #include "cmsis_os2.h"
430  
431 //include rtx_os.h for types of RTX objects
432 #include "rtx_os.h"
433  
434 //The thread function instanced in this example
435 void worker(void *arg)
436 {
437   while(1) 
438   {
439     //work
440     osDelay(10000);
441   }  
442 }
443  
444 // Define objects that are statically allocated for worker thread 1
445 osRtxThread_t worker_thread_tcb_1;
446  
447 // Reserve two areas for the stacks of worker thread 1
448 // uint64_t makes sure the memory alignment is 8
449 uint64_t worker_thread_stk_1[64];
450  
451 // Define the attributes which are used for thread creation
452 // Optional const saves RAM memory and includes the values in periodic ROM tests 
453 const osThreadAttr_t worker_attr_1 = {
454   "wrk1",
455   osThreadJoinable,
456   &worker_thread_tcb_1,
457   sizeof(worker_thread_tcb_1),
458   &worker_thread_stk_1[0],
459   sizeof(worker_thread_stk_1),
460   osPriorityAboveNormal,
461   0
462 };
463  
464 // Define ID object for thread
465 osThreadId_t th1;
466  
467 /*----------------------------------------------------------------------------
468  * Application main thread
469  *---------------------------------------------------------------------------*/
470 void app_main (void *argument) {
471   uint32_t param = NULL;
472  
473   // Create an instance of the worker thread with static resources (TCB and stack)
474   th1 = osThreadNew(worker, &param, &worker_attr_1);
475  
476   for (;;) {}
477 }
478  
479 int main (void) {
480   // System Initialization
481   SystemCoreClockUpdate();
482   // ...
483
484   osKernelInitialize();                 // Initialize CMSIS-RTOS
485   osThreadNew(app_main, NULL, NULL);    // Create application main thread
486   osKernelStart();                      // Start thread execution
487   for (;;) {}
488 }
489 \endcode
490
491
492 \section ThreadStack Thread Stack Management
493
494 For Cortex-M processors without floating point unit the thread context requires 64 bytes on the local stack.
495
496 \note For Cortex-M4/M7 with FP the thread context requires 200 bytes on the local stack. For these devices the default stack
497 space should be increased to a minimum of 300 bytes.
498
499 Each thread is provided with a separate stack that holds the thread context and stack space for automatic variables and
500 return addresses for function call nesting. The stack sizes of RTX threads are flexibly configurable as explained in the
501 section \ref threadConfig. RTX offers a configurable checking for stack overflows and stack utilization. 
502
503
504 \section lowPower Low-Power Operation
505
506 The system thread \b osRtxIdleThread can be use to switch the system into a low-power mode. The easiest form to enter a
507 low-power mode is the execution of the \c __WFE function that puts the processor into a sleep mode where it waits for an
508 event.
509
510 <b>Code Example:</b>
511 \code
512 #include "RTE_Components.h"
513 #include CMSIS_device_header            /* Device definitions                 */
514  
515 void osRtxIdleThread (void) {
516   /* The idle demon is a system thread, running when no other thread is       */
517   /* ready to run.                                                            */
518  
519   for (;;) {
520     __WFE();                            /* Enter sleep mode                   */
521   }
522 }
523 \endcode
524
525 \note
526 \c __WFE() is not available in every Cortex-M implementation. Check device manuals for availability.
527
528
529 \section kernelTimer RTX kernel Timer Tick
530
531 By default, RTX5 uses the Cortex-M
532 <a href="http://www.keil.com/support/man/docs/gsac/GSAC_SYSTICKtimer.htm" target="_blank">SysTick</a> timer to generate
533 periodic interrupts for the RTX kernel timer tick. CMSIS-RTOS provides \ref CMSIS_RTOS_TimerMgmt functions and several
534 CMSIS-RTOS functions have a \a timeout parameter. This periodic RTX kernel timer tick interrupt is used to derive the
535 required time interval. RTX5 also provides configuration options for an alternative timer and tick-less operation. 
536
537 To handle timeout and time delays for threads, the RTX5 thread management is controlled by the RTX kernel timer tick
538 interrupt. The thread context contains all CPU registers (R0 - R12), the return address (LR), the program counter (PC), and
539 the processor status register (xPSR). For the Cortex-M4/M7 FPU the floating point status and registers (S0 - S32, FPSCR) are
540 also part of the thread context.
541
542 When a thread switch occurs:
543  - the thread context of the current running thread is stored on the local stack of this thread.
544  - the stack pointer is switched to the next running thread.
545  - the thread context of this next running thread is restored and this thread starts to run.
546
547
548 \section CMSIS_RTOS_TimeOutValue Timeout Value   
549
550 Timeout values are an argument to several \b osXxx functions to allow time for resolving a request. A timeout value of \b 0
551 means that the RTOS does not wait and the function returns instantly, even when no resource is available. A timeout value of
552 \ref osWaitForever means that the RTOS waits infinitely until a resource becomes available.
553  
554 The timeout value specifies the number of timer ticks until the time delay elapses. The value is an upper bound and 
555 depends on the actual time elapsed since the last timer tick. 
556
557 Examples:
558   - timeout value \b 0 : the system does not wait, even when no resource is available the RTOS function returns instantly. 
559   - timeout value \b 1 : the system waits until the next timer tick occurs; depending on the previous timer tick, it may be a
560     very short wait time.
561   - timeout value \b 2 : actual wait time is between 1 and 2 timer ticks.
562   - timeout value \ref osWaitForever : system waits infinite until a resource becomes available. 
563   
564 \image html TimerValues.png "Example of timeout using osDelay()"
565
566
567 \section CMSIS_RTOS_ISR_Calls Calls from Interrupt Service Routines 
568
569 The following CMSIS-RTOS2 functions can be called from threads and Interrupt Service Routines (ISR):
570   - \ref osKernelGetSysTimerCount, \ref osKernelGetSysTimerFreq
571   - \ref osThreadFlagsSet
572   - \ref osEventFlagsSet, \ref osEventFlagsClear, \ref osEventFlagsGet, \ref osEventFlagsWait
573   - \ref osSemaphoreAcquire, \ref osSemaphoreRelease, \ref osSemaphoreGetCount
574   - \ref osMemoryPoolAlloc, \ref osMemoryPoolFree, \ref osMemoryPoolGetCapacity, \ref osMemoryPoolGetBlockSize,
575     \ref osMemoryPoolGetCount, \ref osMemoryPoolGetSpace
576   - \ref osMessageQueuePut, \ref osMessageQueueGet, \ref osMessageQueueGetCapacity, \ref osMessageQueueGetMsgSize,
577     \ref osMessageQueueGetCount, \ref osMessageQueueGetSpace
578
579 Functions that cannot be called from an ISR are verifying the interrupt status and return the status code \b osErrorISR, in
580 case they are called from an ISR context. In some implementations, this condition might be caught using the HARD_FAULT
581 vector.
582
583
584 \section TickLess Tick-less Low-Power Operation
585
586 RTX5 provides extension for tick-less operation which is useful for applications that use extensively low-power modes where
587 the SysTick timer is also disabled. To provide a time-tick in such power-saving modes, a wake-up timer is used to
588 derive timer intervals. The CMSIS-RTOS2 functions \ref osKernelSuspend and \ref osKernelResume control the tick-less
589 operation.
590
591 Using this functions allows the RTX5 thread scheduler to stop the periodic kernel tick interrupt. When all active threads
592 are suspended, the system enters power-down and calculates how long it can stay in this power-down mode. In the power-down
593 mode the processor and peripherals can be switched off. Only a wake-up timer must remain powered, because this timer is
594 responsible to wake-up the system after the power-down period expires.
595
596 The tick-less operation is controlled from the \b osRtxIdleThread thread. The wake-up timeout value is set before the system
597 enters the power-down mode. The function \ref osKernelSuspend calculates the wake-up timeout measured in RTX Timer Ticks;
598 this value is used to setup the wake-up timer that runs during the power-down mode of the system.
599
600 Once the system resumes operation (either by a wake-up time out or other interrupts) the RTX5 thread scheduler is started
601 with the function \ref osKernelResume. The parameter \a sleep_time specifies the time (in RTX Timer Ticks) that the system
602 was in power-down mode.
603
604 <b>Code Example:</b>
605 \code
606 #include "msp.h"                        // Device header
607
608 /*----------------------------------------------------------------------------
609  *      MSP432 Low-Power Extension Functions
610  *---------------------------------------------------------------------------*/
611 static void MSP432_LP_Entry(void) {
612   /* Enable PCM rude mode, which allows to device to enter LPM3 without waiting for peripherals */
613   PCM->CTL1 = PCM_CTL1_KEY_VAL | PCM_CTL1_FORCE_LPM_ENTRY;       
614   /* Enable all SRAM bank retentions prior to going to LPM3  */
615   SYSCTL->SRAM_BANKRET |= SYSCTL_SRAM_BANKRET_BNK7_RET;
616   __enable_interrupt();
617   NVIC_EnableIRQ(RTC_C_IRQn);
618   /* Do not wake up on exit from ISR */
619   SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
620   /* Setting the sleep deep bit */
621   SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);  
622 }
623  
624 static volatile unsigned int tc;
625 static volatile unsigned int tc_wakeup;
626  
627 void RTC_C_IRQHandler(void)
628 {
629   if (tc++ > tc_wakeup) 
630   {
631     SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;    
632     NVIC_DisableIRQ(RTC_C_IRQn);
633     NVIC_ClearPendingIRQ(RTC_C_IRQn);
634     return;
635   }
636   if (RTC_C->PS0CTL & RTC_C_PS0CTL_RT0PSIFG)
637   {
638     RTC_C->CTL0 = RTC_C_KEY_VAL;                 // Unlock RTC key protected registers
639     RTC_C->PS0CTL &= ~RTC_C_PS0CTL_RT0PSIFG;
640     RTC_C->CTL0 = 0;
641     SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);
642   }
643 }
644  
645 uint32_t g_enable_sleep = 0;
646   
647 void osRtxIdleThread (void) {
648   
649   for (;;) {
650     tc_wakeup = osKernelSuspend();
651     /* Is there some time to sleep? */
652     if (tc_wakeup > 0) {
653       tc = 0;
654       /* Enter the low power state */
655       MSP432_LP_Entry();
656       __WFI();
657     }
658     /* Adjust the kernel ticks with the amount of ticks slept */
659     osKernelResume (tc);
660   }
661 }
662 \endcode
663
664 \note
665 \c __WFI() is not available in every ARM Cortex-M implementation. Check device manuals for availability.
666
667
668 \section rtx_os_h RTX5 Header File
669
670 Every implementation of the CMSIS-RTOS2 API can bring its own additional features. RTX5 adds a couple of
671 \ref rtx5_specific "functions" for the idle more, for error notifications, and special system timer functions. It also is
672 using macros for control block and memory sizes.
673
674 If you require some of the RTX specific functions in your application code, \#include the header file \b %rtx_os.h:
675
676 \include rtx_os.h
677 */
678
679 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
680 /**
681 \page config_rtx5 Configure RTX v5
682
683 The file "RTX_Config.h" defines the configuration parameters of CMSIS-RTOS RTX and must be part of every project that is
684 using the CMSIS-RTOS RTX kernel. The file "RTX_Config.c" contains stubs of the functions \b osRtxIdleThread and
685 \b osRtxErrorNotify that can be adapted to the application's needs.
686
687 The configuration file uses
688 <a class="el" href="http://www.keil.com/pack/doc/CMSIS/Pack/html/_config_wizard.html" target="_blank">Configuration Wizard Annotations</a>.
689 Depending on the development tool, the annotations might lead to a more user-friendly graphical representation of the
690 settings. The screenshot below is a screenshot from the µVision \b Configuration \b Wizard view:
691
692 \image html config_wizard.png "RTX_Config.h in Configuration Wizard View"
693
694 The configuration options are explained on these pages:
695 - \ref systemConfig
696 - \ref threadConfig
697 - \ref timerConfig
698 - \ref eventFlagsConfig
699 - \ref mutexConfig
700 - \ref semaphoreConfig
701 - \ref memPoolConfig
702 - \ref msgQueueConfig
703
704
705 \section systemConfig System Configuration
706
707 The system configuration covers system-wide settings for the global memory pool, tick frequency, ISR event buffer and
708 round-robin thread switching.
709
710 <b>System Configuration Options</b>
711 \image html config_wizard_system.png "RTX_Config.h: System Configuration"
712
713 Name                                   | \#define                 | Description
714 ---------------------------------------|--------------------------|----------------------------------------------------------------
715 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.
716 Kernel Tick Frequency (Hz)             | \c OS_TICK_FREQ          | Defines base time unit for delays and timeouts in Hz. Default: 1000Hz = 1ms period.
717 Round-Robin Thread switching           | \c OS_ROBIN_ENABLE       | Enables Round-Robin Thread switching.
718 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]}.
719 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}.
720
721 \subsection systemConfig_glob_mem Global dynamic memory
722 Refer to \ref GlobalMemoryPool.
723
724 \subsection systemConfig_rr Round-Robin Thread Switching
725 RTX5 may be configured to use round-robin multitasking thread switching. Round-robin allows quasi-parallel execution of
726 several threads. Threads are not really executed concurrently, but are timed where the available CPU time is divided
727 into time slices and RTX5 assigns a time slice to each thread. Because the time slice is typically short (only a few
728 milliseconds), it appears as though threads execute simultaneously.
729
730 Threads execute for the duration of their time slice (unless the thread's time slice is given up). Then, RTX switches to the
731 next thread that is in \b READY state and has the same priority. If no other task with the same priority is ready to run, the
732 current running task resumes it execution.
733
734 \subsection systemConfig_isr_fifo ISR FIFO Queue
735 The RTX functions (\ref CMSIS_RTOS_ISR_Calls), when called from and interrupt handler, store the request type and optional
736 parameter to the ISR FIFO queue buffer to be processed later, after the interrupt handler exits.
737
738 The scheduler is activated immediately after the IRQ handler has finished its execution to process the requests stored to the
739 FIFO queue buffer. The required size of this buffer depends on the number of functions that are called within the interrupt
740 handler. An insufficient queue size will be caught by \b osRtxErrorNotify with error code \b osRtxErrorISRQueueOverflow.
741
742
743 \section threadConfig Thread Configuration
744
745 The RTX5 provides several parameters to configure the \ref CMSIS_RTOS_ThreadMgmt functions.
746
747 <b>Thread Configuration Options</b>
748 \image html config_wizard_threads.png "RTX_Config.h: Thread Configuration"
749
750 <br> 
751 Option                                                   | \#define               | Description
752 :--------------------------------------------------------|:-----------------------|:---------------------------------------------------------------
753 Object specific Memory allocation                        | \c OS_THREAD_OBJ_MEM   | Enables object specific memory allocation. See \ref ObjectMemoryPool.
754 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]}.
755 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]}.
756 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}. 
757 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}. 
758 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}. 
759 Stack overrun checking                                   | \c OS_STACK_CHECK   | Enable stack overrun checks at thread switch. 
760 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.
761 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.
762
763 \subsection threadConfig_countstack Configuration of Thread Count and Stack Space
764
765 The RTX5 kernel uses a separate stack space for each thread and provides two methods for defining the stack requirements:
766  - <b>Static allocation</b>: when \ref osThreadAttr_t::stack_mem and \ref osThreadAttr_t::stack_size specify a memory area
767    which is used for the thread stack.
768  - <b>Dynamic allocation</b>: when \ref osThreadAttr_t is NULL or \ref osThreadAttr_t::stack_mem is NULL, the system
769    allocates the stack memory from:
770      - Object-specific Memory Pool (default Stack size) when "Object specific Memory allocation" is enabled and "Number of
771        user Threads with default Stack size" is not \token{0} and \ref osThreadAttr_t::stack_size is \token{0} (or
772        \ref osThreadAttr_t is NULL).
773      - Object-specific Memory Pool (user-provided Stack size) when "Object specific Memory allocation" is enabled and "Total
774        Stack size for user..."  is not \token{0} and \ref osThreadAttr_t::stack_size is not \token{0}.
775      - Global Memory Pool when "Object specific Memory allocation" is disabled or (\ref osThreadAttr_t::stack_size is not
776        \token{0} and "Total Stack size for user..." is \token{0}) or (\ref osThreadAttr_t::stack_size is \token{0} and
777        "Number of user Threads with default Stack size" is \token{0}).
778
779 \ref osThreadAttr_t is a parameter of the function \ref osThreadNew.
780
781 \note
782 Before the RTX kernel is started by the \ref osKernelStart() function, the main stack defined in startup_<i>device</i>.s is
783 used. The main stack is also used for:
784  - user application calls to RTX functions in \b thread \b mode using SVC calls
785  - interrupt/exception handlers.
786  
787 \subsection threadConfig_ovfcheck Stack Overflow Checking
788 RTX5 implements a software stack overflow checking that traps stack overruns. Stack is used for return addresses and
789 automatic variables. Extensive usage or incorrect stack configuration may cause a stack overflow. Software stack overflow
790 checking is controlled with the define \c OS_STACK_CHECK.
791  
792 If a stack overflow is detected, the function \b osRtxErrorNotify with error code \b osRtxErrorStackUnderflow is called. By
793 default, this function is implemented as an endless loop and will practically stop code execution.
794
795 \subsection threadConfig_watermark Stack Usage Watermark
796 RTX5 initializes thread stack with a watermark pattern (0xCC) when a thread is created. This allows the debugger to determine
797 the maximum stack usage for each thread. It is typically used during development but removed from the final application.
798 Stack usage watermark is controlled with the define \c OS_STACK_WATERMARK.
799   
800 Enabling this option significantly increases the execution time of \ref osThreadNew (depends on thread stack size).
801  
802 \subsection threadConfig_procmode Processor Mode for Thread Execution
803 RTX5 allows to execute threads in unprivileged or privileged processor mode. The processor mode is controlled with the
804 define \c OS_PRIVILEGE_MODE.
805  
806 In \b unprivileged processor mode, the application software:
807 - has limited access to the MSR and MRS instructions, and cannot use the CPS instruction.
808 - cannot access the system timer, NVIC, or system control block.
809 - might have restricted access to memory or peripherals.
810
811 In \b privileged processor mode, the application software can use all the instructions and has access to all resources.
812
813
814 \section timerConfig Timer Configuration
815
816 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_TimerMgmt functions.
817
818 <b>Timer Configuration Options</b>
819 \image html config_wizard_timer.png "RTX_Config.h: Timer Configuration"
820
821 Name                                   | \#define                 | Description
822 ---------------------------------------|--------------------------|----------------------------------------------------------------
823 Object specific Memory allocation      | \c OS_TIMER_OBJ_MEM      | Enables object specific memory allocation. 
824 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]}.
825 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} 
826 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}.
827 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]}.
828
829 \subsection timerConfig_obj Object-specific memory allocation
830 See \ref ObjectMemoryPool.
831
832 \subsection timerConfig_user User Timer Thread
833 The RTX5 function \b osRtxTimerThread executes callback functions when a time period expires. The priority of the timer
834 subsystem within the complete RTOS system is inherited from the priority of the \b osRtxTimerThread. This is configured by
835 \c OS_TIMER_THREAD_PRIO. Stack for callback functions is supplied by \b osRtxTimerThread. \c OS_TIMER_THREAD_STACK_SIZE must
836 satisfy the stack requirements of the callback function with the highest stack usage. 
837
838
839 \section eventFlagsConfig Event Flags Configuration
840
841 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_EventFlags functions.
842
843 <b>Event Configuration Options</b>
844 \image html config_wizard_eventFlags.png "RTX_Config.h: Event Flags Configuration"
845
846 Name                                   | \#define                 | Description
847 ---------------------------------------|--------------------------|----------------------------------------------------------------
848 Object specific Memory allocation      | \c OS_EVFLAGS_OBJ_MEM    | Enables object specific memory allocation. See \ref ObjectMemoryPool.
849 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]}.
850
851 \subsection eventFlagsConfig_obj Object-specific memory allocation
852 When object-specific memory is used, the pool size for all Event objects is specified by \c OS_EVFLAGS_NUM. Refer to
853 \ref ObjectMemoryPool.
854
855
856 \section mutexConfig Mutex Configuration
857 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_MutexMgmt functions.
858
859 <b>Mutex Configuration Options</b>
860 \image html config_wizard_mutex.png "RTX_Config.h: Mutex Configuration"
861
862
863 Name                                   | \#define                 | Description
864 ---------------------------------------|--------------------------|----------------------------------------------------------------
865 Object specific Memory allocation      | \c OS_MUTEX_OBJ_MEM      | Enables object specific memory allocation. See \ref ObjectMemoryPool.
866 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]}.
867
868 \subsection mutexConfig_obj Object-specific Memory Allocation
869 When object-specific memory is used, the pool size for all Mutex objects is specified by \c OS_MUTEX_NUM. Refer to
870 \ref ObjectMemoryPool.
871
872
873 \section semaphoreConfig Semaphore Configuration
874
875 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_SemaphoreMgmt functions.
876
877 <b>Semaphore Configuration Options</b>
878 \image html config_wizard_semaphore.png "RTX_Config.h: Semaphore Configuration"
879
880
881 Name                                   | \#define                 | Description
882 ---------------------------------------|--------------------------|----------------------------------------------------------------
883 Object specific Memory allocation      | \c OS_SEMAPHORE_OBJ_MEM  | Enables object specific memory allocation. See \ref ObjectMemoryPool.
884 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]}.
885
886 \subsection semaphoreConfig_obj Object-specific memory allocation
887 When Object-specific Memory is used, the pool size for all Semaphore objects is specified by \c OS_SEMAPHORE_NUM. Refer to
888 \ref ObjectMemoryPool.
889
890
891 \section memPoolConfig Memory Pool Configuration
892
893 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_PoolMgmt functions.
894
895 <b>Memory Pool Configuration Options</b>
896 \image html config_wizard_memPool.png "RTX_Config.h: Memory Pool Configuration"
897
898 Name                                   | \#define                 | Description
899 ---------------------------------------|--------------------------|----------------------------------------------------------------
900 Object specific Memory allocation      | \c OS_MEMPOOL_OBJ_MEM    | Enables object specific memory allocation. See \ref ObjectMemoryPool.
901 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]}.
902 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}.
903
904 \subsection memPoolConfig_obj Object-specific memory allocation
905 When object-specific memory is used, the number of pools for all MemoryPool objects is specified by \c OS_MEMPOOL_NUM. The
906 total storage size reserved for all pools is configured in \c OS_MEMPOOL_DATA_SIZE. Refer to \ref ObjectMemoryPool.
907
908
909 \section msgQueueConfig Message Queue Configuration
910
911 RTX5 provides several parameters to configure the \ref CMSIS_RTOS_Message functions.
912
913 <b>MessageQueue Configuration Options</b>
914 \image html config_wizard_msgQueue.png "RTX_Config.h: Message Queue Configuration"
915
916 Name                                   | \#define                 | Description
917 ---------------------------------------|--------------------------|----------------------------------------------------------------
918 Object specific Memory allocation      | \c OS_MSGQUEUE_OBJ_MEM   | Enables object specific memory allocation. See \ref ObjectMemoryPool.
919 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]}.
920 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}.
921
922 \subsection msgQueueConfig_obj Object-specific memory allocation
923 When Object-specific Memory is used, the number of queues for all Message Queue objects is specified by \c OS_MSGQUEUE_NUM.
924 The total storage size reserved for all queues is configured in \c OS_MSGQUEUE_DATA_SIZE. Refer to \ref ObjectMemoryPool.
925 */
926
927
928 /* ========================================================================================================================== */
929 /** 
930 \page creating_RTX5_LIB Building the RTX5 Library
931
932 The CMSIS Pack contains a µVision project for building the complete set of RTX5 libraries. This project can also be used as
933 a reference for building the RTX5 libraries using a tool-chain of your choice.
934
935 -# Open the project \b RTX_CM.uvprojx from the pack folder <b>CMSIS/RTOS2/RTX/Library/ARM/MDK</b> in µVision.
936 -# Select the project target that matches your device's processor core. 
937    \n The project provides target configuration for all supported Cortex-M targets supported by RTX5.
938 -# You can find out about the required preprocessor defines in the dialogs <b>Options for Target - C/C++</b> and
939    <b>Options for Target - Asm</b>.
940 -# From the <b>Project</b> window you find the list of source files required for a complete library build.
941 -# Build the library of your choice using \b Project - \b Build \b Target (or press F7).
942
943 \image html own_lib_projwin.png "Project with files for ARMv8-M Mainline"
944 */
945
946
947 /* ========================================================================================================================== */
948 /** 
949 \page dirstructfiles5 Directory Structure and File Overview
950
951 The following section provides an overview of the directory structure and the files that are relevant for the user's for
952 CMSIS-RTOS RTX v5. The following directory references start below the CMSIS pack installation path, for example
953 ARM/CMSIS/<i>version</i>/CMSIS/RTOS2.
954
955 \section Folders RTX v5 Directory Structure
956
957 The CMSIS-RTOS RTX v5 is delivered in source code and several examples are provided. 
958
959 <table class="cmtable" summary="CMSIS-RTOS RTX Library Files">
960     <tr>
961       <th>Directory</th>
962       <th>Content</th>
963     </tr>
964     <tr>
965       <td>Include</td>
966       <td>The include file for CMSIS-RTOS API v2. cmsis_os2.h is the central include file for user applications.</td>
967     </tr>
968     <tr>
969       <td>Template</td>
970       <td>CMSIS-RTOS API template source and header file.</td>
971     </tr>
972     <tr>
973       <td>RTX</td>
974       <td>Directory with RTX specific files and folders. Also contains the component viewer description file.</td>
975     </tr>
976     <tr>
977       <td>RTX/Config</td>
978       <td>CMSIS-RTOS RTX configuration files %RTX_Config.h and %RTX_Config.c.</td>
979     </tr>
980     <tr>
981       <td>RTX/Examples</td>
982       <td>Example projects that can be directly used in development tools.</td>
983     </tr>
984     <tr>
985       <td>RTX/Include</td>
986       <td>RTX v5 specific include files.</td>
987     </tr>
988     <tr>
989       <td>RTX/Include1</td>
990       <td>CMSIS-RTOS v1 API header file.</td>
991     </tr>
992     <tr>
993       <td>RTX/Library</td>
994       <td>Pre-built libraries (see next table for details).</td>
995     </tr>
996     <tr>
997       <td>RTX/Source</td>
998       <td>Source code that can be used with ARMCC and GCC.</td>
999     </tr>
1000     <tr>
1001       <td>RTX/Template</td>
1002       <td>User code templates for creating application projects with CMSIS-RTOS RTX v5.</td>
1003     </tr>
1004 </table>
1005
1006 \section libFiles RTX v5 Library Files
1007
1008 The CMSIS-RTOS RTX Library is available pre-compiled for ARMCC and GCC compilers and supports all Cortex-M
1009 processor variants in every configuration, including ARM Cortex-M23 and Cortex-M33.
1010
1011 <table class="cmtable" summary="CMSIS-RTOS RTX Library Files">
1012     <tr>
1013       <th>Library File</th>
1014       <th>Processor Configuration</th>
1015     </tr>
1016     <tr>
1017       <td>Library/ARM/RTX_CM0.lib</td>
1018       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Cortex-M0 and M1, little-endian.</td>
1019     </tr>
1020     <tr>
1021       <td>Library/ARM/RTX_CM3.lib</td>
1022       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Cortex-M3, M4, and M7 without FPU, little-endian.</td>
1023     </tr>
1024     <tr>
1025       <td>Library/ARM/RTX_CM4F.lib</td>
1026       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, Cortex-M4 and M7 with FPU, little-endian.</td>
1027     </tr>
1028     <tr>
1029       <td>Library/ARM/RTX_V8MB.lib</td>
1030       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, ARMv8-M baseline.</td>
1031     </tr>
1032     <tr>
1033       <td>Library/ARM/RTX_V8MBN.lib</td>
1034       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, ARMv8-M baseline, non-secure.</td>
1035     </tr>
1036     <tr>
1037       <td>Library/ARM/RTX_V8MM.lib</td>
1038       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, ARMv8-M mainline.</td>
1039     </tr>
1040     <tr>
1041       <td>Library/ARM/RTX_V8MMF.lib</td>
1042       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, ARMv8-M mainline with FPU.</td>
1043     </tr>
1044     <tr>
1045       <td>Library/ARM/RTX_V8MMFN.lib</td>
1046       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, ARMv8-M mainline with FPU, non-secure.</td>
1047     </tr>
1048     <tr>
1049       <td>Library/ARM/RTX_V8MMN.lib</td>
1050       <td>CMSIS-RTOS RTX Library for ARMCC Compiler, ARMv8-M mainline, non-secure.</td>
1051     </tr>
1052     <tr>
1053       <td>Library/GCC/libRTX_CM0.a</td>
1054       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Cortex-M0 and M1, little-endian.</td>
1055     </tr>
1056     <tr>
1057       <td>Library/GCC/libRTX_CM3.a</td>
1058       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Cortex-M3, M4, and M7 without FPU, little-endian.</td>
1059     </tr>
1060     <tr>
1061       <td>Library/GCC/libRTX_CM4F.a</td>
1062       <td>CMSIS-RTOS libRTX Library for GCC Compiler, Cortex-M4 and M7 with FPU, little-endian.</td>
1063     </tr>
1064     <tr>
1065       <td>Library/GCC/libRTX_V8MB.a</td>
1066       <td>CMSIS-RTOS libRTX Library for GCC Compiler, ARMv8-M baseline.</td>
1067     </tr>
1068     <tr>
1069       <td>Library/GCC/libRTX_V8MBN.a</td>
1070       <td>CMSIS-RTOS libRTX Library for GCC Compiler, ARMv8-M baseline, non-secure.</td>
1071     </tr>
1072     <tr>
1073       <td>Library/GCC/libRTX_V8MM.a</td>
1074       <td>CMSIS-RTOS libRTX Library for GCC Compiler, ARMv8-M mainline.</td>
1075     </tr>
1076     <tr>
1077       <td>Library/GCC/libRTX_V8MMF.a</td>
1078       <td>CMSIS-RTOS libRTX Library for GCC Compiler, ARMv8-M mainline with FPU.</td>
1079     </tr>
1080     <tr>
1081       <td>Library/GCC/libRTX_V8MMFN.a</td>
1082       <td>CMSIS-RTOS libRTX Library for GCC Compiler, ARMv8-M mainline with FPU, non-secure.</td>
1083     </tr>
1084     <tr>
1085       <td>Library/GCC/libRTX_V8MMN.a</td>
1086       <td>CMSIS-RTOS libRTX Library for GCC Compiler, ARMv8-M mainline, non-secure.</td>
1087     </tr>
1088 </table>
1089 */
1090
1091 /* ========================================================================================================================== */
1092 /** 
1093 \page technicalData5 Technical Data
1094
1095 This section will list the technical data of CMSIS-RTOS RTX v5. Work in progress.
1096 */
1097
1098
1099 /* ========================================================================================================================== */
1100 /** 
1101 \page misraCompliance5 MISRA-C Compliance Exceptions
1102 CMSIS-RTOS RTX tries to be MISRA-C compliant as much as possible. However, there are some violations in order to simplify
1103 the overall code logic and to generate more efficient code.
1104
1105 This page will list the MISRA-C compliance exceptions. Work in progress.
1106 */
1107
1108 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1109 /**
1110 \page rtosValidation RTOS Validation
1111
1112 ARM offers a <a class=el href="http://www.keil.com/pack" target="_blank">Software Pack</a> for the CMSIS-RTOS Validation.
1113 The <b>ARM::CMSIS-RTOS_Validation</b> Pack contains the following:
1114
1115  - Source code of a CMSIS-RTOS Validation Suite along with configuration file.
1116  - Documentation of the CMSIS-RTOS Validation Suite.
1117  - Example that shows the usage of the CMSIS-RTOS Validation Suite using simulation.
1118
1119 \note
1120 Currently, a public version of the test suite is available only for CMSIS-RTOS v1 API.
1121
1122 The CMSIS-RTOS Validation Suite performs generic validation of various RTOS features. The test cases verify the 
1123 functional behavior, test invalid parameters and call management functions from ISR.
1124
1125 The following CMSIS-RTOS features can be tested with the current release:
1126  - Thread : Create multiple threads, terminate, restart, yield, change priority 
1127  - Timer : Create periodic and one-shot timers
1128  - GenWait : Call generic wait functions (osDelay and osWait)
1129  - WaitFunc : Measure wait ticks (delay, mail, message, mutex, semaphore, signal)
1130  
1131 Moreover the following inter-thread communication functions can be tested: 
1132  - Signal : Verify signal events
1133  - Memory Pool : Verify memory allocation
1134  - Message Queue : Exchange messages between threads
1135  - Mail Queue : Exchange data between threads
1136  - Mutex : Synchronize resource access 
1137  - Semaphore : Access shared resources 
1138  
1139 The RTOS Validation output can be printed to a console, output via ITM printf, or output to a memory buffer.
1140  
1141 \section test_output Sample Test Output
1142 \verbatim
1143 CMSIS-RTOS Test Suite   Oct 21 2015   16:39:16 
1144
1145 TEST 01: TC_ThreadCreate                  PASSED
1146 TEST 02: TC_ThreadMultiInstance           PASSED
1147 TEST 03: TC_ThreadTerminate               PASSED
1148   :
1149   :
1150 TEST 08: TC_ThreadChainedCreate           PASSED
1151 TEST 09: TC_ThreadYield                   NOT EXECUTED
1152 TEST 10: TC_ThreadParam                   PASSED
1153   :
1154   :
1155 TEST 60: TC_MailFromISRToThread           PASSED
1156
1157 Test Summary: 60 Tests, 59 Executed, 59 Passed, 0 Failed, 0 Warnings.
1158 Test Result: PASSED
1159 \endverbatim
1160 */
1161
1162
1163 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1164 /**
1165 \page functionOverview Function Overview
1166
1167 CMSIS-RTOS v2 provides multiple API interfaces:
1168   - \subpage rtos_api2 is the new C function API that supports dynamic object creation and ARMv8-M (ARM Cortex-M23 and
1169     Cortex-M33).
1170   - <a class="el" href="../../RTOS/html/functionOverview.html">CMSIS-RTOS C API v1</a> is a C function API that is backward
1171     compatible with CMSIS-RTOS v1.
1172   - \subpage rtos_apicpp is a C++ class function API.
1173
1174 It is possible to intermix the different API variants in the same application and even in the same C/C++ source module.
1175 However, the functions of the <b>C API Version 1</b> may be deprecated in future versions of CMSIS-RTOS.
1176
1177 \section rtos_api2 CMSIS-RTOS2
1178
1179 Overview of all CMSIS-RTOS C API v2 functions that are implemented in the \subpage cmsis_os2_h. 
1180
1181  - \ref CMSIS_RTOS_KernelCtrl
1182    - \ref osKernelGetInfo : \copybrief osKernelGetInfo
1183    - \ref osKernelGetState : \copybrief osKernelGetState
1184    - \ref osKernelGetSysTimerCount : \copybrief osKernelGetSysTimerCount
1185    - \ref osKernelGetSysTimerFreq : \copybrief osKernelGetSysTimerFreq
1186    - \ref osKernelInitialize : \copybrief osKernelInitialize
1187    - \ref osKernelLock : \copybrief osKernelLock
1188    - \ref osKernelUnlock : \copybrief osKernelUnlock
1189    - \ref osKernelRestoreLock : \copybrief osKernelRestoreLock
1190    - \ref osKernelResume : \copybrief osKernelResume
1191    - \ref osKernelStart : \copybrief osKernelStart
1192    - \ref osKernelSuspend : \copybrief osKernelSuspend
1193    - \ref osKernelGetTickCount : \copybrief osKernelGetTickCount
1194    - \ref osKernelGetTickFreq : \copybrief osKernelGetTickFreq
1195
1196  - \ref CMSIS_RTOS_ThreadMgmt
1197    - \ref osThreadDetach : \copybrief osThreadDetach
1198    - \ref osThreadEnumerate : \copybrief osThreadEnumerate
1199    - \ref osThreadExit : \copybrief osThreadExit
1200    - \ref osThreadGetCount : \copybrief osThreadGetCount
1201    - \ref osThreadGetId : \copybrief osThreadGetId
1202    - \ref osThreadGetName : \copybrief osThreadGetName
1203    - \ref osThreadGetPriority : \copybrief osThreadGetPriority
1204    - \ref osThreadGetStackSize : \copybrief osThreadGetStackSize
1205    - \ref osThreadGetStackSpace : \copybrief osThreadGetStackSpace
1206    - \ref osThreadGetState : \copybrief osThreadGetState
1207    - \ref osThreadJoin : \copybrief osThreadJoin
1208    - \ref osThreadNew : \copybrief osThreadNew
1209    - \ref osThreadResume : \copybrief osThreadResume
1210    - \ref osThreadSetPriority : \copybrief osThreadSetPriority
1211    - \ref osThreadSuspend : \copybrief osThreadSuspend
1212    - \ref osThreadTerminate : \copybrief osThreadTerminate
1213    - \ref osThreadYield : \copybrief osThreadYield
1214
1215  - \ref CMSIS_RTOS_ThreadFlagsMgmt
1216    - \ref osThreadFlagsSet : \copybrief osThreadFlagsSet
1217    - \ref osThreadFlagsClear : \copybrief osThreadFlagsClear
1218    - \ref osThreadFlagsGet : \copybrief osThreadFlagsGet
1219    - \ref osThreadFlagsWait : \copybrief osThreadFlagsWait
1220
1221  - \ref CMSIS_RTOS_EventFlags
1222    - \ref osEventFlagsGetName : \copybrief osEventFlagsGetName
1223    - \ref osEventFlagsNew : \copybrief osEventFlagsNew
1224    - \ref osEventFlagsDelete : \copybrief osEventFlagsDelete
1225    - \ref osEventFlagsSet : \copybrief osEventFlagsSet
1226    - \ref osEventFlagsClear : \copybrief osEventFlagsClear
1227    - \ref osEventFlagsGet : \copybrief osEventFlagsGet
1228    - \ref osEventFlagsWait : \copybrief osEventFlagsWait
1229
1230  - \ref CMSIS_RTOS_Wait
1231    - \ref osDelay : \copybrief osDelay
1232    - \ref osDelayUntil : \copybrief osDelayUntil
1233
1234  - \ref CMSIS_RTOS_TimerMgmt
1235    - \ref osTimerDelete : \copybrief osTimerDelete
1236    - \ref osTimerGetName : \copybrief osTimerGetName
1237    - \ref osTimerIsRunning : \copybrief osTimerIsRunning
1238    - \ref osTimerNew : \copybrief osTimerNew
1239    - \ref osTimerStart : \copybrief osTimerStart
1240    - \ref osTimerStop : \copybrief osTimerStop
1241
1242  - \ref CMSIS_RTOS_MutexMgmt
1243    - \ref osMutexAcquire : \copybrief osMutexAcquire
1244    - \ref osMutexDelete : \copybrief osMutexDelete
1245    - \ref osMutexGetName : \copybrief osMutexGetName
1246    - \ref osMutexGetOwner : \copybrief osMutexGetOwner
1247    - \ref osMutexNew : \copybrief osMutexNew
1248    - \ref osMutexRelease : \copybrief osMutexRelease
1249
1250  - \ref CMSIS_RTOS_SemaphoreMgmt
1251    - \ref osSemaphoreAcquire : \copybrief osSemaphoreAcquire
1252    - \ref osSemaphoreDelete : \copybrief osSemaphoreDelete
1253    - \ref osSemaphoreGetCount : \copybrief osSemaphoreGetCount
1254    - \ref osSemaphoreGetName : \copybrief osSemaphoreGetName
1255    - \ref osSemaphoreNew : \copybrief osSemaphoreNew
1256    - \ref osSemaphoreRelease : \copybrief osSemaphoreRelease
1257
1258  - \ref CMSIS_RTOS_PoolMgmt
1259    - \ref osMemoryPoolAlloc : \copybrief osMemoryPoolAlloc
1260    - \ref osMemoryPoolDelete : \copybrief osMemoryPoolDelete
1261    - \ref osMemoryPoolFree : \copybrief osMemoryPoolFree
1262    - \ref osMemoryPoolGetBlockSize : \copybrief osMemoryPoolGetBlockSize
1263    - \ref osMemoryPoolGetCapacity : \copybrief osMemoryPoolGetCapacity
1264    - \ref osMemoryPoolGetCount : \copybrief osMemoryPoolGetCount
1265    - \ref osMemoryPoolGetName : \copybrief osMemoryPoolGetName
1266    - \ref osMemoryPoolGetSpace : \copybrief osMemoryPoolGetSpace
1267    - \ref osMemoryPoolNew : \copybrief osMemoryPoolNew
1268
1269  - \ref CMSIS_RTOS_Message
1270    - \ref osMessageQueueDelete : \copybrief osMessageQueueDelete
1271    - \ref osMessageQueueGet : \copybrief osMessageQueueGet
1272    - \ref osMessageQueueGetCapacity : \copybrief osMessageQueueGetCapacity
1273    - \ref osMessageQueueGetCount : \copybrief osMessageQueueGetCount
1274    - \ref osMessageQueueGetMsgSize : \copybrief osMessageQueueGetMsgSize
1275    - \ref osMessageQueueGetName : \copybrief osMessageQueueGetName
1276    - \ref osMessageQueueGetSpace : \copybrief osMessageQueueGetSpace
1277    - \ref osMessageQueueNew : \copybrief osMessageQueueNew
1278    - \ref osMessageQueuePut : \copybrief osMessageQueuePut
1279    - \ref osMessageQueueReset : \copybrief osMessageQueueReset
1280
1281  - \ref rtx5_specific
1282    - \ref osRtxErrorNotify : \copybrief osRtxErrorNotify
1283    - \ref osRtxIdleThread : \copybrief osRtxIdleThread
1284    - \ref osRtxSysTimerSetup : \copybrief osRtxSysTimerSetup
1285    - \ref osRtxSysTimerEnable : \copybrief osRtxSysTimerEnable
1286    - \ref osRtxSysTimerDisable : \copybrief osRtxSysTimerDisable
1287    - \ref osRtxSysTimerAckIRQ : \copybrief osRtxSysTimerAckIRQ
1288    - \ref osRtxSysTimerGetCount : \copybrief osRtxSysTimerGetCount
1289    - \ref osRtxSysTimerGetFreq : \copybrief osRtxSysTimerGetFreq
1290
1291 The following CMSIS-RTOS2 functions can be called from threads and \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines"
1292 (ISR):
1293    - \ref osKernelGetSysTimerCount, \ref osKernelGetSysTimerFreq
1294    - \ref osThreadFlagsSet
1295    - \ref osEventFlagsSet, \ref osEventFlagsClear, \ref osEventFlagsGet, \ref osEventFlagsWait
1296    - \ref osSemaphoreAcquire, \ref osSemaphoreRelease, \ref osSemaphoreGetCount
1297    - \ref osMemoryPoolAlloc, \ref osMemoryPoolFree, \ref osMemoryPoolGetCapacity, \ref osMemoryPoolGetBlockSize,
1298      \ref osMemoryPoolGetCount, \ref osMemoryPoolGetSpace
1299    - \ref osMessageQueuePut, \ref osMessageQueueGet, \ref osMessageQueueGetCapacity, \ref osMessageQueueGetMsgSize,
1300      \ref osMessageQueueGetCount, \ref osMessageQueueGetSpace
1301 */
1302
1303
1304 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1305 /**
1306 \page rtos_apicpp CMSIS-RTOS C++ API
1307
1308 The C++11/C++14 interface is planned to be released in January 2017.
1309 */
1310
1311
1312 /* ======================================================================================================================== */
1313 // Group creation for Reference 
1314 /* 
1315 \addtogroup CMSIS_RTOS1 CMSIS-RTOS API v1
1316 \brief This section describes the CMSIS-RTOS API v1. 
1317 \details 
1318 The CMSIS-RTOS is a generic API layer that interfaces to an existing RTOS kernel.
1319
1320 CMSIS-RTOS API v2 provides an translation layer for the
1321 <a class="el" href="../../RTOS/html/index.html">CMSIS-RTOS API v1</a> that simplifies migration.
1322
1323 Refer to the <a class="el" href="../../RTOS/html/modules.html">Reference</a> guide of the CMSIS-RTOS API v1 for details.
1324 */
1325
1326 // Group creation for Reference 
1327 /** 
1328 \addtogroup CMSIS_RTOS CMSIS-RTOS2 API
1329 \brief Describes the C function interface of CMSIS-RTOS API v2. 
1330 \details 
1331 The CMSIS-RTOS2 is a generic API layer that interfaces to an RTOS kernel.
1332
1333 The complete API interface is defined in the \ref cmsis_os2_h. When using dynamic memory allocation for objects, source code
1334 or libraries require no modifications when using on a different CMSIS-RTOS2 implementation.
1335 */
1336
1337 /** 
1338 \addtogroup rtx5_specific RTX5 Specifics
1339 \brief This section describes CMSIS-RTOS RTX5 specifics.
1340 \details
1341 The RTX5 kernel can be customized for different application requirements:
1342 - If you are depending on the \ref lowPower "lowest power consumption" possible, you need to adapt the function
1343   \ref osRtxIdleThread to send the system to sleep mode as often as possible. In addition, use the
1344   \ref TickLess "tick-less low power" functions \ref osKernelSuspend and \ref osKernelResume to suspend the scheduler and to
1345   stop the SysTick timer.
1346 - If you need to specify an \ref kernelTimer "alternate hardware timer" as the system tick timer, you need to implement the
1347   functions \ref osRtxSysTimerSetup, \ref osRtxSysTimerEnable, \ref osRtxSysTimerDisable, and optionally the function
1348   \ref osRtxSysTimerAckIRQ.
1349 - If you try to find a \b runtime \b error, use the function \ref osRtxErrorNotify to debug the error.
1350
1351 RTX5 interfaces to the <a href="http://www.keil.com/pack/doc/compiler/EventRecorder/html/index.html" target="_blank"><b>Event Recorder</b></a> 
1352 to provide event information which helps you to understand and analyze the operation. Refer to \ref rtx_evr for more
1353 information.
1354
1355
1356 @{
1357 */
1358
1359 /**
1360 \defgroup rtx5_specific_defines Macros
1361 \brief RTX5 macros
1362 \details
1363 @{
1364 */
1365
1366 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1367 /**
1368 \def osRtxThreadCbSize
1369 */
1370
1371 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1372 /**
1373 \def osRtxTimerCbSize       
1374 */
1375
1376 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1377 /**
1378 \def osRtxEventFlagsCbSize  
1379 */
1380
1381 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1382 /**
1383 \def osRtxMutexCbSize       
1384 */
1385
1386 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1387 /**
1388 \def osRtxSemaphoreCbSize   
1389 */
1390
1391 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1392 /**
1393 \def osRtxMemoryPoolCbSize  
1394 */
1395
1396 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1397 /**
1398 \def osRtxMessageQueueCbSize
1399 */
1400
1401 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1402 /**
1403 \def osRtxMemoryPoolMemSize
1404 */
1405
1406 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1407 /**
1408 \def osRtxMessageQueueMemSize
1409 */
1410
1411 /**
1412 @}
1413 */
1414
1415 /**
1416 \defgroup rtx5_specific_structs Structs
1417 \brief RTX5 structs 
1418 \details
1419 @{
1420 */
1421
1422 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1423 /**
1424 \struct osRtxThread_t
1425 */
1426
1427 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1428 /**
1429 \struct osRtxTimerFinfo_t
1430 */
1431
1432 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1433 /**
1434 \struct osRtxTimer_t
1435 */
1436
1437 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1438 /**
1439 \struct osRtxEventFlags_t
1440 */
1441
1442 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1443 /**
1444 \struct osRtxMutex_t
1445 */
1446
1447 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1448 /**
1449 \struct osRtxSemaphore_t
1450 */
1451
1452 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1453 /**
1454 \struct osRtxMemoryPool_t
1455 */
1456
1457 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1458 /**
1459 \struct osRtxMessageQueue_t
1460 */
1461
1462 /**
1463 @}
1464 */
1465
1466 /**
1467 \defgroup rtx5_specific_functions Functions
1468 \brief RTX5 functions 
1469 \details
1470 @{
1471 */
1472
1473 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1474 /** 
1475 \fn uint32_t osRtxErrorNotify (uint32_t code, void *object_id);
1476 \details
1477 Some system error conditions can be detected during runtime. If the RTX kernel detects a runtime error, it calls the runtime
1478 error function \b osRtxErrorNotify for an object specified by parameter \a object_id.
1479
1480 The parameter \a code passes the actual error code to this function:
1481 | Error Code                   | Description                                                                       |
1482 |------------------------------|-----------------------------------------------------------------------------------|
1483 | osRtxErrorStackUnderflow     | Stack underflow detected for thread (thread_id=object_id)                         |
1484 | osRtxErrorISRQueueOverflow   | ISR Queue overflow detected when inserting object (object_id)                     |
1485 | osRtxErrorTimerQueueOverflow | User Timer Callback Queue overflow detected for timer (timer_id=object_id)        |
1486 | osRtxErrorClibSpace          | Standard C/C++ library libspace not available: increase \c OS_THREAD_LIBSPACE_NUM |
1487 | osRtxErrorClibMutex          | Standard C/C++ library mutex initialization failed                                |
1488
1489 The function \b osRtxErrorNotify must contain an infinite loop to prevent further program execution. You can use an emulator
1490 to step over the infinite loop and trace into the code introducing a runtime error. For the overflow errors this means you
1491 need to increase the size of the object causing an overflow.
1492
1493 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1494
1495 <b>Code Example</b>
1496 \code
1497 #include "rtx_os.h"
1498  
1499 uint32_t osRtxErrorNotify (uint32_t code, void *object_id) {
1500   (void)object_id;
1501  
1502   switch (code) {
1503     case osRtxErrorStackUnderflow:
1504       // Stack underflow detected for thread (thread_id=object_id)
1505       break;
1506     case osRtxErrorISRQueueOverflow:
1507       // ISR Queue overflow detected when inserting object (object_id)
1508       break;
1509     case osRtxErrorTimerQueueOverflow:
1510       // User Timer Callback Queue overflow detected for timer (timer_id=object_id)
1511       break;
1512     case osRtxErrorClibSpace:
1513       // Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
1514       break;
1515     case osRtxErrorClibMutex:
1516       // Standard C/C++ library mutex initialization failed
1517       break;
1518     default:
1519       break;
1520   }
1521   for (;;) {}
1522 //return 0U;
1523 }
1524 \endcode
1525 */
1526
1527 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1528 osRtxErrorClibMutex         /** 
1529 \fn void osRtxIdleThread (void *argument);
1530 \details
1531 The function \b osRtxIdleThread is executed by the RTX kernel, when no other threads are ready to run. By default, this
1532 thread is an empty end-less loop that does nothing. It only waits until another task becomes ready to run. You may change the
1533 code of the \b osRtxIdleThread function to put the CPU into a power-saving or idle mode.
1534
1535 The default stack size for this thread is defined in the file RTX_Config.h. Refer to \ref threadConfig.
1536
1537 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1538
1539 <b>Code Example</b>
1540 \code
1541 #include "rtx_os.h"
1542  
1543 __NO_RETURN void osRtxIdleThread (void *argument) {
1544   (void)argument;
1545
1546   for (;;) {}
1547 }
1548 \endcode
1549 */ 
1550
1551 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1552 /** 
1553 \fn int32_t osRtxSysTimerSetup (void);
1554 \details
1555 By default, RTX5 uses the Cortex-M SysTick timer, but using \b osRtxSysTimerSetup allows to set up an alternative system
1556 timer. 
1557
1558 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1559 */ 
1560
1561 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1562 /** 
1563 \fn void osRtxSysTimerEnable (void);
1564 \details
1565 The function \b osRtxSysTimerEnable enables the alternative system timer that has been set up using \ref osRtxSysTimerSetup.
1566
1567 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1568 */ 
1569
1570 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1571 /** 
1572 \fn void osRtxSysTimerDisable (void);
1573 \details
1574 The function \b osRtxSysTimerDisable disables the alternative system timer that has been set up using \ref osRtxSysTimerSetup.
1575
1576 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1577 */ 
1578
1579 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1580 /** 
1581 \fn void osRtxSysTimerAckIRQ (void);
1582 \details
1583
1584 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1585 */ 
1586
1587 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1588 /** 
1589 \fn uint32_t osRtxSysTimerGetCount (void);
1590 \details
1591 The function \b osRtxSysTimerGetCount returns the system timer count of the alternative timer set up by
1592 \ref osRtxSysTimerSetup.
1593
1594 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1595 */ 
1596
1597 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1598 /** 
1599 \fn uint32_t osRtxSysTimerGetFreq (void);
1600 \details
1601 The function \b osRtxSysTimerGetFreq returns the system timer frequency of the alternative timer set up by
1602 \ref osRtxSysTimerSetup.
1603
1604 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
1605 */
1606
1607 /**
1608 @}
1609 */
1610
1611 /// @}