niekiran / MasteringMCU

Udemy Mastering Microcontroller Course Repository
392 stars 374 forks source link

stm32f407xx_gpio_driver.c -> GPIO_Init Suggestion #5

Closed Frimi closed 4 years ago

Frimi commented 4 years ago

In my microcontroller the pins are started by default as an analog mode (to save energy), so it would be interesting to ensure that the pin is configured as an input before starting the interrupt configuration process.

Just by adding this line:

//Configure GPIO as input pGPIOHandle->pGPIOx->MODER &= ~( 0x3 << (2 * pGPIOHandle->GPIO_PinConfig.GPIO_PinNumber));