@@ -410,84 +410,88 @@ void NeoSWSerial::rxChar( uint8_t c )
410
410
411
411
} // rxChar
412
412
413
- #ifndef NEOSWSERIAL_EXTERNAL_PCINT
414
413
// ----------------------------------------------------------------------------
415
- // Must define all of the vectors even though only one is used.
416
414
417
- // This handy PCINT code for different boards is based on PinChangeInterrupt.*
418
- // from the excellent Cosa project: http://github.com/mikaelpatel/Cosa
415
+ #ifdef NEOSWSERIAL_EXTERNAL_PCINT
419
416
420
- #define PCINT_ISR (vec,pin ) \
421
- extern " C" { \
422
- ISR (PCINT ## vec ## _vect) \
423
- { \
424
- NeoSWSerial::rxISR (pin); \
425
- } }
417
+ // Client code must call NeoSWSerial::rxISR(PINB) in PCINT handler
426
418
427
- #if defined(__AVR_ATtiny261__) | \
428
- defined (__AVR_ATtiny461__) | \
429
- defined(__AVR_ATtiny861__)
419
+ #else
430
420
431
- ISR(PCINT0_vect)
432
- {
433
- if (GIFR & _BV (INTF0)) {
434
- NeoSWSerial::rxISR (PINA);
435
- } else {
436
- NeoSWSerial::rxISR (PINB);
421
+ // Must define all of the vectors even though only one is used.
422
+
423
+ // This handy PCINT code for different boards is based on PinChangeInterrupt.*
424
+ // from the excellent Cosa project: http://github.com/mikaelpatel/Cosa
425
+
426
+ #define PCINT_ISR (vec,pin ) \
427
+ extern " C" { \
428
+ ISR (PCINT ## vec ## _vect) \
429
+ { \
430
+ NeoSWSerial::rxISR (pin); \
431
+ } }
432
+
433
+ #if defined(__AVR_ATtiny261__) | \
434
+ defined (__AVR_ATtiny461__) | \
435
+ defined(__AVR_ATtiny861__)
436
+
437
+ ISR(PCINT0_vect)
438
+ {
439
+ if (GIFR & _BV (INTF0)) {
440
+ NeoSWSerial::rxISR (PINA);
441
+ } else {
442
+ NeoSWSerial::rxISR (PINB);
443
+ }
437
444
}
438
- }
439
445
440
- #elif defined(__AVR_ATtiny25__) | \
441
- defined (__AVR_ATtiny45__) | \
442
- defined(__AVR_ATtiny85__)
446
+ #elif defined(__AVR_ATtiny25__) | \
447
+ defined (__AVR_ATtiny45__) | \
448
+ defined(__AVR_ATtiny85__)
443
449
444
- PCINT_ISR(0 , PINB);
450
+ PCINT_ISR(0 , PINB);
445
451
446
- #elif defined(__AVR_ATtiny24__) | \
447
- defined (__AVR_ATtiny44__) | \
448
- defined(__AVR_ATtiny84__)
452
+ #elif defined(__AVR_ATtiny24__) | \
453
+ defined (__AVR_ATtiny44__) | \
454
+ defined(__AVR_ATtiny84__)
449
455
450
- PCINT_ISR(0 , PINA);
451
- PCINT_ISR (1 , PINB);
456
+ PCINT_ISR(0 , PINA);
457
+ PCINT_ISR (1 , PINB);
452
458
453
- #elif defined(__AVR_ATmega328P__)
459
+ #elif defined(__AVR_ATmega328P__)
454
460
455
- PCINT_ISR (0 , PINB);
456
- PCINT_ISR (1 , PINC);
457
- PCINT_ISR (2 , PIND);
461
+ PCINT_ISR (0 , PINB);
462
+ PCINT_ISR (1 , PINC);
463
+ PCINT_ISR (2 , PIND);
458
464
459
- #elif defined(__AVR_ATmega32U4__)
465
+ #elif defined(__AVR_ATmega32U4__)
460
466
461
- PCINT_ISR (0 , PINB);
467
+ PCINT_ISR (0 , PINB);
462
468
463
- #elif defined(__AVR_AT90USB1286__)
469
+ #elif defined(__AVR_AT90USB1286__)
464
470
465
- PCINT_ISR (0 , PINB);
471
+ PCINT_ISR (0 , PINB);
466
472
467
- #elif defined(__AVR_ATmega2560__)
473
+ #elif defined(__AVR_ATmega2560__)
468
474
469
- PCINT_ISR (0 , PINB);
470
- PCINT_ISR (1 , PINJ);
471
- PCINT_ISR (2 , PINK);
475
+ PCINT_ISR (0 , PINB);
476
+ PCINT_ISR (1 , PINJ);
477
+ PCINT_ISR (2 , PINK);
472
478
473
- #elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
479
+ #elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
474
480
475
- PCINT_ISR (0 , PINA);
476
- PCINT_ISR (1 , PINB);
477
- PCINT_ISR (2 , PINC);
478
- PCINT_ISR (3 , PIND);
481
+ PCINT_ISR (0 , PINA);
482
+ PCINT_ISR (1 , PINB);
483
+ PCINT_ISR (2 , PINC);
484
+ PCINT_ISR (3 , PIND);
479
485
480
- #elif defined(__AVR_ATmega2560RFR2__)
486
+ #elif defined(__AVR_ATmega2560RFR2__)
481
487
482
- PCINT_ISR (0 , PINB);
483
- PCINT_ISR (1 , PINE);
488
+ PCINT_ISR (0 , PINB);
489
+ PCINT_ISR (1 , PINE);
484
490
485
- #else
486
- #error MCU not supported by NeoSWSerial!
487
- #endif
491
+ #else
492
+ #error MCU not supported by NeoSWSerial!
493
+ #endif
488
494
489
- #else
490
- // It's assumed that client code will call NeoSWSerial::rxISR(PINB) in PCINT handler
491
495
#endif
492
496
493
497
// -----------------------------------------------------------------------------
0 commit comments