From 6dc00061df81b4750208996bb7dd0ec76f8f901f Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Mon, 19 Dec 2011 15:40:12 -0500 Subject: [PATCH] fixed attachInterrupt() on Leonardo had to define a separate block for the 32U4 since it looks like a Mega-series board based on a simple register trick. Only two useable HW interrupts though, compared to the Megas' 8, and numbering differs. --- cores/arduino/WInterrupts.c | 38 +++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) mode change 100755 => 100644 cores/arduino/WInterrupts.c diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c old mode 100755 new mode 100644 index 1449cfb..2ec72a5 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -47,7 +47,19 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { // Enable the interrupt. switch (interruptNum) { -#if defined(EICRA) && defined(EICRB) && defined(EIMSK) +#if defined(__AVR_ATmega32U4__) + // I hate doing this, but the register assignment differs between the 1280/2560 + // and the 32U4. Since avrlib defines registers PCMSK1 and PCMSK2 that aren't + // even present on the 32U4 this is the only way to distinguish between them. + case 0: + EICRA = (EICRA & ~((1<