From 369aeeef51d0aa8e5fa1d2f9bffbb20b3771caaa Mon Sep 17 00:00:00 2001 From: sebastienjean Date: Sat, 1 Dec 2012 00:20:55 +0100 Subject: [PATCH 1/2] 600 Baud comm. support, unsupported baudrate notification - Added a 600 Baud line in DELAY_TABLE, for each CPU frequency. (successfully tested for 16 MHz) - begin(long speed) now returns a bool indicating if speed has been found in DELAY_TABLE (if not, the method returns false immediately) --- libraries/SoftwareSerial/SoftwareSerial.cpp | 16 ++++++++++++---- libraries/SoftwareSerial/SoftwareSerial.h | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index c15bdda0d..4e02cb6a4 100755 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -40,8 +40,8 @@ http://arduiniana.org. // #include #include -#include "Arduino.h" -#include "SoftwareSerial.h" +#include +#include // // Lookup table // @@ -70,6 +70,7 @@ static const DELAY_TABLE PROGMEM table[] = { 4800, 233, 474, 474, 471, }, { 2400, 471, 950, 950, 947, }, { 1200, 947, 1902, 1902, 1899, }, + { 600, 1902, 3804, 3804, 3800, }, { 300, 3804, 7617, 7617, 7614, }, }; @@ -91,6 +92,7 @@ static const DELAY_TABLE table[] PROGMEM = { 4800, 110, 233, 233, 230, }, { 2400, 229, 472, 472, 469, }, { 1200, 467, 948, 948, 945, }, + { 600, 948, 1895, 1895, 1890, }, { 300, 1895, 3805, 3805, 3802, }, }; @@ -115,6 +117,7 @@ static const DELAY_TABLE PROGMEM table[] = { 4800, 296, 595, 595, 592, }, { 2400, 592, 1189, 1189, 1186, }, { 1200, 1187, 2379, 2379, 2376, }, + { 600, 2379, 4759, 4759, 4755, }, { 300, 4759, 9523, 9523, 9520, }, }; @@ -373,13 +376,15 @@ void SoftwareSerial::setRX(uint8_t rx) // Public methods // -void SoftwareSerial::begin(long speed) +bool SoftwareSerial::begin(long speed) { _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; + long baud = 0; + for (unsigned i=0; i Date: Sun, 2 Dec 2012 17:22:59 +0100 Subject: [PATCH 2/2] Reverted begin(long speed) to its original prototype (i.e. returning void) --- libraries/SoftwareSerial/SoftwareSerial.cpp | 9 ++------- libraries/SoftwareSerial/SoftwareSerial.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp index 4e02cb6a4..64496febb 100755 --- a/libraries/SoftwareSerial/SoftwareSerial.cpp +++ b/libraries/SoftwareSerial/SoftwareSerial.cpp @@ -376,15 +376,13 @@ void SoftwareSerial::setRX(uint8_t rx) // Public methods // -bool SoftwareSerial::begin(long speed) +void SoftwareSerial::begin(long speed) { _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; - long baud = 0; - for (unsigned i=0; i