The ports/freertos/ directory contains a generic platform-independent QP/C port to FreeRTOS kernel (version 10). The provided QP port to FreeRTOS has been designed generically to rely exclusively on the existing FreeRTOS API. This means that the port should run without changes on any CPU/compiler platform supported by FreeRTOS.
The QP-FreeRTOS port works as follows:
StaticTask_t
) and requires a private stack space.taskENTER_CRITICAL()
/taskEXIT_CRITICAL()
.taskENTER_CRITICAL_FROM_ISR()
/taskEXIT_CRITICAL_FROM_ISR()
.QACTIVE_POST_FROM_ISR()
, QF_PUBLISH_FROM_ISR()
, etc. These "FromISR" QP APIs must be used inside ISRs instead of the task-level APIs (QACTIVE_POST()
, QF_PUBLISH()
, etc.) and conversely, they cannot be used inside tasks and active objects. Unfortunately, FreeRTOS provides no generic way to enforce the proper API use via assertions.StaticQueue_t
) for active object event queues.vApplicationTickHook()
to periodically invoke the QP clock tick QF_TICK_X_FROM_ISR(). (NOTE: the vApplicationTickHook()
executes in the ISR context and therefore mandates the use of the "FromISR" APIs).The QP port to FreeRTOS comes with examples located in the directory qpc/examples/freertos
. Currently, the examples are provided for the following boards and development toolchains:
The provided examples show how to write regular "kernel-aware" ISRs as well as "kernel-unaware" ISRs for QP/FreeRTOS. (See also the FreeRTOS documentation for configMAX_SYSCALL_INTERRUPT_PRIORITY.
Here is an example of a regular "kernel-aware" ISR (note the use of the FromISR
suffix in the QP APIs):
Here is an example of a "kernel-unaware" ISR (See also the FreeRTOS documentation for configMAX_SYSCALL_INTERRUPT_PRIORITY ):
FreeRTOS provides "hooks" that are user functions that execute in the ISR context (e.g., vApplicationTickHook()
). Such ISR-level functions are closely related to ISRs and should also use exclusively only the "FromISR" APIs. Here is an example of the vApplicationTickHook()
:
As mentioned in the FreeRTOS port summary, the QP port to FreeRTOS uses the static memory allocation of FreeRTOS. This means that all memory for an active object, including the private queue buffer and the private stack for the the associated FreeRTOS task must be allocated by the user. Here is an example code that starts an active object: