From 57f4cabff93a11e27c61ecb181664e0d70c7ced1 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 8 Jul 2024 16:22:56 +0100 Subject: [PATCH] rp2/machine_pin: Generalise gpio_irq handler for pins >32. Fix the gpio_irq function so that it looks at all six iobank0_hw->intr[n] registers, for up to 48 IOs. Signed-off-by: Phil Howard --- ports/rp2/machine_pin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/rp2/machine_pin.c b/ports/rp2/machine_pin.c index 8fdde114b..8ba0b44a6 100644 --- a/ports/rp2/machine_pin.c +++ b/ports/rp2/machine_pin.c @@ -86,6 +86,7 @@ typedef struct _machine_pin_irq_obj_t { } machine_pin_irq_obj_t; static const mp_irq_methods_t machine_pin_irq_methods; +static const int num_intr_regs = sizeof(iobank0_hw->intr) / sizeof(iobank0_hw->intr[0]); // Mask with "1" indicating that the corresponding pin is in simulated open-drain mode. uint64_t machine_pin_open_drain_mask; @@ -99,7 +100,7 @@ static inline bool is_ext_pin(__unused const machine_pin_obj_t *self) { #endif static void gpio_irq(void) { - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < num_intr_regs; ++i) { uint32_t intr = iobank0_hw->intr[i]; if (intr) { for (int j = 0; j < 8; ++j) {