Skip to content

Commit

Permalink
cpu/sam0_common/periph_gpio_ll: fix gpio_query_conf()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maribu committed Nov 18, 2024
1 parent 72d0b2b commit 0222b8c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpu/sam0_common/periph/gpio_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0222b8c

Please sign in to comment.