Skip to content

Commit d7d0e30

Browse files
committed
Support 3rd external interrupt on ATmega1284P (maniacbug)
http://code.google.com/p/arduino/issues/detail?id=728
1 parent 0d70c72 commit d7d0e30

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

hardware/arduino/cores/arduino/WInterrupts.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
110110
#warning attachInterrupt may need some more work for this cpu (case 1)
111111
#endif
112112
break;
113+
114+
case 2:
115+
#if defined(EICRA) && defined(ISC20) && defined(ISC21) && defined(EIMSK)
116+
EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
117+
EIMSK |= (1 << INT2);
118+
#elif defined(MCUCR) && defined(ISC20) && defined(ISC21) && defined(GICR)
119+
MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
120+
GICR |= (1 << INT2);
121+
#elif defined(MCUCR) && defined(ISC20) && defined(GIMSK) && defined(GIMSK)
122+
MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
123+
GIMSK |= (1 << INT2);
124+
#else
125+
#warning attachInterrupt may need some more work for this cpu (case 1)
126+
#endif
127+
break;
113128
#endif
114129
}
115130
}
@@ -237,6 +252,13 @@ SIGNAL(INT1_vect) {
237252
intFunc[EXTERNAL_INT_1]();
238253
}
239254

255+
#if defined(EICRA) && defined(ISC20)
256+
SIGNAL(INT2_vect) {
257+
if(intFunc[EXTERNAL_INT_2])
258+
intFunc[EXTERNAL_INT_2]();
259+
}
260+
#endif
261+
240262
#endif
241263

242264
/*

hardware/arduino/cores/arduino/wiring_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ extern "C"{
5454

5555
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
5656
#define EXTERNAL_NUM_INTERRUPTS 8
57+
#elif defined(__AVR_ATmega1284P__)
58+
#define EXTERNAL_NUM_INTERRUPTS 3
5759
#else
5860
#define EXTERNAL_NUM_INTERRUPTS 2
5961
#endif

0 commit comments

Comments
 (0)