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

Fork of BufferedSerial by Sam Grove

Revision:
10:9ee15ae3d1a3
Parent:
9:2cb30392ade6
Child:
11:8037db39ea31
--- a/BufferedSerial.h	Sun Jan 04 23:27:53 2015 +0000
+++ b/BufferedSerial.h	Wed Jan 07 18:37:11 2015 +0000
@@ -30,9 +30,6 @@
 // Base Class
 #define SERIAL_BASE  RawSerial
 
-// Internal buffer size (Ring buffers will be 2X this value each for RX and TX...)
-#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
@@ -79,7 +76,8 @@
 private:
     Buffer <char> _rxbuf;
     Buffer <char> _txbuf;
-    char          _buffer[BUFFEREDSERIAL_MAX_BUFFER_SIZE+1];
+    uint32_t      _buf_size;
+    uint32_t      _tx_multiple;
  
     void rxIrq(void);
     void txIrq(void);
@@ -89,10 +87,12 @@
     /** Create a BufferedSerial port, connected to the specified transmit and receive pins
      *  @param tx Transmit pin
      *  @param rx Receive pin
+     *  @param buf_size printf() buffer size
+     *  @param tx_multiple amount of max printf() present in the internal ring buffer at one time
      *  @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);
+    BufferedSerial(PinName tx, PinName rx, uint32_t buf_size = 256, uint32_t tx_multiple = 4,const char* name=NULL);
     
     /** Destroy a BufferedSerial port
      */