Skip to content

Commit 0b100b2

Browse files
committed
Atledge-184 Minor improvements to SoftwareSerial library
Minor improvements to SoftwareSerial library
1 parent 7150436 commit 0b100b2

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

libraries/CurieSoftwareSerial/SoftwareSerial.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ License along with this library; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
1818
Implementation of SoftwareSerial Library for Arduino 101
19+
20+
CurieSoftwareSerial library is a work in progress
21+
Currently only 38400 and 57600 bps is the supported baud rate for RX
22+
RX is only fully functional on pins 2, 4, 7, 8, 10, 11, 12.
1923
*/
2024

2125
// When set, _DEBUG co-opts pins 11 and 13 for debugging with an
@@ -172,7 +176,8 @@ void SoftwareSerial::recv()
172176
}
173177

174178
// skip the stop bit/s
175-
delayTicks(bitDelay>>4);
179+
//TODO: tweak this value depending on which gpio is used
180+
delayTicks(bitDelay >> 2);
176181
DebugPulse(_DEBUG_PIN1, 1);
177182
}
178183
interrupts();

libraries/CurieSoftwareSerial/SoftwareSerial.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ License along with this library; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
1818
Implementation of SoftwareSerial Library for Arduino 101
19+
20+
CurieSoftwareSerial library is a work in progress
21+
Currently only 38400 and 57600 bps is the supported baud rate for RX
22+
RX is only fully functional on pins 2, 4, 7, 8, 10, 11, 12.
1923
*/
2024

2125
#ifndef SoftwareSerial_h
@@ -57,12 +61,12 @@ class SoftwareSerial : public Stream
5761
static SoftwareSerial *active_object;
5862

5963
// private methods
60-
static void recv() __attribute__((__always_inline__));
64+
static void recv();
6165
uint32_t rx_pin_read();
6266
void tx_pin_write(uint32_t pin_state) __attribute__((__always_inline__));
6367
void setTX(uint8_t transmitPin);
6468
void setRX(uint8_t receivePin);
65-
void setRxIntMsk(bool enable) __attribute__((__always_inline__));
69+
void setRxIntMsk(bool enable);
6670

6771
// Return num - sub, or 1 if the result would be < 1
6872
static uint16_t subtract_cap(uint16_t num, uint16_t sub);

libraries/CurieSoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Receives from software serial, sends to hardware serial.
66
77
The circuit:
8-
* RX is digital pin 10 (connect to TX of other device)
9-
* TX is digital pin 11 (connect to RX of other device)
8+
* RX is digital pin 2 (connect to TX of other device)
9+
* TX is digital pin 3 (connect to RX of other device)
1010
1111
Note:
1212
Not all pins on the Mega and Mega 2560 support change interrupts,
@@ -27,12 +27,12 @@
2727
*/
2828
#include <SoftwareSerial.h>
2929

30-
SoftwareSerial mySerial(10, 11); // RX, TX
30+
SoftwareSerial mySerial(2, 3); // RX, TX
3131

3232
void setup()
3333
{
3434
// Open serial communications and wait for port to open:
35-
Serial.begin(57600);
35+
Serial.begin(115200);
3636
while (!Serial) {
3737
; // wait for serial port to connect. Needed for Leonardo only
3838
}
@@ -41,7 +41,7 @@ void setup()
4141
Serial.println("Goodnight moon!");
4242

4343
// set the data rate for the SoftwareSerial port
44-
mySerial.begin(4800);
44+
mySerial.begin(38400);
4545
mySerial.println("Hello, world?");
4646
}
4747

0 commit comments

Comments
 (0)