00001 /*************************************************************************** 00002 LOW_linkPassiveSerial.h - description 00003 ------------------- 00004 begin : Sun Jul 7 2002 00005 copyright : (C) 2002 by Harald Roelle, Helmut Reiser 00006 email : roelle@informatik.uni-muenchen.de, reiser@informatik.uni-muenchen.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef LOW_LINKPASSIVESERIAL_H 00019 #define LOW_LINKPASSIVESERIAL_H 00020 00021 00022 #include "LOW_types.h" 00023 #include "LOW_link.h" 00024 #include "LOW_exception.h" 00025 #include "LOW_portSerial.h" 00026 00027 00028 00029 /** Link class for simple passive serial 1-Wire adapters. 00030 00031 As the passive adapter is not capable of real strong pullups with high current, 00032 it is emulated by providing high level on the bus for a relatively long time. 00033 00034 @author Harald Roelle, Helmut Reiser 00035 */ 00036 class LOW_linkPassiveSerial : public LOW_link { 00037 00038 //======================================================================================= 00039 public: 00040 00041 //===================================================================================== 00042 // 00043 // constructors 00044 // 00045 00046 /** Constructor. 00047 00048 @param inSerPortSpec Specification of serial port the adapter is on. 00049 @param inAllowProgPulse Wether the program pulse should be allowed. 00050 */ 00051 LOW_linkPassiveSerial( const LOW_portSerialFactory::portSpecifier_t &inSerPortSpec, 00052 const bool inAllowProgPulse = false); 00053 00054 /** Destructor. 00055 */ 00056 ~LOW_linkPassiveSerial(); 00057 00058 00059 //===================================================================================== 00060 // 00061 // Standard methods required by LOW_Link 00062 // 00063 00064 //! @name Bus touch (write/read) methods required by LOW_Link 00065 //!@{ 00066 bool touchBit( const bool inSendBit, const strongPullup_t inPullup = pullUp_NONE); 00067 uint8_t touchByte( const uint8_t inSendByte, const strongPullup_t inPullup = pullUp_NONE); 00068 byteVec_t touchBlock( const byteVec_t &inBytes, const strongPullup_t inPullup = pullUp_NONE); 00069 //!@} 00070 00071 //! @name Bus read methods required by LOW_Link 00072 //!@{ 00073 bool readDataBit( const strongPullup_t inPullup = pullUp_NONE); 00074 uint8_t readDataByte( const strongPullup_t inPullup = pullUp_NONE); 00075 void readData( byteVec_t &outBytes, const strongPullup_t inPullup = pullUp_NONE); 00076 //!@} 00077 00078 //! @name Bus write methods required by LOW_Link 00079 //!@{ 00080 void writeData( const bool inSendBit, const strongPullup_t inPullup = pullUp_NONE); 00081 void writeData( const uint8_t inSendByte, const strongPullup_t inPullup = pullUp_NONE); 00082 void writeData( const byteVec_t &inSendBytes, const strongPullup_t inPullup = pullUp_NONE); 00083 //!@} 00084 00085 //! @name Misc methods required by LOW_Link 00086 //!@{ 00087 void resetLinkAdapter(); 00088 bool resetBus(); 00089 void strongPullup( const unsigned long inMicroSecs); 00090 void programPulse(); 00091 void doSearchSequence( const LOW_deviceIDRaw &inBranchVector, 00092 LOW_deviceIDRaw &outFoundID, LOW_deviceIDRaw &outDiscrVec); 00093 //!@} 00094 00095 00096 //======================================================================================= 00097 private: 00098 00099 //===================================================================================== 00100 // 00101 // constants 00102 // 00103 00104 /** Time to wait for emulation of strong pullup in seconds. */ 00105 static const int strongPullupEmuTime = 3; 00106 00107 00108 //===================================================================================== 00109 // 00110 // attributes 00111 // 00112 00113 LOW_portSerial *serialPort; /**< The serial port the adapter is attached to. */ 00114 00115 00116 //===================================================================================== 00117 // 00118 // methods 00119 // 00120 00121 /** Set the 1-Wire net line level to strong pullup for a specified time. 00122 Adapter for time specification in strongPullup_t. 00123 @param inPullup Pullup time. 00124 */ 00125 void strongPullup( const strongPullup_t inPullup); 00126 00127 }; 00128 00129 #endif