/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/ /** \mainpage Introduction FreeRTOS is one of the market leading real-time operating systems (RTOS) for embedded microcontrollers. It is professionally developed, strictly quality controlled, robust, supported, free to use in commercial products without a requirement to expose proprietary source code, and has no IP infringement risk. CMSIS-RTOS v2 is a common API for real-time operating systems (RTOS). It provides a standardized programming interface that is portable to many RTOS and enables software components that can work across multiple RTOS systems. It supports the ARMv8-M architecture, dynamic object creation, for multi-core systems, and has a binary compatible interface across ABI compliant compilers. Using this software pack, users can choose between a native FreeRTOS implementation or one that is adhering to the CMSIS-RTOS2 API and using FreeRTOS under the hood. The CMSIS-RTOS2 API enables programmers to create portable application code to be used with different RTOS kernels (for example Keil RTX5). \b Note: FreeRTOS does not support ARM Compiler v6, yet! Please refere to the FreeRTOS Support Archive. This documentation shows you: - how to \ref cre_freertos_proj "create a new microcontroller project" using FreeRTOS from scratch. - Various \ref examples show you the usage of FreeRTOS in native and CMSIS-RTOS2 mode. - the \ref tech_data of this implementation. \section License License The CMSIS-FreeRTOS implementation is provided free of charge by ARM under the FreeRTOS license. \section CMFR_Pack_Content ARM::CMSIS-FreeRTOS Pack The ARM::CMSIS-FreeRTOS pack contains the following: File/Directory |Content :--------------------------|:--------------------------------------------------------------------------------- \b ARM.CMSIS-FreeRTOS.pdsc | Package description file in CMSIS-Pack format. \b License | FreeRTOS license agreement. \b CMSIS | CMSIS-RTOS2 compliant implementation of FreeRTOS. \b Config | FreeRTOS configuration header file. \b Demo | FreeRTOS demo projects. \b Documentation | This documentation. \b DoxyGen | Source of the documentation. \b Source | FreeRTOS source code. \b Utilities | Utilities to build the pack. */ /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/ /** \page cm_revisionHistory Revision History
1.0.0 Initial release
*/ /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/ /** \page cre_freertos_proj Create a FreeRTOS project You can basically choose between two option when creating a FreeRTOS project: -# \ref native_freertos using the FreeRTOS API and kernel. -# \ref cmsis_freertos using the CMSIS-RTOS2 API with an underlying FreeRTOS kernel. \section native_freertos Create a native FreeRTOS project The steps to create a microcontroller application using FreeRTOS are: - Create a new project and select a microcontroller device. - In the Manage Run-Time Environment window, select \::Device:Startup, \::RTOS:CORE and \::RTOS:Config in the \b FreeRTOS variant and an applicable \::RTOS:Heap scheme (for more information on the heap schemes, visit the FreeRTOS documentation): \image html manage_rte_freertos_native.png \n - If the Validation Output requires other components to be present, try to use the \b Resolve button. - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files: \image html project_window_freertos_native.png \subsection native_freertos_config Configure FreeRTOS When you have created the native FreeRTOS project, you can configure the real-time operating system using the \b FreeRTOSConfig.h file. Please refer to the FreeRTOS documentation for more information on the specific settings. \image html freertos_config_h_native.png \subsection native_freertos_er Add Event Recorder Visibility - To use the Event Recorder together with FreeRTOS, add the software components \::Compiler:Event Recorder and \::RTOS:Event Groups to your project. - Add this include: \c \#include \c "EventRecorder.h" - Call EventRecorderInitialize(EventRecordAll, 1); in your application code (ideally in \c main()). - If you are using simulation mode, add an initialization file with the following content: \code MAP 0xE0001000, 0xE0001007 READ WRITE signal void DWT_CYCCNT (void) { while (1) { rwatch(0xE0001004); _WWORD(0xE0001004, states); } } DWT_CYCCNT() \endcode - Build the application code and download it to the debug hardware or run it in simulation. Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event \b Recorder. \section cmsis_freertos Create a CMSIS-FreeRTOS project The steps to create a microcontroller application using CMSIS-FreeRTOS are: - Create a new project and select a microcontroller device. - In the Manage Run-Time Environment window, select \::Device:Startup, \::CMSIS::RTOS2 (API)\::FreeRTOS, \::RTOS:CORE in the \b FreeRTOS variant, \::RTOS:Config in the \b CMSIS \b RTOS2 variant, \::RTOS:Timers, \::RTOS:Event Groups, and an applicable \::RTOS:Heap scheme (for more information on the heap schemes, visit the FreeRTOS documentation): \image html manage_rte_freertos_rtos2.png \n - If the Validation Output requires other components to be present, try to use the \b Resolve button. - Click \b OK. In the \b Project window, you will see the files that have been automatically added to you project, such as \b %FreeRTOSConfig.h, the source code files, as well as the system and startup files: \image html project_window_freertos_rtos2.png \subsection cmsis_freertos_config Configure CMSIS-FreeRTOS When you have created the CMSIS-FreeRTOS project, you can configure the real-time operating system using the \b FreeRTOSConfig.h file. It can be opened using the Configuration Wizard view: \image html freertos_config_h_cmsis_rtos.png The following settings are available: Name | \#define | Description | -------------------------------|------------------------------------|------------------------------------------------------------| Minimal stack size [words] | configMINIMAL_STACK_SIZE | Stack for idle task and default task stack in words. | Total heap size [bytes] | configTOTAL_HEAP_SIZE | Heap memory size in bytes. | Kernel tick frequency [Hz] | configTICK_RATE_HZ | Kernel tick rate in Hz. | Timer task stack depth [words] | configTIMER_TASK_STACK_DEPTH | Stack for timer task in words. | Timer task priority | configTIMER_TASK_PRIORITY | Timer task priority. | Timer queue length | configTIMER_QUEUE_LENGTH | Timer command queue length. | Use time slicing | configUSE_TIME_SLICING | Enable setting to use time slicing. | Idle should yield | configIDLE_SHOULD_YIELD | Control Yield behavior of the idle task. | Check for stack overflow | configCHECK_FOR_STACK_OVERFLOW | Enable or disable stack overflow checking. | Use idle hook | configUSE_IDLE_HOOK | Enable callback function call on each idle task iteration. | Use tick hook | configUSE_TICK_HOOK | Enable callback function call during each tick interrupt. | Use daemon task startup hook | configUSE_DAEMON_TASK_STARTUP_HOOK | Enable callback function call when timer service starts. | Use malloc failed hook | configUSE_MALLOC_FAILED_HOOK | Enable callback function call when out of dynamic memory. | \subsection cmsis_freertos_er Add Event Recorder Visibility - To use the Event Recorder together with FreeRTOS, add the software component \::Compiler:Event Recorder to your project. - Add this include: \c \#include \c "EventRecorder.h" - Call EventRecorderInitialize(EventRecordAll, 1); in your application code (ideally in \c main()). - If you are using simulation mode, add an initialization file with the following content: \code MAP 0xE0001000, 0xE0001007 READ WRITE signal void DWT_CYCCNT (void) { while (1) { rwatch(0xE0001004); _WWORD(0xE0001004, states); } } DWT_CYCCNT() \endcode - Build the application code and download it to the debug hardware or run it in simulation. Once the target application generates event information, it can be viewed in the µVision debugger using the \b Event \b Recorder. */ /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/ /** \page examples Example projects This pack contains two example projects: - \ref examples_native - \ref examples_cmsis The first example shows how to use FreeRTOS standalone, whereas the second example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS. The examples simulate a step-motor driver. Four phase variables are simulating the activation of the four output driver stages. The state changes are shown in the Watch window variable \c g_phases. All four phases are displayed in the Logic Analyzer: \image html blinky_example_simu.png \section examples_native Blinky example using FreeRTOS natively This example shows how to use FreeRTOS natively in a µVision project. This makes your code portable and you can choose to use a different RTOS kernel anytime during development (even only for evaluation purposes). To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the Native FreeRTOS Blinky (uVision Simulator) project on the \b Examples tab. Select the location on your hard drive where you want to copy the project to and press OK. µVision opens. \section examples_cmsis Blinky example using CMSIS-FreeRTOS This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS. This makes your code portable and you can choose to use a different RTOS kernel anytime during development (even only for evaluation purposes). To open the example, go to Pack Installer, select \b ARM in the \b Devices tab, and click on \b Copy next to the CMSIS-RTOS2 FreeRTOS Blinky (uVision Simulator) project on the \b Examples tab. Select the location on your hard drive where you want to copy the project to and press OK. µVision opens. \section examples_cmsis_a9 Blinky example using CMSIS-FreeRTOS running on ARM Cortex-A9 This example shows how to use the CMSIS-RTOS2 API with an underlying FreeRTOS running on an NXP i.MX6 equipped with an ARM Cortex-A9 code. This example only works in DS-MDK, the Eclipse-based development environment from ARM. For information on setting up the target connection, please refer to NXP i.MX 6SoloX SABRE Reference. \note you need to have the i.MX6 device family pack installed to see the example in the \b Examples tab of Pack Installer. To open the example, open the Pack Installer perspective, select \b NXP in the \b Devices tab, and click on \b Copy next to the CMSIS-RTOS2 FreeRTOS Blinky CA9 (MCIMX6SX-SABRE) project on the \b Examples tab. \image html copy_a9_example.png Confirm the default location in the Eclipse Workspace by pressing Copy. \image html copy_a9_example_ws.png Right-click on the project and select \b Build \b Project. Then, right-click on the project and select \b Debug \b As and then \b Debug \b Configurations. The Debug Configurations dialog opens: \image html dbg_conf.png The project is already set up for running from the SDRAM of the i.MX6 SABRE board. Press \b Debug. DS-MDK will switch to the debug perspective. After a successful connection to the target, press \b F8 to run the application. In the \b App \b Console you will see the output of the phases: \image html dbg_output.png */ /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/ /** \page tech_data Technical data and limitations This lists the technical data of CMSIS-FreeRTOS. \section td_limitations Limitations The following list briefly describes the limitations and unsupported features of the CMSIS-RTOS2 wrapper for FreeRTOS: - ARM Compiler v6 is not supported by FreeRTOS, yet. - Static memory allocation will only work if \a all memory (from attributes structure) is provided statically. In order to allocate object memory statically, you need to: - provide the memory for control blocks and stack in the \c osThreadAttr_t structure for threads. - provide the memory for control blocks and message data in the \c osMessageQueueAttr_t structure for memory queues. - provide the memory for control blocks for other objects in the object's attributes structure. - Each timer object requires additional 8 bytes of dynamic memory. - \c osKernelSuspend and \c osKernelResume are not supported. - \c osKernelGetTickCount is limited to a 32-bit return value. - \c osThreadDetach, \c osThreadJoin() and attribute \c osThreadJoinable are not supported (\c osThreadNew returns NULL when osThreadJoinable attribute is specified). - \c osThreadGetStackSize is not implemented. - Event flags are limited to 24 bits. - \c osEventFlagsGetName is not implemented. - \c osEventFlagsWait cannot be called from an ISR. - Priority inherit protocol is used as default mutex behavior (\c osMutexNew creates priority inherit mutex object by default and ignores \c osMutexPrioInherit attribute when specified). - Robust mutex objects are not supported (\c osMutexNew returns NULL when \c osMutexRobust attribute is specified). - \c osMutexGetName is not implemented and always returns NULL. - \c osSemaphoreGetName is not implemented and always returns NULL. - Memory Pool functions are not implemented and will always return with error. - \c osMessageQueueGetName is not implemented and always returns NULL. - \c osMessageQueuePut and \c osMessageQueueGet always ignore message priority. \section td_validation CMSIS-RTOS validation suite results CMSIS provides a validation suite that can be used to test a real-time operating system for compliance to the standard. The test suite has been run successfully on the CMSIS-FreeRTOS implementation with the following exceptions: \b TC_ThreadParam: - Reason: unsupported feature - Test attempts to test \c osThreadJoin and \c osThreadDetach functions for invalid parameter input. These two functions are not implemented. \b TC_ThreadInterrupts: - Reason: unsupported feature - Test attempts to call \c osThreadJoin and \c osThreadDetach from the ISR. These two functions are not implemented. \b TC_EventFlagsInterrupts: - Reason: unsupported feature - Test attempts to call \c osEventFlagsWait from the ISR. Wrapper implementation does not allow function \c osEventFlagsWait to be called from interrupts. \b TC_MutexRobust: - Reason: unsupported feature - Test attempts to create robust mutex. FreeRTOS implementation does not support robust mutexes. \b TC_MutexOwnership: - Reason: unsupported feature - Test attempts to release a mutex from a thread which is not the mutex owner. Test fails, because FreeRTOS implementation does not verify ownership on mutex release. */ /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/ /** \page functionOverview Function Overview \section rtos_api2 CMSIS-RTOS2 API Overview of all CMSIS-RTOS C API v2 functions that are implemented in CMSIS-FreeRTOS. Kernel Information and Control ------------------------------ - \b osKernelGetInfo: supported - \b osKernelGetState: supported - \b osKernelGetSysTimerCount: supported - \b osKernelGetSysTimerFreq: supported - \b osKernelInitialize: supported - \b osKernelLock: supported - \b osKernelUnlock: supported - \b osKernelRestoreLock: supported - \b osKernelResume: \token{not implemented} - \b osKernelStart: supported - \b osKernelSuspend: \token{not implemented} - \b osKernelGetTickCount: limited to 32-bit return value. - \b osKernelGetTickFreq: supported Thread Management ----------------- - \b osThreadDetach: \token{not implemented} - \b osThreadEnumerate: supported - \b osThreadExit: supported - \b osThreadGetCount: supported - \b osThreadGetId: supported - \b osThreadGetName: supported - \b osThreadGetPriority: supported - \b osThreadGetStackSize: \token{not implemented} - \b osThreadGetStackSpace: supported - \b osThreadGetState: supported - \b osThreadJoin: \token{not implemented} - \b osThreadNew: supported - \b osThreadResume: supported - \b osThreadSetPriority: supported - \b osThreadSuspend: supported - \b osThreadTerminate: supported - \b osThreadYield: supported Thread Flags ------------ - \b osThreadFlagsSet: supported - \b osThreadFlagsClear: supported - \b osThreadFlagsGet: supported - \b osThreadFlagsWait: supported Event Flags ----------- All event flags are limited to 24 bits. - \b osEventFlagsGetName: \token{not implemented} - \b osEventFlagsNew: supported - \b osEventFlagsDelete: supported - \b osEventFlagsSet: supported - \b osEventFlagsClear: supported - \b osEventFlagsGet: supported - \b osEventFlagsWait: cannot be called from an ISR. Generic Wait Functions ---------------------- - \b osDelay: supported - \b osDelayUntil: supported Timer Management ---------------- - \b osTimerDelete: supported - \b osTimerGetName: supported - \b osTimerIsRunning: supported - \b osTimerNew: supported - \b osTimerStart: supported - \b osTimerStop: supported Mutex Management ---------------- Priority inherit protocol is used as default mutex behavior (osMutexNew creates priority inherit mutex object by default and ignores osMutexPrioInherit attribute when specified).\n Robust mutex objects are not supported (osMutexNew returns NULL when osMutexRobust attribute is specified). - \b osMutexAcquire: supported - \b osMutexDelete: supported - \b osMutexGetName: \token{not implemented} - \b osMutexGetOwner: supported - \b osMutexNew: supported - \b osMutexRelease: supported Semaphores ---------- - \b osSemaphoreAcquire: supported - \b osSemaphoreDelete: supported - \b osSemaphoreGetCount: supported - \b osSemaphoreGetName: \token{not implemented} - \b osSemaphoreNew: supported - \b osSemaphoreRelease: supported Memory Pool ----------- Memory Pool functions are not implemented and will always return with error. - \b osMemoryPoolAlloc: \token{not implemented} - \b osMemoryPoolDelete: \token{not implemented} - \b osMemoryPoolFree: \token{not implemented} - \b osMemoryPoolGetBlockSize: \token{not implemented} - \b osMemoryPoolGetCapacity: \token{not implemented} - \b osMemoryPoolGetCount: \token{not implemented} - \b osMemoryPoolGetName: \token{not implemented} - \b osMemoryPoolGetSpace: \token{not implemented} - \b osMemoryPoolNew: \token{not implemented} Message Queue ------------- - \b osMessageQueueDelete: supported - \b osMessageQueueGet: ignores message priority. - \b osMessageQueueGetCapacity: supported - \b osMessageQueueGetCount: supported - \b osMessageQueueGetMsgSize: supported - \b osMessageQueueGetName: \token{not implemented} - \b osMessageQueueGetSpace: supported - \b osMessageQueueNew: supported - \b osMessageQueuePut: ignores message priority. - \b osMessageQueueReset: supported */ /* ======================================================================================================================== */ // Group creation for Reference /** \addtogroup freertos_specific CMSIS-FreeRTOS Specifics \brief This section describes CMSIS-FreeRTOS specifics. \details CMSIS-FreeRTOS interfaces to the Event Recorder to provide event information which helps you to understand and analyze the operation. Refer to \ref freertos_evr for more information. */