diff options
Diffstat (limited to 'cores/arduino/WInterrupts.c')
-rw-r--r-- | cores/arduino/WInterrupts.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 71dd45c..7e9f717 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -32,7 +32,39 @@ #include "wiring_private.h" -static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS]; +static void nothing(void) { +} + +static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS] = { +#if EXTERNAL_NUM_INTERRUPTS > 8 + #warning There are more than 8 external interrupts. Some callbacks may not be initialized. + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 7 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 6 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 5 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 4 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 3 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 2 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 1 + nothing, +#endif +#if EXTERNAL_NUM_INTERRUPTS > 0 + nothing, +#endif +}; // volatile static voidFuncPtr twiIntFunc; void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { @@ -238,7 +270,7 @@ void detachInterrupt(uint8_t interruptNum) { #endif } - intFunc[interruptNum] = 0; + intFunc[interruptNum] = nothing; } } @@ -250,87 +282,71 @@ void attachInterruptTwi(void (*userFunc)(void) ) { #if defined(__AVR_ATmega32U4__) ISR(INT0_vect) { - if(intFunc[EXTERNAL_INT_0]) - intFunc[EXTERNAL_INT_0](); + intFunc[EXTERNAL_INT_0](); } ISR(INT1_vect) { - if(intFunc[EXTERNAL_INT_1]) - intFunc[EXTERNAL_INT_1](); + intFunc[EXTERNAL_INT_1](); } ISR(INT2_vect) { - if(intFunc[EXTERNAL_INT_2]) - intFunc[EXTERNAL_INT_2](); + intFunc[EXTERNAL_INT_2](); } ISR(INT3_vect) { - if(intFunc[EXTERNAL_INT_3]) - intFunc[EXTERNAL_INT_3](); + intFunc[EXTERNAL_INT_3](); } ISR(INT6_vect) { - if(intFunc[EXTERNAL_INT_4]) - intFunc[EXTERNAL_INT_4](); + intFunc[EXTERNAL_INT_4](); } #elif defined(EICRA) && defined(EICRB) ISR(INT0_vect) { - if(intFunc[EXTERNAL_INT_2]) intFunc[EXTERNAL_INT_2](); } ISR(INT1_vect) { - if(intFunc[EXTERNAL_INT_3]) intFunc[EXTERNAL_INT_3](); } ISR(INT2_vect) { - if(intFunc[EXTERNAL_INT_4]) intFunc[EXTERNAL_INT_4](); } ISR(INT3_vect) { - if(intFunc[EXTERNAL_INT_5]) intFunc[EXTERNAL_INT_5](); } ISR(INT4_vect) { - if(intFunc[EXTERNAL_INT_0]) intFunc[EXTERNAL_INT_0](); } ISR(INT5_vect) { - if(intFunc[EXTERNAL_INT_1]) intFunc[EXTERNAL_INT_1](); } ISR(INT6_vect) { - if(intFunc[EXTERNAL_INT_6]) intFunc[EXTERNAL_INT_6](); } ISR(INT7_vect) { - if(intFunc[EXTERNAL_INT_7]) intFunc[EXTERNAL_INT_7](); } #else ISR(INT0_vect) { - if(intFunc[EXTERNAL_INT_0]) intFunc[EXTERNAL_INT_0](); } ISR(INT1_vect) { - if(intFunc[EXTERNAL_INT_1]) intFunc[EXTERNAL_INT_1](); } #if defined(EICRA) && defined(ISC20) ISR(INT2_vect) { - if(intFunc[EXTERNAL_INT_2]) intFunc[EXTERNAL_INT_2](); } #endif |