Skip to content

Commit 8f9227f

Browse files
committed
Add library.properties for #11
* Move EXTERNAL_PCINT to header * Update version comments
1 parent d6f762d commit 8f9227f

File tree

3 files changed

+90
-73
lines changed

3 files changed

+90
-73
lines changed

Diff for: NeoSWSerial.cpp

+58-54
Original file line numberDiff line numberDiff line change
@@ -410,84 +410,88 @@ void NeoSWSerial::rxChar( uint8_t c )
410410

411411
} // rxChar
412412

413-
#ifndef NEOSWSERIAL_EXTERNAL_PCINT
414413
//----------------------------------------------------------------------------
415-
// Must define all of the vectors even though only one is used.
416414

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
419416

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
426418

427-
#if defined(__AVR_ATtiny261__) | \
428-
defined(__AVR_ATtiny461__) | \
429-
defined(__AVR_ATtiny861__)
419+
#else
430420

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+
}
437444
}
438-
}
439445

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__)
443449

444-
PCINT_ISR(0, PINB);
450+
PCINT_ISR(0, PINB);
445451

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__)
449455

450-
PCINT_ISR(0, PINA);
451-
PCINT_ISR(1, PINB);
456+
PCINT_ISR(0, PINA);
457+
PCINT_ISR(1, PINB);
452458

453-
#elif defined(__AVR_ATmega328P__)
459+
#elif defined(__AVR_ATmega328P__)
454460

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);
458464

459-
#elif defined(__AVR_ATmega32U4__)
465+
#elif defined(__AVR_ATmega32U4__)
460466

461-
PCINT_ISR(0, PINB);
467+
PCINT_ISR(0, PINB);
462468

463-
#elif defined(__AVR_AT90USB1286__)
469+
#elif defined(__AVR_AT90USB1286__)
464470

465-
PCINT_ISR(0, PINB);
471+
PCINT_ISR(0, PINB);
466472

467-
#elif defined(__AVR_ATmega2560__)
473+
#elif defined(__AVR_ATmega2560__)
468474

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);
472478

473-
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
479+
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
474480

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);
479485

480-
#elif defined(__AVR_ATmega2560RFR2__)
486+
#elif defined(__AVR_ATmega2560RFR2__)
481487

482-
PCINT_ISR(0, PINB);
483-
PCINT_ISR(1, PINE);
488+
PCINT_ISR(0, PINB);
489+
PCINT_ISR(1, PINE);
484490

485-
#else
486-
#error MCU not supported by NeoSWSerial!
487-
#endif
491+
#else
492+
#error MCU not supported by NeoSWSerial!
493+
#endif
488494

489-
#else
490-
// It's assumed that client code will call NeoSWSerial::rxISR(PINB) in PCINT handler
491495
#endif
492496

493497
//-----------------------------------------------------------------------------

Diff for: NeoSWSerial.h

+23-19
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@
4747
// service routines, the buffer size should be chosen to be a
4848
// power of 2 (i.e., 2, 4, 8, 16, 32, 64,...).
4949
//
50-
// Nov/Dec 2014 jboyton - Created
51-
// Jun 2015 jboyton - Added support for 8 MHz system clock. Timer 2 had to
52-
// be used since the timer 0 prescaler was inadequate
53-
// for this. The supported baud rates for 8 MHz are 9600
54-
// and 19200.
55-
// Nov 2015 SlashDev - Add support for other boards,
56-
// add end() and attach/detachInterrupt
57-
// Jun 2016 SlashDev - Add support for all character values
58-
// Mar 2017 SlashDev - Add GPL
50+
// v1.0 Nov 2014 jboyton - Created
51+
// v1.1 Jun 2015 jboyton - Added support for 8 MHz system clock. Timer 2 had to
52+
// be used since the timer 0 prescaler was inadequate
53+
// for this. The supported baud rates for 8 MHz are 9600
54+
// and 19200.
55+
// v2.0 Nov 2015 SlashDev - Add support for other boards,
56+
// add end() and attach/detachInterrupt
57+
// v2.1 Jun 2016 SlashDev - Add support for all character values
58+
// v2.2 Mar 2017 Dionorgua - Add option to disable pre-defined PCINT ISRs.
59+
// v2.3 Mar 2017 SlashDev - Add GPL
60+
// v3.0.0 May 2017 SlashDev - Convert to new Arduino IDE library
5961

6062
class NeoSWSerial : public Stream
6163
{
@@ -70,16 +72,16 @@ class NeoSWSerial : public Stream
7072
_isr = (isr_t) NULL;
7173
}
7274

73-
void begin(uint16_t baudRate=9600); // initialize, set baudrate, listen
74-
void listen(); // enable RX interrupts
75-
void ignore(); // disable RX interrupts
76-
void setBaudRate(uint16_t baudRate); // set baud rate (9600 [default], 19200, 38400)
77-
int available(); // returns number of characters in buffer
78-
int read(); // get one character from buffer
79-
size_t write(uint8_t txChar); // transmit a character
80-
virtual int peek() { return 0; };
81-
virtual void flush() {};
82-
void end() { ignore(); }
75+
void begin(uint16_t baudRate=9600); // initialize, set baudrate, listen
76+
void listen(); // enable RX interrupts
77+
void ignore(); // disable RX interrupts
78+
void setBaudRate(uint16_t baudRate); // 9600 [default], 19200, 38400
79+
virtual int available();
80+
virtual int read();
81+
virtual size_t write(uint8_t txChar);
82+
virtual int peek() { return 0; };
83+
virtual void flush() {};
84+
void end() { ignore(); }
8385

8486
typedef void (* isr_t)( uint8_t );
8587
void attachInterrupt( isr_t fn );
@@ -101,5 +103,7 @@ class NeoSWSerial : public Stream
101103
public:
102104
// visible only so the ISRs can call it...
103105
static void rxISR( uint8_t port_input_register );
106+
107+
//#define NEOSWSERIAL_EXTERNAL_PCINT // uncomment to use your own PCINT ISRs
104108
};
105109
#endif

Diff for: library.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=NeoSWSerial
2+
version=3.0.0
3+
author=SlashDevin
4+
maintainer=SlashDevin
5+
sentence=An efficient replacement for SoftwareSerial at baud rates 9600, 19200 and 38400.
6+
category=Communication
7+
url=https://github.com/SlashDevin/NeoSWSerial
8+
architectures=avr
9+
includes=NeoSWSerial.h

0 commit comments

Comments
 (0)