Skip to content

Commit 779aaed

Browse files
committed
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. (cherry picked from commit 0222b8c)
1 parent cd84ea5 commit 779aaed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cpu/sam0_common/periph/gpio_ll.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,12 @@ gpio_conf_t gpio_ll_query_conf(gpio_port_t port, uint8_t pin)
204204
}
205205
}
206206

207-
result.initial_value = iobus->OUT.reg & pin_mask;
207+
if (result.state == GPIO_INPUT) {
208+
result.initial_value = (gpio_ll_read(port) >> pin) & 1UL;
209+
}
210+
else {
211+
result.initial_value = (gpio_ll_read_output(port) >> pin) & 1UL;
212+
}
208213

209214
return result;
210215
}

0 commit comments

Comments
 (0)