From 05cd17e36fbc5d3606e34e430dc72549bd1d6708 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 2 Sep 2021 13:02:49 +1000 Subject: [PATCH] stm32/pin: Enable GPIO clock of pin if it's constructed without init. Fixes issue #7363. Signed-off-by: Damien George --- ports/stm32/pin.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/stm32/pin.c b/ports/stm32/pin.c index f1c5eee850..ad153311e3 100644 --- a/ports/stm32/pin.c +++ b/ports/stm32/pin.c @@ -256,6 +256,9 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, mp_map_t kw_args; mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); pin_obj_init_helper(pin, n_args - 1, args + 1, &kw_args); + } else { + // enable the peripheral clock so pin reading at least works + mp_hal_gpio_clock_enable(pin->gpio); } return MP_OBJ_FROM_PTR(pin);