From 0222b8c54cda20baec9a95d5357d18eb958efa1f Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 18 Nov 2024 14:27:14 +0100 Subject: [PATCH] cpu/sam0_common/periph_gpio_ll: fix gpio_query_conf() For the other MCUs, we take the input register state instead of the output register state when the pin is configured as input. Let's do the same here, as this is a lot more useful and intuitive. --- cpu/sam0_common/periph/gpio_ll.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cpu/sam0_common/periph/gpio_ll.c b/cpu/sam0_common/periph/gpio_ll.c index a8a7c13713..d375faeda9 100644 --- a/cpu/sam0_common/periph/gpio_ll.c +++ b/cpu/sam0_common/periph/gpio_ll.c @@ -204,7 +204,12 @@ gpio_conf_t gpio_ll_query_conf(gpio_port_t port, uint8_t pin) } } - result.initial_value = iobus->OUT.reg & pin_mask; + if (result.state == GPIO_INPUT) { + result.initial_value = (gpio_ll_read(port) >> pin) & 1UL; + } + else { + result.initial_value = (gpio_ll_read_output(port) >> pin) & 1UL; + } return result; }