Skip to content

Commit

Permalink
cpu/qn908x: Fix triggering GPIO IRQ.
Browse files Browse the repository at this point in the history
The IRQ for each GPIO port needs to be enabled in the NVIC on top of
enabling the corresponding bit in the GPIO port.

This was not caught in tests before because I was testing with a larger
stack of commits (including UART and timers) which also had this fix.

Manually poking the GPIOs while using tests/periph_gpio now properly
fires the interrupts.
  • Loading branch information
iosabi committed Dec 5, 2020
1 parent f72e98d commit eb15254
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpu/qn908x/periph/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
/* Bit mask indicating if a GPIO is set to open_drain. */
static uint32_t gpio_open_drain[GPIO_PORTS_NUMOF] = {};

/* The IRQ numbers in the NVIC for each GPIO port. */
static const uint32_t gpio_nvic_irqs[GPIO_PORTS_NUMOF] = GPIO_IRQS;

int gpio_init(gpio_t pin, gpio_mode_t mode)
{
GPIO_Type *const base = GPIO_T_ADDR(pin);
Expand Down Expand Up @@ -168,6 +171,7 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,

void gpio_irq_enable(gpio_t pin)
{
NVIC_EnableIRQ(gpio_nvic_irqs[GPIO_T_PORT(pin)]);
GPIO_T_ADDR(pin)->INTENSET = 1u << GPIO_T_PIN(pin);
}

Expand Down

0 comments on commit eb15254

Please sign in to comment.