Skip to content

Commit 17b9b53

Browse files
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.
1 parent 157ec97 commit 17b9b53

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

libraries/SoftwareSerial/SoftwareSerial.cpp

+3-12
Original file line numberDiff line numberDiff line change
@@ -316,24 +316,15 @@ ISR(PCINT0_vect)
316316
#endif
317317

318318
#if defined(PCINT1_vect)
319-
ISR(PCINT1_vect)
320-
{
321-
SoftwareSerial::handle_interrupt();
322-
}
319+
ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
323320
#endif
324321

325322
#if defined(PCINT2_vect)
326-
ISR(PCINT2_vect)
327-
{
328-
SoftwareSerial::handle_interrupt();
329-
}
323+
ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
330324
#endif
331325

332326
#if defined(PCINT3_vect)
333-
ISR(PCINT3_vect)
334-
{
335-
SoftwareSerial::handle_interrupt();
336-
}
327+
ISR(PCINT3_vect, ISR_ALIASOF(PCINT0_vect));
337328
#endif
338329

339330
//

0 commit comments

Comments
 (0)