@@ -40,8 +40,8 @@ The latest version of this library can always be found at
40
40
//
41
41
#include < avr/interrupt.h>
42
42
#include < avr/pgmspace.h>
43
- #include " Arduino.h"
44
- #include " SoftwareSerial.h"
43
+ #include < Arduino.h>
44
+ #include < SoftwareSerial.h>
45
45
//
46
46
// Lookup table
47
47
//
@@ -70,6 +70,7 @@ static const DELAY_TABLE PROGMEM table[] =
70
70
{ 4800 , 233 , 474 , 474 , 471 , },
71
71
{ 2400 , 471 , 950 , 950 , 947 , },
72
72
{ 1200 , 947 , 1902 , 1902 , 1899 , },
73
+ { 600 , 1902 , 3804 , 3804 , 3800 , },
73
74
{ 300 , 3804 , 7617 , 7617 , 7614 , },
74
75
};
75
76
@@ -91,6 +92,7 @@ static const DELAY_TABLE table[] PROGMEM =
91
92
{ 4800 , 110 , 233 , 233 , 230 , },
92
93
{ 2400 , 229 , 472 , 472 , 469 , },
93
94
{ 1200 , 467 , 948 , 948 , 945 , },
95
+ { 600 , 948 , 1895 , 1895 , 1890 , },
94
96
{ 300 , 1895 , 3805 , 3805 , 3802 , },
95
97
};
96
98
@@ -115,6 +117,7 @@ static const DELAY_TABLE PROGMEM table[] =
115
117
{ 4800 , 296 , 595 , 595 , 592 , },
116
118
{ 2400 , 592 , 1189 , 1189 , 1186 , },
117
119
{ 1200 , 1187 , 2379 , 2379 , 2376 , },
120
+ { 600 , 2379 , 4759 , 4759 , 4755 , },
118
121
{ 300 , 4759 , 9523 , 9523 , 9520 , },
119
122
};
120
123
@@ -373,13 +376,15 @@ void SoftwareSerial::setRX(uint8_t rx)
373
376
// Public methods
374
377
//
375
378
376
- void SoftwareSerial::begin (long speed)
379
+ bool SoftwareSerial::begin (long speed)
377
380
{
378
381
_rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0 ;
379
382
383
+ long baud = 0 ;
384
+
380
385
for (unsigned i=0 ; i<sizeof (table)/sizeof (table[0 ]); ++i)
381
386
{
382
- long baud = pgm_read_dword (&table[i].baud );
387
+ baud = pgm_read_dword (&table[i].baud );
383
388
if (baud == speed)
384
389
{
385
390
_rx_delay_centering = pgm_read_word (&table[i].rx_delay_centering );
@@ -389,6 +394,7 @@ void SoftwareSerial::begin(long speed)
389
394
break ;
390
395
}
391
396
}
397
+ if (baud != speed) return false ;
392
398
393
399
// Set up RX interrupts, but only if we have a valid RX baud rate
394
400
if (_rx_delay_stopbit)
@@ -407,6 +413,8 @@ void SoftwareSerial::begin(long speed)
407
413
#endif
408
414
409
415
listen ();
416
+
417
+ return true ;
410
418
}
411
419
412
420
void SoftwareSerial::end ()
0 commit comments