CMSIS-RTOS RTX  Version 4.80
CMSIS-RTOS RTX: Real-Time Operating System for Cortex-M processor-based devices
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Create a CMSIS-RTOS RTX Project

Example projects using CMSIS-RTOS RTX are available for various development boards. To make use of these examples, you need to install a Device Family Pack in µVision and use Pack Installer to open a CMSIS-RTOS Blinky project. If you wish to start a CMSIS-RTOS RTX from scratch, follow these steps:

  • Create a new project and select a device.
  • In the Manage Run-Time Environment window that opens, select CMSIS::CORE and CMSIS::RTOS (API)::Keil RTX. If the Validation Output requires other components to be present, try to use the Resolve button:

    manage_rte_output.png
  • Click OK. In the Project window, you will see the files that have been automatically added to you project, such as RTX_Conf_CM.c and the system and startup files:

    project_window.png
  • You can add template files to the project by right-clicking on Source Group 1 and selecting Add New Item to 'Source Group 1'. In the new window, click on User Code Template. On the right-hand side you will see all available template files for CMSIS-RTOS RTX:

    add_item.png
  • Finally, configure RTX to the application's needs using the RTX_Conf_CM.c file.

Define and Reference Object Definitions

With #define osObjectsExternal objects are defined as external symbols. This allows to create a consistent header file that is used throughout a project. If you are using the CMSIS-RTOS 'main' function user code template, such a header file (called osObjects.h) will be added automatically to the project:

Code Example

/*----------------------------------------------------------------------------
osObjects.h: CMSIS-RTOS global object definitions for an application
*----------------------------------------------------------------------------
This header file defines global RTOS objects used throughout a project
#define osObjectsPublic indicates that objects are defined; without that
definition the objects are defined as external symbols.
*--------------------------------------------------------------------------*/
#ifndef __osObjects
#define __osObjects
#if (!defined (osObjectsPublic))
#define osObjectsExternal // define RTOS objects with extern attribute
#endif
#include <cmsis_os.h> // CMSIS RTOS header file
// global 'thread' functions -------------------------------------------------
extern void thread_sample (void const *argument); // function prototype
osThreadDef (thread_sample, osPriorityBelowNormal, 1, 100);
// global 'memory pools' -----------------------------------------------------
osPoolDef(MyPool, 10, long);
#endif // __osObjects

This header file defines all objects when included in a C/C++ source file. When #define osObjectsExternal is present before the header file, the objects are defined as external symbols. A single consistent header file can therefore be used throughout the whole project.

Code Example

#include "osObjects.h" // Definition of the CMSIS-RTOS objects