mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-19 08:52:15 +01:00
Boilerplate compression on ISR declaration
The current code is very verbose and a painful to maintain (Change ISR implementation in 20 different places? No Thanks!). (This was originally part of #4519, but we all agreeded it deserved it's own PR)
This commit is contained in:
parent
36c9419118
commit
0ab9245f41
@ -280,75 +280,37 @@ void attachInterruptTwi(void (*userFunc)(void) ) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define IMPLEMENT_ISR(vect, interrupt) \
|
||||||
|
ISR(vect) { \
|
||||||
|
intFunc[interrupt](); \
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__AVR_ATmega32U4__)
|
#if defined(__AVR_ATmega32U4__)
|
||||||
ISR(INT0_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_0]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT1_vect) {
|
IMPLEMENT_ISR(INT0_vect, EXTERNAL_INT_0)
|
||||||
intFunc[EXTERNAL_INT_1]();
|
IMPLEMENT_ISR(INT1_vect, EXTERNAL_INT_1)
|
||||||
}
|
IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_2)
|
||||||
|
IMPLEMENT_ISR(INT3_vect, EXTERNAL_INT_3)
|
||||||
ISR(INT2_vect) {
|
IMPLEMENT_ISR(INT6_vect, EXTERNAL_INT_4)
|
||||||
intFunc[EXTERNAL_INT_2]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT3_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_3]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT6_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_4]();
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(EICRA) && defined(EICRB)
|
#elif defined(EICRA) && defined(EICRB)
|
||||||
|
|
||||||
ISR(INT0_vect) {
|
IMPLEMENT_ISR(INT0_vect, EXTERNAL_INT_2)
|
||||||
intFunc[EXTERNAL_INT_2]();
|
IMPLEMENT_ISR(INT1_vect, EXTERNAL_INT_3)
|
||||||
}
|
IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_4)
|
||||||
|
IMPLEMENT_ISR(INT3_vect, EXTERNAL_INT_5)
|
||||||
ISR(INT1_vect) {
|
IMPLEMENT_ISR(INT4_vect, EXTERNAL_INT_0)
|
||||||
intFunc[EXTERNAL_INT_3]();
|
IMPLEMENT_ISR(INT5_vect, EXTERNAL_INT_1)
|
||||||
}
|
IMPLEMENT_ISR(INT6_vect, EXTERNAL_INT_6)
|
||||||
|
IMPLEMENT_ISR(INT7_vect, EXTERNAL_INT_7)
|
||||||
ISR(INT2_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_4]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT3_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_5]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT4_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_0]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT5_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_1]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT6_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_6]();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT7_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_7]();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
ISR(INT0_vect) {
|
IMPLEMENT_ISR(INT0_vect, EXTERNAL_INT_0)
|
||||||
intFunc[EXTERNAL_INT_0]();
|
IMPLEMENT_ISR(INT1_vect, EXTERNAL_INT_1)
|
||||||
}
|
|
||||||
|
|
||||||
ISR(INT1_vect) {
|
|
||||||
intFunc[EXTERNAL_INT_1]();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(EICRA) && defined(ISC20)
|
#if defined(EICRA) && defined(ISC20)
|
||||||
ISR(INT2_vect) {
|
IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_2)
|
||||||
intFunc[EXTERNAL_INT_2]();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user