I'm learning to use STM32 microcontrollers using CubeMX to generate a project. I've noticed that CubeMX generates two basic stages of initialization for nearly every peripheral:
(A) Within the
stm32fxxxx_hap_msp.c file, it defines a number of callbacks of the form
main.c, it defines a number of functions of the form
Sometimes a given peripheral's
HAL_XYZ_Init() function is called from within (A) as it is with the ADC and RTC. Other times a given peripheral's
HAL_XYZ_Init() function is called from within (B) as it is done with GPIO.
Both sets of functions call
__HAL_RCC_xxxx macros extensively.
I can't make heads or tails of the usage pattern and neither the HAL guide nor reference manual give much direction here.
I suspect that the callback format provided by (A) has something to do with the uC waking from low-power modes, but I am not positive about this. Is this correct, or what is the purpose of the
I noticed that (A) contains more user-definition block comments indicating room for my code to cohabit the functions generated by CubeMX. But why, for instance, would it be wrong to move code from (B) into the space of (A) in order to keep my initialization sequence clear and easy to read?