CQ出版 Interface 2014年10月号のC027(MAX7-Q)GPSテスト記事のプログラム。 CQ publishing Interface 2014.10 issue, C027 GPS(MAX-7Q) test program.

Dependencies:   C027 C027_Support mbed

Revision:
3:002503ab7199
Parent:
2:bc413454a83e
--- a/C027_Support/SerialPipe.cpp	Mon Jul 28 15:45:16 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#pragma once 
-
-#include "SerialPipe.h"
-
-SerialPipe::SerialPipe(PinName tx, PinName rx, int rxSize, int txSize) 
-    : _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
-int SerialPipe::writeable(void)    
-{
-    return _pipeTx.free();
-}
-
-int SerialPipe::putc(int c)    
-{
-    c = _pipeTx.putc(c);
-    txStart();
-    return c;
-}
-
-int SerialPipe::put(const void* buffer, int length, bool blocking)    
-{ 
-    int count = length;
-    const char* ptr = (const char*)buffer;
-    if (count)
-    {
-        do
-        {
-            int written = _pipeTx.put(ptr, count, false);
-            ptr += written;
-            count -= written;
-            txStart();
-        }
-        while (count && blocking);
-    }
-    return (length - count);
-}
-
-void SerialPipe::txIrqBuf(void)
-{
-    while (_SerialPipeBase::writeable() && _pipeTx.readable())
-    {
-        char c = _pipeTx.getc();
-        _SerialPipeBase::_base_putc(c);
-    }
-}
-
-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
-}
-
-// rx channel
-int SerialPipe::readable(void)                      
-{ 
-    return _pipeRx.readable(); 
-} 
-
-int SerialPipe::getc(void)                          
-{ 
-    if (!_pipeRx.readable())
-        return EOF;
-    return _pipeRx.getc(); 
-} 
-
-int SerialPipe::get(void* buffer, int length, bool blocking) 
-{ 
-    return _pipeRx.get((char*)buffer,length,blocking); 
-}
-
-void SerialPipe::rxIrqBuf(void)
-{
-    while (_SerialPipeBase::readable())
-    {
-        char c = _SerialPipeBase::_base_getc();
-        if (_pipeRx.writeable())
-            _pipeRx.putc(c);
-        else 
-            /* overflow */;
-    }
-}
-