diff options
| author | robert-hh <robert@hammelrath.com> | 2024-06-07 09:22:46 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-08-20 12:06:25 +1000 |
| commit | 87adf11dd282fb5b121427ef5bdf133c2dfdfdac (patch) | |
| tree | 20046d8a21c1563d1e91b50098177461471e856f | |
| parent | 36108a41d0d397fdbfcda060a05f0fa8e206aa96 (diff) | |
mimxrt/machine_pin: Clear IRQ flag when enabling or disabling IRQ.
Preventing already pending IRQs to fire when not expected.
Signed-off-by: robert-hh <robert@hammelrath.com>
| -rw-r--r-- | ports/mimxrt/machine_pin.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ports/mimxrt/machine_pin.c b/ports/mimxrt/machine_pin.c index ad4158c6b..4f623214b 100644 --- a/ports/mimxrt/machine_pin.c +++ b/ports/mimxrt/machine_pin.c @@ -407,6 +407,7 @@ static mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_ if (args[ARG_handler].u_obj == mp_const_none) { // remove the IRQ from the table, leave it to gc to free it. GPIO_PortDisableInterrupts(self->gpio, 1U << self->pin); + GPIO_PortClearInterruptFlags(self->gpio, 1U << self->pin); MP_STATE_PORT(machine_pin_irq_objects[index]) = NULL; return mp_const_none; } @@ -445,6 +446,8 @@ static mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_ GPIO_PinSetInterruptConfig(self->gpio, self->pin, irq->trigger); // Enable the specific Pin interrupt GPIO_PortEnableInterrupts(self->gpio, 1U << self->pin); + // Clear previous IRQs + GPIO_PortClearInterruptFlags(self->gpio, 1U << self->pin); // Enable LEVEL1 interrupt again EnableIRQ(irq_num); } |
