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:   buffered_serial_test BLE_Police_HRM evena_BLE_Police_HRM df-2014-workshop-rfid-case-generator-k64f ... more

Example

 #include "mbed.h"
 #include "BufferedSerial.h"

 BufferedSerial pc(USBTX, USBRX);

 int main()
 {
     pc.baud(115200);
   
     while(1)
     {
         Timer s;
       
         s.start();
         pc.printf("Hello World - buff\n");
         int buffered_time = s.read_us();
         wait(0.1f); // give time for the buffer to empty
       
         s.reset();
         printf("Hello World - poll\n");
         int polled_time = s.read_us();
         s.stop();
         wait(0.1f); // give time for the buffer to empty
       
         pc.printf("printf buffered took %d us\n", buffered_time);
         pc.printf("printf polled took %d us\n", polled_time);
         wait(0.5f);
     }
 }

History

Discard random text file and update version check help message. default tip

2019-02-20, by sam_grove [Wed, 20 Feb 2019 01:34:41 +0000] rev 14

Discard random text file and update version check help message.


Eliminate warnings with Mbed 2 version 131 and Mbed OS 5.2.0 and newer. Added error messages to help if incompatible versions are identified (best effort)

2019-02-20, by sam_grove [Wed, 20 Feb 2019 01:29:28 +0000] rev 13

Eliminate warnings with Mbed 2 version 131 and Mbed OS 5.2.0 and newer. Added error messages to help if incompatible versions are identified (best effort)


Update Buffer to MyBuffer

2016-03-07, by sam_grove [Mon, 07 Mar 2016 21:10:27 +0000] rev 12

Update Buffer to MyBuffer


Force use of RawSerial

2015-07-26, by sam_grove [Sun, 26 Jul 2015 21:53:11 +0000] rev 11

Force use of RawSerial


updates to the constructor to enable expansion of the internal ring buffers and printf() buffer sizes

2015-01-07, by ansond [Wed, 07 Jan 2015 18:37:11 +0000] rev 10

updates to the constructor to enable expansion of the internal ring buffers and printf() buffer sizes


updates to buffer ring sizes now 2x the buffer size

2015-01-04, by ansond [Sun, 04 Jan 2015 23:27:53 +0000] rev 9

updates to buffer ring sizes now 2x the buffer size


increased buffer sizes more

2015-01-04, by ansond [Sun, 04 Jan 2015 22:15:53 +0000] rev 8

increased buffer sizes more


made updates to enable the ability to expand the internal buffer. Additionally, used the definition to set the size of the ring buffers in the constructor initializer list. Increased the default buffer size to 512. Additional clean ups (param cks)

2015-01-02, by ansond [Fri, 02 Jan 2015 03:47:26 +0000] rev 7

made updates to enable the ability to expand the internal buffer. Additionally, used the definition to set the size of the ring buffers in the constructor initializer list. Increased the default buffer size to 512. Additional clean ups (param cks)


added #define to change the base Serial class to RawSerial if desired

2014-09-09, by ansond [Tue, 09 Sep 2014 20:20:38 +0000] rev 6

added #define to change the base Serial class to RawSerial if desired


Updated example in documentation. Tested with mbed.bld 81 and works with LPC1768, LPC11U24, KL25Z, KL46Z, KL05Z

2014-03-24, by sam_grove [Mon, 24 Mar 2014 19:56:57 +0000] rev 5

Updated example in documentation. Tested with mbed.bld 81 and works with LPC1768, LPC11U24, KL25Z, KL46Z, KL05Z