From cfe606b601d97f02713662e0bc521dc0f5db310b Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 12 Apr 2020 21:06:56 +0200 Subject: [PATCH] cpu/lpc2387: gpio: Don't discriminate between rising & falling pins The `test_irq()` function does not discriminate between rising and falling pins, so there is no need to handle them separately. --- cpu/lpc2387/periph/gpio.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/cpu/lpc2387/periph/gpio.c b/cpu/lpc2387/periph/gpio.c index e8dc68e9e2..6f8463332b 100644 --- a/cpu/lpc2387/periph/gpio.c +++ b/cpu/lpc2387/periph/gpio.c @@ -268,11 +268,10 @@ void gpio_irq_disable(gpio_t dev) _gpio_configure(dev, 0, 0); } -static void test_irq(int port, unsigned long f_mask, unsigned long r_mask) +static void test_irq(int port, unsigned long active_pins) { /* Test each bit of rising and falling masks, if set trigger interrupt * on corresponding device */ - unsigned long active_pins = f_mask | r_mask; while (active_pins) { /* we want the position of the first one bit, so N_bits - (N_leading_zeros + 1) */ @@ -295,24 +294,18 @@ void GPIO_IRQHandler(void) __attribute__((interrupt("IRQ"))); void GPIO_IRQHandler(void) { + unsigned long int_stat; + if (IO_INT_STAT & BIT0) { /* interrupt(s) on PORT0 pending */ - unsigned long int_stat_f = IO0_INT_STAT_F; /* save content */ - unsigned long int_stat_r = IO0_INT_STAT_R; /* save content */ - - IO0_INT_CLR = int_stat_f; /* clear flags of fallen pins */ - IO0_INT_CLR = int_stat_r; /* clear flags of risen pins */ - - test_irq(0, int_stat_f, int_stat_r); + int_stat = IO0_INT_STAT_F | IO0_INT_STAT_R; /* get risen & fallen pin IRQs */ + IO0_INT_CLR = int_stat; /* clear IRQ flags */ + test_irq(0, int_stat); } if (IO_INT_STAT & BIT2) { /* interrupt(s) on PORT2 pending */ - unsigned long int_stat_f = IO2_INT_STAT_F; /* save content */ - unsigned long int_stat_r = IO2_INT_STAT_R; /* save content */ - - IO2_INT_CLR = int_stat_f; /* clear flags of fallen pins */ - IO2_INT_CLR = int_stat_r; /* clear flags of risen pins */ - - test_irq(2, int_stat_f, int_stat_r); + int_stat = IO2_INT_STAT_F | IO2_INT_STAT_R; /* get risen & fallen pin IRQs */ + IO2_INT_CLR = int_stat; /* clear IRQ flags */ + test_irq(2, int_stat); } VICVectAddr = 0; /* Acknowledge Interrupt */