Inherit from Serial and use software buffers for TX and RX. This allows the UART peripherals to operate in a IRQ driven mode. Overrides most (but not all) stdio functions as Serial did

Dependencies:   Buffer

Dependents:   mbed_esp8266_demo

Fork of BufferedSerial by Sam Grove

Revision:
7:6fa214b41d73
Parent:
6:8287e83943f0
Child:
8:506247a040bc
--- a/BufferedSerial.h	Tue Sep 09 20:20:38 2014 +0000
+++ b/BufferedSerial.h	Fri Jan 02 03:47:26 2015 +0000
@@ -27,8 +27,12 @@
 #include "mbed.h"
 #include "Buffer.h"
 
+// Base Class
 #define SERIAL_BASE  RawSerial
 
+// Internal buffer size
+#define BUFFEREDSERIAL_MAX_BUFFER_SIZE   512
+
 /** A serial port (UART) for communication with other serial devices
  *
  * Can be used for Full Duplex communication, or Simplex by specifying
@@ -75,6 +79,7 @@
 private:
     Buffer <char> _rxbuf;
     Buffer <char> _txbuf;
+    char          _buffer[BUFFEREDSERIAL_MAX_BUFFER_SIZE+1];
  
     void rxIrq(void);
     void txIrq(void);
@@ -84,6 +89,7 @@
     /** Create a BufferedSerial port, connected to the specified transmit and receive pins
      *  @param tx Transmit pin
      *  @param rx Receive pin
+     *  @param name optional name
      *  @note Either tx or rx may be specified as NC if unused
      */
     BufferedSerial(PinName tx, PinName rx, const char* name=NULL);