MODSERIAL with support for KL25Z + RTOS (beta, putc + puts currently)

Dependents:   kl25z_USB_4

Fork of MODSERIAL by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Tue Jul 16 14:00:58 2013 +0000
Parent:
29:9a41078f0488
Commit message:
Added some RTOS ability

Changed in this revision

MODSERIAL.h Show annotated file Show diff for this revision Revisions of this file
example1.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MODSERIAL.h	Fri Jul 12 15:56:20 2013 +0000
+++ b/MODSERIAL.h	Tue Jul 16 14:00:58 2013 +0000
@@ -43,6 +43,8 @@
 
 #include "mbed.h"
 #include "serial_api.h"
+//#include <cstdarg>
+
 
 namespace AjK {
 
@@ -729,19 +731,56 @@
         return move(s, max, auto_detect_char);
     }
     
-    #if 0 // Inhereted from Serial/Stream, for documentation only
-    /**
+     /**
      * Function: putc
      * 
      * Write a character
-     * Inhereted from Serial/Stream
      *
      * @see http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.putc
      * @ingroup API
      * @param c The character to write to the serial port
      */
-    int putc(int c);
-    #endif
+    int putc(int c) {
+        _putc(c);
+        return c;
+        }
+
+    /**
+     * Function: puts
+     * 
+     * Write a string
+     *
+     * @ingroup API
+     * @param s The string to write to the serial port
+     */
+     int puts(char *string) {
+        int i = 0;
+        while (string[i]!='\0') {
+            putc(string[i]);
+            i++;
+            }
+        return 1;
+     }
+     
+     /**
+     * Function: printf
+     * 
+     * Write a formatted string
+     *
+     * @ingroup API
+     * @param ---
+     *
+     int printf(const char* format, ...) {
+        std::va_list arg;
+        va_start(arg, format);
+        char buffer[30];
+        int r = snprintf(buffer, 30, format, arg);
+        va_end(arg);
+        puts(buffer);
+        return r;
+
+     }
+*/
     
     #if 0 // Inhereted from Serial/Stream, for documentation only
     /**
--- a/example1.cpp	Fri Jul 12 15:56:20 2013 +0000
+++ b/example1.cpp	Tue Jul 16 14:00:58 2013 +0000
@@ -41,11 +41,12 @@
 void txEmpty(MODSERIAL_IRQ_INFO *q) {
     led2 = 0;
     pc.puts(" Done. ");
-}
+    }
 
 // This function is called when a character goes into the RX buffer.
 void rxCallback(MODSERIAL_IRQ_INFO *q) {
     led3 = !led3;
+    //pc.putc('A');
     pc.putc(uart.getc());
 }