An RTOS-friendly Serial interface Its primary benefit is that it never hogs the CPU. An amusing alternative to the traditional ring-bufferd interrupt-serviced systems, it uses short mbed-rtos queues to buffer characters to and from the UART, and a thread to service the transmitter. Short interrupt service routines enqueue received characters and signal the transmit thread when the transmitter is available. WARNING: Do not create RTOS-Serial objects before the RTOS is running! Put them inside your main() block or another function, not in the global initialization.

Dependents:   Test_RDM880_rfid_reader

Revision:
17:93011ddbd0a2
Parent:
16:2d3937773625
Child:
18:8665cc17b30d
--- a/rtos_serial.h	Wed Oct 30 04:59:44 2013 +0000
+++ b/rtos_serial.h	Wed Oct 30 05:01:45 2013 +0000
@@ -88,7 +88,7 @@
 class RTOS_Serial : public RawSerial {
   public:
 
-    /** Create an RTOS_Serial connected to the specified UART pins
+    /** Create an RTOS_Serial connected to the specified UART pins.
      *
      * @param tx PinName of the UART output (transmission) pin
      * @param rx PinName of the UART input (reception) pin
@@ -96,7 +96,7 @@
      */
     RTOS_Serial(PinName tx, PinName rx, const char *name=NULL);
     
-    /** Send a character
+    /** Send a character.
      * If the output queue is full it yields until it can enqueue
      *
      * @param c character to queue for transmission
@@ -104,7 +104,7 @@
      */
     int putc(int c);
     
-    /** Get a character
+    /** Get a character.
      * Yields to other threads until a character is available
      *
      * @param timeout (optional) milliseconds to wait for a character (default forever)
@@ -112,7 +112,7 @@
      */
     int getc(int timeout = osWaitForever);
     
-    /** Put a null-terminated string of characters
+    /** Put a null-terminated string of characters.
      *
      * @param s the string
      * @returns the number of characters enqueued for transmission, or EOF on error
@@ -121,7 +121,7 @@
 //    int readable();
 //    int writeable();
     int get_index();
-    /** Obtain the baud rate of the UART
+    /** Obtain the baud rate of the UART.
      *
      * @returns the baud rate of the UART (tx and rx are the same)
      */