2021-08-11 05:56 AM
I'm developing production code for an STM32 project and using the Device Configuration Tool as much as possible. I need to organize the code so that everything is not in main.c.
Is there a way, for example, to move FreeRTOS tasks out of main into their own files so that they don't get regenerated back in main when I change something with the Device Config. Tool?
2021-08-11 07:10 AM
2021-08-11 07:27 AM
Thanks, Ethan.
That helps a lot. The big issue now is that the FreeRTOS tasks are all in the same file. At least the Start functions are. I can leave the start functions there and move my code out to individual files and make calls so that nothing gets broken when I do a configuration update.
2021-08-12 02:18 AM
It seems to me making task function as weak (shown in the attached picture) may be what you need. After making task function as weak, you could add implementation of the same task function (without compiling error) in the file you want:
// The weak implementation is done by CubeMX in freertos.c
__weak void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN StartDefaultTask */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END StartDefaultTask */
}
// Your implementation in the source file you want:
void StartDefaultTask(void const * argument)
{
for(;;)
{
...
}
}
2021-08-12 05:48 AM
That would work, too.
I'm just going to replace the bodies of StartXTask() with calls to functions in my files. I'll have a source file for each task.