Skip to content

Commit 9a9e552

Browse files
committed
zephyr/machine_pin: Retry configuring gpio with just GPIO_OUTPUT.
Some targets like frdm_k64f don't support GPIO_OUTPUT|GPIO_INPUT, so just use GPIO_OUTPUT in those cases (it seems they still support reading the current output state even when configured only as GPIO_OUTPUT, unlike other targets which require both settings). Signed-off-by: Damien George <[email protected]>
1 parent bf432a3 commit 9a9e552

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/zephyr/machine_pin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ static mp_obj_t machine_pin_obj_init_helper(machine_pin_obj_t *self, size_t n_ar
116116
}
117117

118118
int ret = gpio_pin_configure(self->port, self->pin, mode | pull | init);
119+
if (ret == -ENOTSUP && mode == (GPIO_OUTPUT | GPIO_INPUT)) {
120+
// Some targets (eg frdm_k64f) don't support GPIO_OUTPUT|GPIO_INPUT, so try again with just GPIO_OUTPUT.
121+
ret = gpio_pin_configure(self->port, self->pin, GPIO_OUTPUT | pull | init);
122+
}
119123
if (ret) {
120124
mp_raise_ValueError(MP_ERROR_TEXT("invalid pin"));
121125
}

0 commit comments

Comments
 (0)