Skip to content

Commit 2387046

Browse files
committed
Added support to INT6 on Leonardo.
Fixes arduino#988
1 parent 5e8df5e commit 2387046

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

hardware/arduino/cores/arduino/WInterrupts.c

+21-9
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
5151
// I hate doing this, but the register assignment differs between the 1280/2560
5252
// and the 32U4. Since avrlib defines registers PCMSK1 and PCMSK2 that aren't
5353
// even present on the 32U4 this is the only way to distinguish between them.
54-
case 0:
55-
EICRA = (EICRA & ~((1<<ISC00) | (1<<ISC01))) | (mode << ISC00);
56-
EIMSK |= (1<<INT0);
57-
break;
58-
case 1:
59-
EICRA = (EICRA & ~((1<<ISC10) | (1<<ISC11))) | (mode << ISC10);
60-
EIMSK |= (1<<INT1);
61-
break;
54+
case 0:
55+
EICRA = (EICRA & ~((1<<ISC00) | (1<<ISC01))) | (mode << ISC00);
56+
EIMSK |= (1<<INT0);
57+
break;
58+
case 1:
59+
EICRA = (EICRA & ~((1<<ISC10) | (1<<ISC11))) | (mode << ISC10);
60+
EIMSK |= (1<<INT1);
61+
break;
6262
case 2:
6363
EICRA = (EICRA & ~((1<<ISC20) | (1<<ISC21))) | (mode << ISC20);
6464
EIMSK |= (1<<INT2);
@@ -67,6 +67,10 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
6767
EICRA = (EICRA & ~((1<<ISC30) | (1<<ISC31))) | (mode << ISC30);
6868
EIMSK |= (1<<INT3);
6969
break;
70+
case 4:
71+
EICRB = (EICRB & ~((1<<ISC60) | (1<<ISC61))) | (mode << ISC60);
72+
EIMSK |= (1<<INT6);
73+
break;
7074
#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
7175
case 2:
7276
EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
@@ -166,7 +170,10 @@ void detachInterrupt(uint8_t interruptNum) {
166170
break;
167171
case 3:
168172
EIMSK &= ~(1<<INT3);
169-
break;
173+
break;
174+
case 4:
175+
EIMSK &= ~(1<<INT6);
176+
break;
170177
#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
171178
case 2:
172179
EIMSK &= ~(1 << INT0);
@@ -250,6 +257,11 @@ ISR(INT3_vect) {
250257
intFunc[EXTERNAL_INT_3]();
251258
}
252259

260+
ISR(INT6_vect) {
261+
if(intFunc[EXTERNAL_INT_4])
262+
intFunc[EXTERNAL_INT_4]();
263+
}
264+
253265
#elif defined(EICRA) && defined(EICRB)
254266

255267
ISR(INT0_vect) {

hardware/arduino/cores/arduino/wiring_private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern "C"{
5757
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
5858
#define EXTERNAL_NUM_INTERRUPTS 3
5959
#elif defined(__AVR_ATmega32U4__)
60-
#define EXTERNAL_NUM_INTERRUPTS 4
60+
#define EXTERNAL_NUM_INTERRUPTS 5
6161
#else
6262
#define EXTERNAL_NUM_INTERRUPTS 2
6363
#endif

0 commit comments

Comments
 (0)