Buffered Serial Port Driver for RTOS

Dependents:   nucleo_cannonball PiballNeoController

Buffered Serial Port Driver for RTOS

  • ISR driven, ring buffered IO operation
  • IO operations are idle waiting, don't waste time in RTOS :D
  • Can use external buffers
  • Based on mbed RawSerial

Example

SerialDriver Example

#include "SerialDriver.h"

SerialDriver pc(USBTX, USBRX);

int main()
{
    // setup serial port
    pc.baud(9600);
    
    // print some text
    pc.puts("This is just a string.\r\n");
    pc.printf("But this is a %s with integer %i and float %f.\r\n", "formatted text", 123, 0.456f);
    
    // now lets behave like a null modem 
    while(1)
       pc.putc(pc.getc());
}

Look at the API Documentation for more Examples.

Dependencies

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Import librarymbed-rtos

Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

If you find a bug, please help me to fix it. Send me a message. You can help me a lot: Write a demo program that causes the bug reproducible.

Files at this revision

API Documentation at this revision

Comitter:
BlazeX
Date:
Thu Jan 15 09:00:48 2015 +0000
Parent:
0:cd0d79be0c1a
Child:
2:012c0c2fac52
Commit message:
Fixed Dependencies.

Changed in this revision

Examples/Example_Blocking.cpp Show annotated file Show diff for this revision Revisions of this file
Examples/Example_Bridge.cpp Show annotated file Show diff for this revision Revisions of this file
Examples/Example_Nullmodem.cpp Show annotated file Show diff for this revision Revisions of this file
Examples/Example_printf.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/Examples/Example_Blocking.cpp	Wed Jan 14 16:30:14 2015 +0000
+++ b/Examples/Example_Blocking.cpp	Thu Jan 15 09:00:48 2015 +0000
@@ -11,7 +11,6 @@
 
 #if 0
 
-#include "mbed.h"
 #include "SerialDriver.h"
 
 SerialDriver pc(USBTX, USBRX, 4, 32);
--- a/Examples/Example_Bridge.cpp	Wed Jan 14 16:30:14 2015 +0000
+++ b/Examples/Example_Bridge.cpp	Thu Jan 15 09:00:48 2015 +0000
@@ -12,7 +12,6 @@
 
 #if 0
 
-#include "mbed.h"
 #include "SerialDriver.h"
 
 SerialDriver pc(USBTX, USBRX);
@@ -60,3 +59,4 @@
 }
 
 #endif
+
--- a/Examples/Example_Nullmodem.cpp	Wed Jan 14 16:30:14 2015 +0000
+++ b/Examples/Example_Nullmodem.cpp	Thu Jan 15 09:00:48 2015 +0000
@@ -10,7 +10,6 @@
 
 #if 0
 
-#include "mbed.h"
 #include "SerialDriver.h"
 
 SerialDriver pc(USBTX, USBRX);
@@ -48,3 +47,4 @@
 }
 
 #endif
+
--- a/Examples/Example_printf.cpp	Wed Jan 14 16:30:14 2015 +0000
+++ b/Examples/Example_printf.cpp	Thu Jan 15 09:00:48 2015 +0000
@@ -10,7 +10,6 @@
 
 #if 0
 
-#include "mbed.h"
 #include "SerialDriver.h"
 
 // only 4 byte of software ring buffer?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Jan 15 09:00:48 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#9387d4c49609
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 15 09:00:48 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file