drivers: gpio: rpi_pico: fix call to gpio_set_dir

Ensure gpio_set_dir() receives GPIO_IN or GPIO_OUT by mapping
INIT_{LOW,HIGH} flags explicitly, instead of passing raw bitmasks.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2025-06-09 21:38:14 +02:00 committed by Dan Kalowsky
commit 67b4055d57

View file

@ -161,11 +161,13 @@ static int gpio_rpi_configure(const struct device *dev,
if (flags & GPIO_LINE_OPEN_DRAIN) {
data->open_drain_mask |= BIT(pin);
gpio_put(pin + offset, 0);
gpio_set_dir(pin + offset, flags & GPIO_OUTPUT_INIT_LOW);
gpio_set_dir(pin + offset,
(flags & GPIO_OUTPUT_INIT_LOW) ? GPIO_OUT : GPIO_IN);
} else {
data->open_drain_mask &= ~(BIT(pin));
gpio_put(pin + offset, 1);
gpio_set_dir(pin + offset, flags & GPIO_OUTPUT_INIT_HIGH);
gpio_set_dir(pin + offset,
(flags & GPIO_OUTPUT_INIT_HIGH) ? GPIO_OUT : GPIO_IN);
}
} else {
data->single_ended_mask &= ~(BIT(pin));