FreeRTOS¶
lbuild module: modm:freertos
Amazon FreeRTOS is an open source, real-time operating system (RTOS) for microcontrollers in small, low-power devices.
This module provides the latest FreeRTOS LTS release integrated with modm:
- Chooses the right Cortex-M port for the target.
- Variable tick rate integrated with
modm::Clockviamodm:platform:clock. - Dynamic memory provided by the
modm:platform:heapmodule with thread-safe locking of Newlib'smalloc/free. - Assertions integrated into the
modm:architecture:assertinterface. - Interrupt handling integrated with CMSIS NVIC functions.
Note that we recommend using the FreeRTOS API directly and only if you write
threaded code that also runs on other platforms (x86 simulators for example)
should you consider using the API defined in modm:processing:rtos module.
Configuration¶
This module generates a FreeRTOSConfig.h config file for modm integration with
these settings:
configASSERT(x)implemented withmodm_assert(x, "freertos").configCPU_CLOCK_HZimplemented with CMSISSystemCoreClock.configTICK_RATE_HZset tomodm:freertos:frequencyor 1kHz on Cortex-M0.configSUPPORT_DYNAMIC_ALLOCATION = 1only if used withmodm:platform:heap.configSUPPORT_STATIC_ALLOCATION = 1always.configUSE_TICK_HOOK = 1used bymodm:platform:clockto providemodm::Clock.
In addition we define these overwritable default settings:
-
configMAX_SYSCALL_INTERRUPT_PRIORITY=(__NVIC_PRIO_BITS << (8u - __NVIC_PRIO_BITS)) -
configMINIMAL_STACK_SIZE= 128 configMAX_PRIORITIES= 5configUSE_PREEMPTION= 1configUSE_IDLE_HOOK= 0-
configUSE_16_BIT_TICKS= 0 -
configUSE_MUTEXES= 1 configUSE_RECURSIVE_MUTEXES= 1configUSE_COUNTING_SEMAPHORES= 1configQUEUE_REGISTRY_SIZE= 10configNUM_THREAD_LOCAL_STORAGE_POINTERS= 5-
configCHECK_FOR_STACK_OVERFLOW= 1 -
configUSE_TIMERS= 1 configTIMER_TASK_PRIORITY= 3configTIMER_QUEUE_LENGTH= 10configTIMER_TASK_STACK_DEPTH=configMINIMAL_STACK_SIZE
All other config settings are unchanged by modm and are defaulted by FreeRTOS itself, please refer to the FreeRTOS Config documentation to understand what each of these do.
To change a configuration setting, define a <FreeRTOSConfigLocal.h> file,
which is included before the optional settings, so you can overwrite them
easily.
An example <FreeRTOSConfigLocal.h> file:
// Use a bigger minimal stack size
#define configMINIMAL_STACK_SIZE 256
// Longer timer queue
#define configTIMER_QUEUE_LENGTH 20
This module is only available for rp, sam, stm32.
Options¶
frequency¶
Context switch frequency in Hz
Default: 1000
Inputs: [4 ... 1000]
Dependencies¶
Limited availability: Check with 'lbuild discover' if this module is available for your target!