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:
- 10:236fce2e5b8c
- Parent:
- 6:517082212c00
--- a/SoftSerial_rx.cpp Sat Jul 05 08:07:49 2014 +0000 +++ b/SoftSerial_rx.cpp Sat Jul 05 13:22:43 2014 +0000 @@ -1,5 +1,7 @@ #include "SoftSerial.h" +uint32_t overhead_us = 200 * 1000000 / SystemCoreClock; //Random estimation of the overhead of mbed libs, makes slow devices like LPC812 @ 12MHz perform better + int SoftSerial::_getc( void ) { while(!readable()); out_valid = false; @@ -13,18 +15,20 @@ //Start receiving byte void SoftSerial::rx_gpio_irq_handler(void) { rxticker.prime(); - rxticker.setNext(bit_period + (bit_period >> 1)); + rxticker.setNext(bit_period + (bit_period >> 1) - overhead_us); rx->fall(NULL); rx_bit = 0; rx_error = false; }; void SoftSerial::rx_handler(void) { + //Receive data + int val = rx->read(); + rxticker.setNext(bit_period); rx_bit++; - //Receive data - int val = rx->read(); + if (rx_bit <= _bits) { read_buffer |= val << (rx_bit - 1); return;