freertos-mcpp is a C++ wrapper library that allows developers to use the ubiquitous FreeRTOS kernel while simplifying its use by a new API that closely follows the C++ standard classes.
- No virtual classes, the wrapper classes accurately encapsulate the underlying data structures
- Promotes static allocation, optimizing RAM use and reducing heap fragmentation risks
- Public API closely matches the standard C++ thread support library
- The API selects the threading or interrupt service routine (xFromISR) FreeRTOS API calls by detecting ISR context
- C++11 and above
- ESP-IDF platform supported (simply add it to
EXTRA_COMPONENT_DIRS, or submodule it into{project}/components) - MCUXpresso SDK supported (as a west module, drop-in, see mcux/Kconfig)
In general the library adheres to the FreeRTOS configuration flags,
so there's little integration work needed.
Certain features and functionality require specific configurations for FreeRTOSConfig.h,
see below:
// required globally#defineconfigSUPPORT_STATIC_ALLOCATION 1
// optional, to allow termination of threads and automatic resource freeing (see thread documentation)// NOTE: statically allocated threads are still not allowed to return!#defineconfigSUPPORT_DYNAMIC_ALLOCATION 1
externvoidvTaskExitHandler(void);
#defineconfigTASK_RETURN_ADDRESS vTaskExitHandler
// optional, for thread termination signalling, used by thread::join// configNUM_THREAD_LOCAL_STORAGE_POINTERS must be higher than configTHREAD_EXIT_CONDITION_INDEX#defineconfigNUM_THREAD_LOCAL_STORAGE_POINTERS 1
#defineconfigTHREAD_EXIT_CONDITION_INDEX 0In addition to the C++ wrappers, there are helper files located in src/helpers for some common use-cases:
tasks_static.cis required as source to support static allocation of kernel objectsruntime_stats_timer.cis a zero-cost runtime statistics timer for Cortex Mx architecturesmalloc_free.candnew_delete_ops.cppredirect heap allocation to FreeRTOS's heap management