Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SoftSerial by
Diff: SoftSerial_rx.cpp
- Revision:
 - 3:7238e9bb74d2
 - Parent:
 - 1:f8b4b764ace7
 - Child:
 - 4:c010265ed202
 
diff -r 9e01a38606b4 -r 7238e9bb74d2 SoftSerial_rx.cpp
--- a/SoftSerial_rx.cpp	Sat Apr 26 16:21:42 2014 +0000
+++ b/SoftSerial_rx.cpp	Sat Apr 26 16:35:20 2014 +0000
@@ -12,15 +12,17 @@
 
 //Start receiving byte
 void SoftSerial::rx_gpio_irq_handler(void) {
+    rxout.attach_us(this, &SoftSerial::rx_handler, bit_period + (bit_period >> 1));   //Start reading first data byte
     rx->fall(NULL);
     rx_bit = 0;
     rx_error = false;
-    rxout.attach_us(this, &SoftSerial::rx_handler, bit_period + (bit_period >> 1));   //Start reading first data byte
 };    
 
 void SoftSerial::rx_handler(void) {
+    if (!rx_bit)
+        rxticker.attach_us(this, &SoftSerial::rx_handler, bit_period); 
+        
     rx_bit++;
-    rxout.attach_us(this, &SoftSerial::rx_handler, bit_period); 
     
     //Receive data
     int val = rx->read();
@@ -72,7 +74,7 @@
         out_buffer = read_buffer;
     }
     read_buffer = 0;
-    rxout.detach(); 
+    rxticker.detach(); 
     rx->fall(this, &SoftSerial::rx_gpio_irq_handler);
 }
 
    