-
Notifications
You must be signed in to change notification settings - Fork 248
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
digitalPinToInterrupt #67
base: master
Are you sure you want to change the base?
Conversation
According to: https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/ "attachInterrupt(pin, ISR, mode) (Not recommended. Additionally, this syntax only works on Arduino SAMD Boards, Uno WiFi Rev2, Due, and 101.)" Instead, it proposes to use: "attachInterrupt(digitalPinToInterrupt(pin), ISR, mode) (recommended)"
Did you test this on any boards? If so, which ones? And which pins did you use during those tests? |
I have only tested it in the Arduino Nano Every |
Does that board define CORE_INT0_PIN, CORE_INT1_PIN, CORE_INT2_PIN, etc? My understanding is Arduino doesn't define this abstraction for any of their boards. If you only test this change on boards which don't define those symbols, well, that means your change is essentially untested. It must be actually tested on boards which define those names. |
It might be helpful to know the pin can be checked to ensure it can be used as an interrupt: uint8_t pin_interrupt = digitalPinToInterrupt(PIN);
if (pin_interrupt == NOT_AN_INTERRUPT) { /* fail here */ } However, // Arduino Uno, Duemilanove, Diecimila, LilyPad, Mini, Fio, etc...
#elif defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328PB__) ||defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__)
#define CORE_NUM_INTERRUPT 2
#define CORE_INT0_PIN 2
#define CORE_INT1_PIN 3 So the switch statement already identifies the proper pin value: case CORE_INT0_PIN:
interruptArgs[0] = state;
attachInterrupt(0, isr0, CHANGE);
break; It is equivalent to attachInterrupt(digitalPinToInterrupt(CORE_INT0_PIN), isr0, CHANGE); or attachInterrupt(digitalPinToInterrupt(pin), isr0, CHANGE); So I'd either: 1) leave it 2) modify
|
any progress on this issue? I've actually stumbled on this PR after I made local changes to |
According to:
https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/
"attachInterrupt(pin, ISR, mode) (Not recommended. Additionally, this syntax only works on Arduino SAMD Boards, Uno WiFi Rev2, Due, and 101.)"
Instead, it proposes to use:
"attachInterrupt(digitalPinToInterrupt(pin), ISR, mode) (recommended)"