diff options
-rw-r--r-- | cores/arduino/WInterrupts.c | 80 | ||||
-rw-r--r-- | libraries/Wire/utility/twi.c | 2 |
2 files changed, 22 insertions, 60 deletions
diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 7e9f717..cef1106 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -280,75 +280,37 @@ void attachInterruptTwi(void (*userFunc)(void) ) { } */ -#if defined(__AVR_ATmega32U4__) -ISR(INT0_vect) { - intFunc[EXTERNAL_INT_0](); -} - -ISR(INT1_vect) { - intFunc[EXTERNAL_INT_1](); -} - -ISR(INT2_vect) { - intFunc[EXTERNAL_INT_2](); -} +#define IMPLEMENT_ISR(vect, interrupt) \ + ISR(vect) { \ + intFunc[interrupt](); \ + } -ISR(INT3_vect) { - intFunc[EXTERNAL_INT_3](); -} +#if defined(__AVR_ATmega32U4__) -ISR(INT6_vect) { - intFunc[EXTERNAL_INT_4](); -} +IMPLEMENT_ISR(INT0_vect, EXTERNAL_INT_0) +IMPLEMENT_ISR(INT1_vect, EXTERNAL_INT_1) +IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_2) +IMPLEMENT_ISR(INT3_vect, EXTERNAL_INT_3) +IMPLEMENT_ISR(INT6_vect, EXTERNAL_INT_4) #elif defined(EICRA) && defined(EICRB) -ISR(INT0_vect) { - intFunc[EXTERNAL_INT_2](); -} - -ISR(INT1_vect) { - intFunc[EXTERNAL_INT_3](); -} - -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](); -} +IMPLEMENT_ISR(INT0_vect, EXTERNAL_INT_2) +IMPLEMENT_ISR(INT1_vect, EXTERNAL_INT_3) +IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_4) +IMPLEMENT_ISR(INT3_vect, EXTERNAL_INT_5) +IMPLEMENT_ISR(INT4_vect, EXTERNAL_INT_0) +IMPLEMENT_ISR(INT5_vect, EXTERNAL_INT_1) +IMPLEMENT_ISR(INT6_vect, EXTERNAL_INT_6) +IMPLEMENT_ISR(INT7_vect, EXTERNAL_INT_7) #else -ISR(INT0_vect) { - intFunc[EXTERNAL_INT_0](); -} - -ISR(INT1_vect) { - intFunc[EXTERNAL_INT_1](); -} +IMPLEMENT_ISR(INT0_vect, EXTERNAL_INT_0) +IMPLEMENT_ISR(INT1_vect, EXTERNAL_INT_1) #if defined(EICRA) && defined(ISC20) -ISR(INT2_vect) { - intFunc[EXTERNAL_INT_2](); -} +IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_2) #endif #endif diff --git a/libraries/Wire/utility/twi.c b/libraries/Wire/utility/twi.c index 2af0597..7efcc5a 100644 --- a/libraries/Wire/utility/twi.c +++ b/libraries/Wire/utility/twi.c @@ -165,7 +165,7 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen // We need to remove ourselves from the repeated start state before we enable interrupts, // since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning // up. Also, don't enable the START interrupt. There may be one pending from the - // repeated start that we sent outselves, and that would really confuse things. + // repeated start that we sent ourselves, and that would really confuse things. twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR do { TWDR = twi_slarw; |