How to partially configure GPIO using HAL and CubeMX?
Hi,
I want to partially configure GPIO's using HAL and CubeMX. In my simple case, I just want to enable/disable the pull-up resistors while running a program.
At first I looked up, how the pins get initialized by CubeMX:
There's this structure, which you have to fill using all parameters.
typedef struct
{
uint32_t Pin; // Specifies the GPIO pins to be configured.
uint32_t Mode; // Specifies the operating mode for the selected pins.
uint32_t Pull; // Specifies the Pull-up or Pull-Down activation for the selected pins.
uint32_t Speed; // Specifies the speed for the selected pins.
uint32_t Alternate; // Peripheral to be connected to the selected pins
}GPIO_InitTypeDef;=> I could use that, if I would be able to get the parameters I selected in CubeMX, but there's no such function as "void HAL_GPIO_Get_Config(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_InitTypeDef *GPIO_Init)"...
The next thing I heard of is the LL (low level) driver (https://community.st.com/s/question/0D50X00009Xkf0P/partially-configure-gpio-using-hal). It has a seperate function for setting the pull-up/pull-down seperatly:
void LL_GPIO_SetPinPull (GPIO_TypeDef * GPIOx, uint32_t Pin, uint32_t Pull);�?That would be perfect, but you can use either HAL or LL ( Got that information here at 6.2: https://www.st.com/content/ccc/resource/technical/document/user_manual/10/c5/1a/43/3a/70/43/7d/DM00104712.pdf/files/DM00104712.pdf/jcr:content/translations/en.DM00104712.pdf). And I don't want to switch to LL just for a single function.
There's also no way to add custom "USER CODE BEGIN/END" sections to the gpio configuration to save the config from CubeMX... (https://community.st.com/s/question/0D50X0000ALxNlmSQF/is-it-possible-to-add-custom-user-code-sections)
Is there any other option than creating constant arrays with the GPIO settings from CubeMX and change them in code whenever I change them in CubeMX? I feel stupid doing this...
Thanks in advance!
