From 17b9b5373763eb97302a55a9208d35f7abaea217 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 23 Apr 2014 14:41:12 +0200 Subject: In SoftwareSerial, use ISR_ALIASOF to prevent duplication Previously, up to four separate but identical ISR routines were defined, for PCINT0, PCINT1, PCINT2 and PCINT3. Each of these would generate their own function, with a lot of push-popping because another function was called. Now, the ISR_ALIASOF macro from avr-libc is used to declare just the PCINT0 version and make all other ISRs point to that one, saving a lot of program space, as well as some speed because of improved inlining. On an Arduino Uno with gcc 4.3, this saves 168 bytes. With gcc 4.8, this saves 150 bytes. --- libraries/SoftwareSerial/SoftwareSerial.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index 974aa1e..cafd0c4 100644 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -316,24 +316,15 @@ ISR(PCINT0_vect) #endif #if defined(PCINT1_vect) -ISR(PCINT1_vect) -{ - SoftwareSerial::handle_interrupt(); -} +ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect)); #endif #if defined(PCINT2_vect) -ISR(PCINT2_vect) -{ - SoftwareSerial::handle_interrupt(); -} +ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect)); #endif #if defined(PCINT3_vect) -ISR(PCINT3_vect) -{ - SoftwareSerial::handle_interrupt(); -} +ISR(PCINT3_vect, ISR_ALIASOF(PCINT0_vect)); #endif // -- cgit v1.2.3-18-g5258