...
The current version of FreeRTOS can be downloaded fromĀ www.freertos.org. For porting, we need the folder <FreeRTOS/Source> and from the portable folder we need to use one of the following port/ portmacro files:
portable | FPU | MPU |
---|---|---|
ARM_CM3 | ||
ARM_CM3_MPU | ||
ARM_CM4FP | ||
ARM_CM4_MPU |
FreeRTOS Config
TBD
Heap
TBDThe FreeRTOSConfig file must be defined according your needs. You can find more information fromĀ
Heap
TBD
FreeRTOSCommonHooks
The following Hook Functions are required:
Code Block | ||||
---|---|---|---|---|
| ||||
/**
* @brief Delay for the specified number of milliSeconds
* @param ms: Delay in milliSeconds
* @return Nothing
* @note Delays the specified number of milliSeoconds using a task delay
*/
void FreeRTOSDelay(uint32_t ms);
/**
* @brief FreeRTOS malloc fail hook
* @return Nothing
* @note This function is alled when a malloc fails to allocate data.
*/
void vApplicationMallocFailedHook(void);
/**
* @brief FreeRTOS remalloc fail hook
* @return Nothing
* @note This function is alled when a malloc fails to allocate data.
*/
void vApplicationReallocFailedHook(void);
/**
* @brief FreeRTOS application idle hook
* @return Nothing
* @note Calls ARM Wait for Interrupt function to idle core
*/
void vApplicationIdleHook(void); |
Code Block | ||||
---|---|---|---|---|
| ||||
/* Delay for the specified number of milliSeconds */
void FreeRTOSDelay(uint32_t ms)
{
portTickType xDelayTime;
xDelayTime = xTaskGetTickCount();
vTaskDelayUntil(&xDelayTime, ms);
}
/*-----------------------------------------------------------*/
/* FreeRTOS malloc fail hook */
void vApplicationMallocFailedHook(void)
{
/* vApplicationMallocFailedHook() will only be called if
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
function that will get called if a call to pvPortMalloc() fails.
pvPortMalloc() is called internally by the kernel whenever a task, queue,
timer or semaphore is created. It is also called by various parts of the
demo application. If heap_1.c or heap_2.c are used, then the size of the
heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
to query the size of free heap space that remains (although it does not
provide information on how the remaining heap might be fragmented). */
taskDISABLE_INTERRUPTS();
for (;; ) {}
}
/*-----------------------------------------------------------*/
/* FreeRTOS malloc fail hook */
void vApplicationReallocFailedHook(void)
{
/* vApplicationMallocFailedHook() will only be called if
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
function that will get called if a call to pvPortMalloc() fails.
pvPortMalloc() is called internally by the kernel whenever a task, queue,
timer or semaphore is created. It is also called by various parts of the
demo application. If heap_1.c or heap_2.c are used, then the size of the
heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
to query the size of free heap space that remains (although it does not
provide information on how the remaining heap might be fragmented). */
taskDISABLE_INTERRUPTS();
for (;; ) {}
}
/*-----------------------------------------------------------*/
/* FreeRTOS application idle hook */
void vApplicationIdleHook(void)
{
/* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle
task. It is essential that code added to this hook function never attempts
to block in any way (for example, call xQueueReceive() with a block time
specified, or call vTaskDelay()). If the application makes use of the
vTaskDelete() API function (as this demo application does) then it is also
important that vApplicationIdleHook() is permitted to return to its calling
function, because it is the responsibility of the idle task to clean up
memory allocated by the kernel to any task that has since been deleted. */
/* Best to sleep here until next systick */
__WFI();
}
/* FreeRTOS stack overflow hook */
void vApplicationStackOverflowHook(xTaskHandle pxTask, char * pcTaskName)
{
(void) pxTask;
(void) pcTaskName;
//DEBUGOUT("DIE:ERROR:FreeRTOS: Stack overflow in task %s\r\n", pcTaskName);
/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS();
for (;; ) {}
}
/* FreeRTOS application tick hook */
void vApplicationTickHook(void)
{
/* This function will be called by each tick interrupt if
configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be
added here, but the tick hook is called from an interrupt context, so
code must not attempt to block, and only the interrupt safe FreeRTOS API
functions can be used (those that end in FromISR()). */
#ifdef DRV_TIM_MODULE_ENABLED
DRVSysTick_Handler();
#endif |
Note that the vApplicationTickHook() calls the netX Driver Systick Handler in case the timer module is enabled!
This is required since the timer implementation of the netX driver might need the systick!