Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use digitalPinToInterrupt with attachInterrupt and detachInterrupt #18

Closed
per1234 opened this issue Feb 16, 2019 · 1 comment

Comments

@per1234
Copy link
Contributor

per1234 commented Feb 16, 2019

We expect to be able to use the attachInterrupt(digitalPinToInterrupt(pin), ISR, mode) syntax, even when the use of digitalPinToInterrupt is not absolutely necessary due to the interrupts having the same numbering as the pins (e.g. SAMD). This allows code to be written that is portable across architectures.

This is not currently possible with Arduino megaAVR Boards. Arduino megaAVR Boards' attachInterrupt was written to take a pin number as the first parameter, then convert the pin number to interrupt number inside attachInterrupt using digitalPinToInterrupt, breaking from the convention established in Arduino AVR Boards.

To make matters more confusing, the attachInterrupt documentation falsely claims:

For Uno WiFiRev.2, Due, Zero, MKR Family and 101 boards the interrupt number = pin number.

The attachInterrupt documentation also specifically says that the attachInterrupt(pin, ISR, mode) syntax is not recommended.


Originally reported at:
http://forum.arduino.cc/index.php?topic=592249

@facchinm
Copy link
Member

I totally agree with you, the right behaviour is the one you are describing, so the action must be:

  • redefine digitalPinToInterrupt(P) as P
  • rename digitalPinToInterrupt existing macro and call it in the function

This way both attachInterrupt(pin) and attachInterrupt(digitalPinToInterrupt(pin)) behaviours should be fine and consistent with SAMD core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants