3 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5 \page os2MigrationGuide RTX Migration Guide
7 RTX5 supplies both API layers: CMSIS-RTOS v1 and CMSIS-RTOS v2. This allows a gradient transition from version 1 to 2.
8 Depending on the phase a project is in its life cycly a level of migration is chosen.
10 - The first level of migration is to migrate to RTX5 without changing the API level.
11 - The second level in the transition is to use Version 2 API functions and Version 1 API functions in mixed variation.
12 - The third level is non-trivial and requires some additional development effort to migrate all API Version 1 calls to Version 2.
14 \section MigL1 Level 1 Migration - Upgrade to RTX5 on API v1
16 The Upgrade to RTX Version 5 from any version 4.x is simple using the API v1 compatibility layer. To configure this in an existing project the following steps are required:
18 \image html "RTX5_Migrate1.PNG" "Component Selection for RTX5"
20 -# Open Manage Run-Time Environment window:
21 -# Expand CMSIS Software Component.
22 -# Expand RTOS (API) and deselect Keil RTX.
23 -# Select Keil RTX5 from the RTOS (API) group.
24 -# Resolve the missing components.
26 -# Expand CMSIS group in the Project window:
27 -# Open RTX_Config.c and adapt configuration to suit the application including:
28 - System Configuration->Global Dynamic Memory size
29 - Kernel Tick Frequency
30 - Thread Configuration->Default Thread Stack size
31 - Details are found in \ref config_rtx
32 -# Rename function int \b main (void) to void \b app_main (void *arg).
33 Create new function int main (void) which implements at least:
34 - System initialization and configuration
35 - Update SystemCoreClock
36 - Initialize CMSIS-RTOS kernel
37 - Creates new thread app_main
38 - Start RTOS scheduler
40 <b>Example - Application Main Thread</b>
42 /* Renamed main() function */
43 void app_main (void *arg) {
51 /* New main function to start app_main */
55 // System Initialization
56 SystemCoreClockUpdate();
58 osKernelInitialize(); // Initialize CMSIS-RTOS
59 osThreadNew(app_main, NULL, NULL); // Create application main thread
60 if (osKernelGetState() == osKernelReady) {
61 osKernelStart(); // Start thread execution
67 \note In RTOS API v1 all timings were specified in milliseconds. RTX5 defines all times in kernel ticks.
68 To match both it is recommended to set the Kernel Tick Frequency to 1000Hz in the \ref SystemConfig.
70 To validate the correct operation of your RTOS after migration you can temporarily integrate the \ref rtosValidation component into your project.
72 \section MigL2 Level 2 Migration - Use API v2 and v1 alongside in RTX5
74 Implementing new features in your project is ideally done using the new API. Both API versions are offered in RTX5 and can exist along-side.
76 The component selection is identical to Migration Level 1.
78 Include "cmsis_os2.h" in all modules where access to API v2 functions is required.
81 #include "cmsis_os.h" // ARM::CMSIS:RTOS:Keil RTX5
82 #include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5
85 The following snippet shows how threads - created with both API versions - live along-side:
88 /*----------------------------------------------------------------------------
89 * Thread 4 'phaseD': Phase D output - API v2 thread
90 *---------------------------------------------------------------------------*/
91 void phaseD (void *argument) {
93 osThreadFlagsWait(0x0001, osFlagsWaitAny, osWaitForever); /* wait for an event flag 0x0001 */
95 signal_func(tid_phaseA); /* call common signal function */
100 /*----------------------------------------------------------------------------
101 * Thread 5 'clock': Signal Clock - API v1 thread
102 *---------------------------------------------------------------------------*/
103 void clock (void const *argument) {
105 osSignalWait(0x0100, osWaitForever); /* Wait for event send by API v2 function osThreadFlagsSet() */
107 osDelay(80); /* delay ticks */
112 /* Define the API v1 thread */
113 osThreadDef(clock, osPriorityNormal, 1, 0);
115 /*----------------------------------------------------------------------------
116 * Main: Initialize and start RTX Kernel
117 *---------------------------------------------------------------------------*/
118 void app_main (void *argument) {
121 /* Create the API v2 thread */
122 tid_phaseD = osThreadNew(phaseD, NULL, NULL);
123 /* Create the API v1 thread */
124 tid_clock = osThreadCreate(osThread(clock), NULL);
126 osThreadFlagsSet(tid_phaseA, 0x0001); /* set signal to phaseA thread */
128 osDelay(osWaitForever);
133 The full example "RTX5 Migration" is part of the CMSIS5 pack and available from the pack installer.
135 \section MigL3 Level 3 Migration - Full transition to API v2
136 Migrating fully to APIv2 reduces the overhead of the translation layer and simplifies the project.
137 There is some effort to replace and re-test all API Version 1 calls.
138 The following steps are recommended as a rough guide-line:
139 -# Open Manage Run-Time Environment window:
140 -# Expand CMSIS Software Component:
141 -# Expand RTOS (API) Software Component and de-select Keil RTX5
143 -# Remove all occurances of
145 #include "cmsis_os.h"
147 -# Identify all references to the API v1 and replace with the appropriate calls in v2. You might want to use the Error List window in uVision to identify the related code passages quickly.
149 \note See \ref os2MigrationFunctions for details in differences.
151 Generally there are now longer os*Def macros to declare OS objects.
153 \note Signal Events have been replaced. Use the functions listed under Thread Flags and Event Flags instead.
154 \note The Mail Queue RTOS v1 functions have been deprecated. Use the functionality of the Message Queue instead. Differences are listed under \ref mig_msgQueue.
157 \todo Kernel Ticks needs to be added to SystemConfig documentation