Dependencies: ChaNFSSD mbed BMP085 SHT2x
tserialbuffer.h
00001 /* 00002 * Copyright (c) 2011 Toshihisa T 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 00006 #ifndef __TSERIALBUFFER_H 00007 #define __TSERIALBUFFER_H 00008 00009 #include "mbed.h" 00010 #include "tringbuffer.h" 00011 #include "tversion.h" 00012 00013 namespace libT { 00014 00015 class tSerialBuffer : public tRingBuffer<unsigned char> , public Serial , public tVersion { 00016 00017 public: 00018 tSerialBuffer(PinName _tx, PinName _rx) : Serial(_tx,_rx) , tVersion(0x20100720/* 2010-07-20 */,0x00000001UL){} 00019 00020 void recvStart(void){ 00021 Serial::attach(this,&tSerialBuffer::recvHandler,Serial::RxIrq); 00022 } 00023 void recvStop(void){ 00024 Serial::attach(0,Serial::RxIrq); 00025 } 00026 00027 int readable(void){ 00028 return tRingBuffer::readable(); 00029 } 00030 00031 int getc(void){ 00032 unsigned char _c; 00033 int retval = -1; 00034 if(tRingBuffer::readable()){ 00035 (void)tRingBuffer::read(&_c); 00036 retval = static_cast<int>(_c); 00037 } 00038 return retval; 00039 } 00040 00041 private: 00042 void recvHandler(void){ 00043 if(Serial::readable()){ 00044 tRingBuffer::write(static_cast<unsigned char>(Serial::getc())); 00045 } 00046 } 00047 00048 }; 00049 00050 }; 00051 00052 #endif /* __TSERIALBUFFER_H */ 00053
Generated on Thu Jul 14 2022 16:50:44 by 1.7.2