IM920地温観測システム用 cbUSB()関数定義だけ修正したもの

Fork of C027_Support by u-blox

Revision:
70:0a87d256cd24
Parent:
45:ebc2fd8dcf21
Child:
74:208e3e32d263
--- a/SerialPipe.cpp	Wed May 14 05:54:37 2014 +0000
+++ b/SerialPipe.cpp	Wed May 14 09:12:47 2014 +0000
@@ -6,18 +6,12 @@
     : _SerialPipeBase(tx,rx), _pipeRx(rxSize), _pipeTx(txSize)
 {
     attach(this, &SerialPipe::rxIrqBuf, RxIrq);
-#if defined(TARGET_UBLOX_C027) || defined(TARGET_LPC1768)
-    // the lpc1768 supports interrupt driven tx
-    attach(this, &SerialPipe::txIrqBuf, TxIrq);
-#endif
 }
 
 SerialPipe::~SerialPipe(void)
 {
     attach(NULL, RxIrq);
-#if defined(TARGET_UBLOX_C027) || defined(TARGET_LPC1768)
     attach(NULL, TxIrq);
-#endif
 }
 
 // tx channel
@@ -51,7 +45,7 @@
     return (length - count);
 }
 
-void SerialPipe::txIrqBuf(void)
+void SerialPipe::txCopy(void)
 {
     while (_SerialPipeBase::writeable() && _pipeTx.readable())
     {
@@ -60,21 +54,22 @@
     }
 }
 
+void SerialPipe::txIrqBuf(void)
+{
+    txCopy();
+    // detach tx isr if we are done 
+    if (!_pipeTx.readable())
+        attach(NULL, TxIrq);
+}
+
 void SerialPipe::txStart(void)
 {
-#if defined(TARGET_UBLOX_C027) || defined(TARGET_LPC1768)
-    __disable_irq();
-    txIrqBuf();
-    __enable_irq();
-#else
-    while (_pipeTx.readable())
-    {
-        char c = _pipeTx.getc();
-        while (!_SerialPipeBase::writeable())
-            /*wait*/;
-        _SerialPipeBase::_base_putc(c);
-    }
-#endif
+    // disable the tx isr to avoid interruption
+    attach(NULL, TxIrq);
+    txCopy();
+    // attach the tx isr to handle the remaining data
+    if (_pipeTx.readable())
+        attach(this, &SerialPipe::txIrqBuf, TxIrq);
 }
 
 // rx channel