diff --git a/lib/card10/portexpander.c b/lib/card10/portexpander.c index c1406ea436a2dcf236ef652ce9d7ea134353d72f..e84c259f786ce648e75553f0353412fabf35bca5 100644 --- a/lib/card10/portexpander.c +++ b/lib/card10/portexpander.c @@ -123,6 +123,12 @@ int portexpander_init(void) GPIO_IntEnable(&pe_int_pin); NVIC_EnableIRQ((IRQn_Type)MXC_GPIO_GET_IRQ(pe_int_pin.port)); + // Unmask portexpander interrupts + portexpander_int_enable(PE_INPUT_MASK); + + // Clear existing interrupts + portexpander_in_get(0); + return E_SUCCESS; } @@ -304,6 +310,8 @@ int portexpander_register_callback( /* ************************************************************************** */ __attribute__((weak)) void portexpander_interrupt_callback(void *_) { + GPIO_IntDisable(&pe_int_pin); + GPIO_IntClr(&pe_int_pin); interrupt_pending = true; } @@ -317,6 +325,8 @@ void portexpander_poll() // Port read resets interrupts uint8_t port_levels = portexpander_in_get(0xFF); + GPIO_IntEnable(&pe_int_pin); + for (uint8_t pin = 0; pin < 8; ++pin) { if ((caused_by & (1 << pin)) && callbacks[pin]) { gpio_int_pol_t edge_type =