Skip to content

Commit d6f762d

Browse files
committed
Add license for Issue #8
1 parent 95e6b3f commit d6f762d

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

NeoSWSerial.cpp

+34-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
//
22
// NeoSWSerial
3+
// Copyright (C) 2015-2017, SlashDevin
4+
//
5+
// NeoSWSerial is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// NeoSWSerial is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details:
14+
//
15+
// <http://www.gnu.org/licenses/>.
316
//
417
// Methods
518
// -------
@@ -16,7 +29,7 @@
1629
// print() is supported
1730
//=============================================================================
1831

19-
#include "NeoSWSerial.h"
32+
#include <NeoSWSerial.h>
2033

2134
// Default baud rate is 9600
2235
static const uint8_t TICKS_PER_BIT_9600 = (uint8_t) 26;
@@ -27,8 +40,17 @@ static const uint8_t BITS_PER_TICK_38400_Q10 = 157;
2740

2841
#if F_CPU == 16000000L
2942
#define TCNTX TCNT0
43+
#define PCI_FLAG_REGISTER PCIFR
3044
#elif F_CPU == 8000000L
31-
#define TCNTX TCNT2
45+
#if defined(__AVR_ATtiny25__) | \
46+
defined(__AVR_ATtiny45__) | \
47+
defined(__AVR_ATtiny85__)
48+
#define TCNTX TCNT1
49+
#define PCI_FLAG_REGISTER GIFR
50+
#else
51+
#define TCNTX TCNT2
52+
#define PCI_FLAG_REGISTER PCIFR
53+
#endif
3254
#endif
3355

3456
static NeoSWSerial *listener = (NeoSWSerial *) NULL;
@@ -121,8 +143,14 @@ void NeoSWSerial::listen()
121143

122144
if (F_CPU == 8000000L) {
123145
// Have to use timer 2 for an 8 MHz system.
124-
TCCR2A = 0x00;
125-
TCCR2B = 0x03; // divide by 32
146+
#if defined(__AVR_ATtiny25__) | \
147+
defined(__AVR_ATtiny45__) | \
148+
defined(__AVR_ATtiny85__)
149+
TCCR1 = 0x06; // divide by 32
150+
#else
151+
TCCR2A = 0x00;
152+
TCCR2B = 0x03; // divide by 32
153+
#endif
126154
}
127155

128156
volatile uint8_t *pcmsk = digitalPinToPCMSK(rxPin);
@@ -507,8 +535,8 @@ size_t NeoSWSerial::write(uint8_t txChar)
507535

508536
while ((uint8_t)(TCNTX - t0) < width) {
509537
// Receive interrupt pending?
510-
if (PCIFR & PCIbit) {
511-
PCIFR |= PCIbit; // clear it because...
538+
if (PCI_FLAG_REGISTER & PCIbit) {
539+
PCI_FLAG_REGISTER |= PCIbit; // clear it because...
512540
rxISR( *rxPort ); // ... this handles it
513541
DBG_NSS_COUNT(polledPCI);
514542
} else if (checkRxTime()) {

NeoSWSerial.h

+15-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@
66
//---------------------------------------------------------------------------
77
//
88
// NeoSWSerial
9+
// Copyright (C) 2015-2016, SlashDevin
910
//
11+
// NeoSWSerial is free software: you can redistribute it and/or modify
12+
// it under the terms of the GNU General Public License as published by
13+
// the Free Software Foundation, either version 3 of the License, or
14+
// (at your option) any later version.
1015
//
11-
// A software serial library, intended as a more-efficient replacement
12-
// for SoftwareSerial at baud rates 9600, 19200 and 38400.
16+
// NeoSWSerial is distributed in the hope that it will be useful,
17+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
// GNU General Public License for more details:
20+
//
21+
// <http://www.gnu.org/licenses/>.
1322
//
14-
// Constructor: NeoSWSerial ss(RX_PIN, TX_PIN);
23+
//
24+
// This software serial library is intended as a more-efficient replacement
25+
// for SoftwareSerial at baud rates 9600, 19200 and 38400.
1526
//
1627
// Any of the pins supported by SoftwareSerial may be used. Pins (0-19)
1728
// on the Uno may be used. Other boards can use any of the pins
@@ -44,7 +55,7 @@
4455
// Nov 2015 SlashDev - Add support for other boards,
4556
// add end() and attach/detachInterrupt
4657
// Jun 2016 SlashDev - Add support for all character values
47-
//
58+
// Mar 2017 SlashDev - Add GPL
4859

4960
class NeoSWSerial : public Stream
5061
{

0 commit comments

Comments
 (0)