2023-03-29 04:00 AM
Hello,
I want to know if there is a way to set the GPIO output level for an output at runtime before it will be initialized by the CubeMX generated MX_GPIO_Init() function?
In other words: The MX_GPIO_Init() function writes the in CubeMX configured value to a GPIO output before intializing it:
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(***_GPIO_Port, ***_Pin, GPIO_PIN_SET);
Can I somehow get CubeMX to insert a variable name/value instead of the define 'GPIO_PIN_SET' which would allow me to change the value before calling the MX_GPIO_Init() function?
My intention is to decide at runtime if this pin should be initialized to high or low. I could copy&paste the generated MX_GPIO_Init() and adapt it to my needs, but then I am not in sync with the CubeMX project anymore. Also changing the pin value after the initialization is not an option for me because I don't want a wrong value at the pin.
Thanks,
Jens
Edit: Tried to clarify the 'runtime' aspect of the question.
2023-03-29 04:15 AM
Hello @Jens_ ,
Open STM32CubeMX, Configure and select I / O :
(1).GPIO output level (pin initial level setting)
(2) . GPIO mode (GPIO output mode)
(3) . GPIO pull up / pull down
(4) . maximum output speed (pin speed setting)
(5) . user label
Hope I helped you!
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-03-29 04:21 AM
Hello Foued,
this looks like the normal workflow with a constant definition. This does not work for me.
I want to decide at runtime before initialization if the pin shall be high or low.
Best Regards,
Jens