Disable and clearing pending GPIO interrupt

Hi,

In my app I want to (for a moment) disable external interrupt for GPIO pin and also clear eventual pending interrupt on it. And in a little moment I want to reenable this interrupt.

Now I enable the irq like that: gpio_pin_interrupt_configure_dt(&btn, GPIO_INT_EDGE_BOTH) 

1) How to disable this interrupt?

2) How to clear pending interrupt (I want to do it before I reenable it)?

Thank you very much.

Jan.

  • Hi Jan,

    1) How to disable this interrupt?

    You can call gpio_pin_interrupt_configure_dt(&btn, GPIO_INT_DISABLE) 

    2) How to clear pending interrupt (I want to do it before I reenable it)?

    After you disable interrupt, there should be no new ones to worry about.
    I can imagine there are some corner cases where an interrupt already pending when you disable the interrupt will slip through. However I don't know the necessary API to simulate such situations right now.
    Do you need to worry about corner cases like that?

    Best regards,

    Hieu

Related