diff options
-rw-r--r-- | chip/stm32/gpio.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chip/stm32/gpio.c b/chip/stm32/gpio.c index fe79ca5aad..bb45f0e388 100644 --- a/chip/stm32/gpio.c +++ b/chip/stm32/gpio.c @@ -23,6 +23,7 @@ static uint8_t exti_events[16]; void gpio_pre_init(void) { const struct gpio_info *g = gpio_list; + const struct unused_pin_info *u = unused_pin_list; int is_warm = system_is_reboot_warm(); int i; @@ -59,6 +60,19 @@ void gpio_pre_init(void) /* Set up GPIO based on flags */ gpio_set_flags_by_mask(g->port, g->mask, flags); } + + /* Configure optional unused pins for low power optimization. */ + for (i = 0; i < unused_pin_count; i++, u++) { + /* + * Configure unused pins as ANALOG INPUT to save power. + * For more info, please see + * "USING STM32F4 MCU POWER MODES WITH BEST DYNAMIC EFFICIENCY" + * ("AN4365") section 1.2.6 and section 7.3.12 of the STM32F412 + * reference manual. + */ + if (IS_ENABLED(CHIP_FAMILY_STM32F4)) + gpio_set_flags_by_mask(u->port, u->mask, GPIO_ANALOG); + } } test_mockable int gpio_get_level(enum gpio_signal signal) |