Buffered Serial Port Driver for RTOS tested with a K64F

Dependents:   JRO_CR2 frdm_test JRO_DDSv2 JRO_DDSv2_rev2019

Fork of SerialDriver by BlazeX .

Files at this revision

API Documentation at this revision

Comitter:
miguelcordero191
Date:
Tue Feb 10 14:29:32 2015 +0000
Parent:
4:3956012cd0c4
Commit message:
This library just was modified when a K64F is used

Changed in this revision

SerialDriver.cpp Show annotated file Show diff for this revision Revisions of this file
SerialDriver.h Show annotated file Show diff for this revision Revisions of this file
diff -r 3956012cd0c4 -r ee58295c58e1 SerialDriver.cpp
--- a/SerialDriver.cpp	Thu Feb 05 19:03:30 2015 +0000
+++ b/SerialDriver.cpp	Tue Feb 10 14:29:32 2015 +0000
@@ -41,26 +41,12 @@
     
     // attach interrupt routines
     attach(this, &SerialDriver::onRxIrq, RxIrq);
-    //attach(this, &SerialDriver::onTxIrq, TxIrq);
+    #if !defined(TARGET_K64F)
+        attach(this, &SerialDriver::onTxIrq, TxIrq);
+    #endif
 }
 
-int SerialDriver::putc(int c, unsigned int timeoutMs)
-{
-    
-    while(!SerialBase::writeable())
-    {//wait until character had been sent
-        Thread::wait(1);
-    }
-    
-    if(SerialBase::writeable())
-    {
-        // take byte from tx buffer and put it out
-        SerialBase::_base_putc(c);
-    }
-    
-    return 1;
-}
-/*
+#if !defined(TARGET_K64F)
 int SerialDriver::putc(int c, unsigned int timeoutMs)
 {
     // critical section, isr could modify cursors
@@ -97,7 +83,25 @@
     
     return 1;
 }
-*/
+#else
+int SerialDriver::putc(int c, unsigned int timeoutMs)
+{
+    
+    while(!SerialBase::writeable())
+    {//wait until character had been sent
+        Thread::wait(1);
+    }
+    
+    if(SerialBase::writeable())
+    {
+        // take byte from tx buffer and put it out
+        SerialBase::_base_putc(c);
+    }
+    
+    return 1;
+}
+#endif
+
 void SerialDriver::onTxIrq()
 {
     // prevent fire another TxIrq now
diff -r 3956012cd0c4 -r ee58295c58e1 SerialDriver.h
--- a/SerialDriver.h	Thu Feb 05 19:03:30 2015 +0000
+++ b/SerialDriver.h	Tue Feb 10 14:29:32 2015 +0000
@@ -13,6 +13,9 @@
 /// @see https://developer.mbed.org/users/mbed_official/code/mbed-rtos/
 /// @see https://developer.mbed.org/users/mbed_official/code/mbed/
 
+#ifndef        SERIAL_DRIVER
+#define        SERIAL_DRIVER
+
 #pragma once
 
 #include "mbed.h"
@@ -173,7 +176,6 @@
     /// @return true - RX buffer is readable, false - else
     inline bool readable()      {   return !isRxBufferEmpty();   }
     
-    
     /// @brief Returns number of dropped bytes that did not fit into TX buffer
     /// @return number of dropped tx bytes
     inline int getNumTxDrops()  {   return numTxDrops;  }
@@ -182,3 +184,5 @@
     /// @return number of dropped rx bytes
     inline int getNumRxDrops()  {   return numRxDrops;  }
 };
+
+#endif    //  #ifndef  SERIAL_DRIVER
\ No newline at end of file