Disable interrupt for a given pin

Hi all,

let's say I'm attaching an interrupt to a pin
C++:
attachInterrupt(digitalPinToInterrupt(pin), isr, FALLING);
and I want, in certain conditions, to disable only this interrupt. Is there a way of doing this? Maybe by calling NVIC_DISABLE_IRQ(digitalPinToInterrupt(pin))?

Edit:
Looking at the implementation of attachInterrupt in interrupt.c, I can see that NVIC_ENABLE_IRQ(IRQ_GPIO6789); is called, but it seems that this is valid for ALL pins. So if calling NVIC_DISABLE_IRQ(IRQ_GPIO6789); am I disabling the interrupt for ALL pins?

Thanks,
Luca
 
Last edited:
Try:

Code:
// Remove a previously configured attachInterrupt() function from a pin.
void detachInterrupt(uint8_t pin);
 
So basically, if I have three interrupts on three different pins, I can disable just one of them with detachInterrupt()? Cool!

Is there any other difference between calling detachInterrupt or NVIC_DISABLE_IRQ? Maybe one is faster?
 
Back
Top