2017-09-15 01:11 AM
I'm learning how to use an RTOS (FreeRTOS in this case) and I have a couple of questions about its interoperability with HAL. So now I have a project generated by STM32CubeMX v4.22.1 with FreeRTOS selected and some options tuned.
1. The stm32l0xx_hal_conf.h contains a definition '&sharpdefine USE_RTOS 0U', when I change it to 1U HAL fails to compile on this line: '&sharperror 'USE_RTOS should be 0 in the current HAL release''. What does it mean? Is HAL ready to work with an RTOS?
2. For example the default (weakly defined) HAL_Delay function will not work well with FreeRTOS, I think it would be better to redefine it in the generated freertos.c file to use the osDelay function instead of wasting cycles and preventing the RTOS kernel to switch to another task. Or am I wrong?
Edit:
Redefining HAL_Delay isn't very straightforward because all the clocks and peripherals initialization in main.c is done before initializing the RTOS, so osDelay won't work in the beginning.
Edit 2:
It seems internally HAL_Delay is only called in the stm32l0xx_hal_pcd_ex.c module of the HAL (at least in STM32CubeL0), so that's not that much bad.
#freertos+hal2018-04-26 06:20 AM
Forget about changing USE_RTOS as it is just a placeholder and most likely nothing will come out of it.
You may be interested to read my response here
2018-04-26 08:40 AM
I tend to agree.
A RTOS like FreeRTOS would like to use ressources that HAL has already carelessly hijacked.
I don't envy the developers assigned to marry both ...