Skip to content

Commit ee29ea2

Browse files
kbidanidanieldegrasse
authored andcommitted
drivers: gpio: stm32: Fix gpio_pin_get_config
This commit updates the function to only set output-related flags (GPIO_OUTPUT_INIT_HIGH, GPIO_OUTPUT_INIT_LOW) when the pin is actually configured as output. For input pins, only GPIO_INPUT and other relevant flags are set. Signed-off-by: Khaoula Bidani <[email protected]> (cherry picked from commit e803a10)
1 parent 3d42040 commit ee29ea2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/gpio/gpio_stm32.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ static int gpio_stm32_pincfg_to_flags(struct gpio_stm32_pin pin_cfg,
126126
if (pin_cfg.type == LL_GPIO_OUTPUT_OPENDRAIN) {
127127
flags |= GPIO_OPEN_DRAIN;
128128
}
129+
130+
if (pin_cfg.out_state == 0) {
131+
flags |= GPIO_OUTPUT_INIT_LOW;
132+
} else {
133+
flags |= GPIO_OUTPUT_INIT_HIGH;
134+
}
129135
} else if (pin_cfg.mode == LL_GPIO_MODE_INPUT) {
130136
flags |= GPIO_INPUT;
131137
#ifdef CONFIG_SOC_SERIES_STM32F1X
@@ -142,12 +148,6 @@ static int gpio_stm32_pincfg_to_flags(struct gpio_stm32_pin pin_cfg,
142148
flags |= GPIO_PULL_DOWN;
143149
}
144150

145-
if (pin_cfg.out_state != 0) {
146-
flags |= GPIO_OUTPUT_HIGH;
147-
} else {
148-
flags |= GPIO_OUTPUT_LOW;
149-
}
150-
151151
*out_flags = flags;
152152

153153
return 0;

0 commit comments

Comments
 (0)