00001 /*************************************************************************** 00002 LOW_devDS2405.h - description 00003 ------------------- 00004 begin : Tue Aug 20 2002 00005 copyright : (C) 2002 by Harald Roelle 00006 email : roelle@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_DEVDS2405_H 00019 #define LOW_DEVDS2405_H 00020 00021 00022 00023 #include "LOW_device.h" 00024 #include "LOW_helper_crc.h" 00025 00026 00027 00028 /** Device class for DS2405 Addressable Switch. 00029 00030 DS2405 features: 00031 00032 - Open-drain PIO pin is controlled by matching 64-bit, laser-engraved registration number 00033 associated with each device 00034 - Logic level of open drain output can be determined over 1-Wire bus for closed-loop control 00035 - PIO pin sink capability is greater than 4mA at 0.4V 00036 - Multiple DS2405s can be identified on a common 1-Wire bus and be turned on or off independent 00037 of other devices on the bus 00038 - Unique, factory-lasered and tested 64-bit registration number (8-bit family code +48- bit serial 00039 number +8-bit CRC tester) assures absolute identity because no two parts are alike 00040 - Built-in multidrop controller ensures compatibility with other MicroLAN products 00041 - Reduces control, address, data, and power to a single data pin 00042 - Directly connects to a single port pin of a microprocessor and communicates at up to 16.3kbits/s 00043 - 8-bit family code specifies DS2405 communications requirements to reader 00044 - 8-bit cyclic redundancy check ensures errorfree selection 00045 - Zero standby power required 00046 - Low cost TO-92, SOT-223, or 6-pin TSOC surface mount package 00047 - 1-Wire communication operates over a wide voltage range of 2.8V to 6.0V from -40°C to +85°C 00048 00049 This class is thread-safe. 00050 00051 @author Harald Roelle 00052 @author Parts of the documentation by Dallas Semiconductors / Maxim Integrated Products 00053 */ 00054 class LOW_devDS2405 : public LOW_device { 00055 00056 //======================================================================================= 00057 public: 00058 00059 //===================================================================================== 00060 // 00061 // exceptions 00062 // 00063 00064 /** Exception base class for all exceptions thrown by LOW_devDS2405. */ 00065 class_DERIVE_FROM_EXCEPTION( devDS2405_error, LOW_exception); 00066 00067 00068 00069 //===================================================================================== 00070 // 00071 // constants 00072 // 00073 00074 /** Family code of this specific device. */ 00075 static const LOW_deviceIDRaw::devFamCode_t familyCode = 0x05; 00076 00077 /** Family name of this specific device. */ 00078 static const std::string familyName; 00079 00080 00081 //===================================================================================== 00082 // 00083 // type definitions 00084 // 00085 00086 typedef std::vector<LOW_devDS2405*> devDS2405PtrVec_t; /**< Vector type of class device pointers. */ 00087 00088 00089 //===================================================================================== 00090 // 00091 // constructors 00092 // 00093 00094 /** Real constructor corresponding to static pseudo constructor new_Instance(). 00095 @param inSegment Reference to network segment the device is on. 00096 @param inDevID Reference to device's ID. 00097 */ 00098 LOW_devDS2405( LOW_netSegment &inSegment, const LOW_deviceID &inDevID); 00099 00100 /** Destructor. 00101 */ 00102 virtual ~LOW_devDS2405(); 00103 00104 00105 //===================================================================================== 00106 // 00107 // methods 00108 // 00109 00110 /** Get the device's family name. 00111 @return Family name of the device. 00112 */ 00113 virtual std::string getFamilyName() const { return familyName; }; 00114 00115 00116 /** Toggle the state of the PIO pin. 00117 */ 00118 virtual void cmd_Match() const; 00119 00120 00121 /** Toggle the state of the PIO pin and read its new state. 00122 00123 <B>Note:</B> The return value is <B>inverted</B> compared to @ref cmd_SearchActive(). 00124 00125 @return false, if the device IS driving the PIO pin low. 00126 true, if the device is NOT driving the PIO pin low. 00127 */ 00128 virtual bool cmd_MatchRead() const; 00129 00130 00131 /** Read the logic state of the PIO pin (input). 00132 00133 The device will not toggle the state of its PIO pin. 00134 The combination of Match ROM and Search ROM allows the user to change the state 00135 of the PIO pin and report the current state (Match ROM) or simply report the 00136 current state of the PIO pin without changing it (Search ROM). 00137 00138 @return false, if the pulldown is on, 00139 or the pulldown is off and the PIO pin is a logical 0.<BR> 00140 true, if the pulldown is off and the PIO pin is a logical 1 (i.e. external pullup). 00141 */ 00142 virtual bool cmd_SearchRead() const; 00143 00144 00145 /** Read if the output pulldown is turned on. 00146 00147 The device will not toggle the state of its PIO pin. 00148 00149 <B>Note:</B> The return value is <B>inverted</B> compared to @ref cmd_MatchActive(). 00150 00151 @return false, if the device is NOT driving the PIO pin low. 00152 true, if the device IS driving the PIO pin low. 00153 00154 */ 00155 virtual bool cmd_SearchActive() const; 00156 00157 00158 00159 //======================================================================================= 00160 protected: 00161 00162 //===================================================================================== 00163 // 00164 // static methods 00165 // 00166 00167 /** Static pseudo constructor for registering with LOW_deviceFactory. 00168 @param inSegment Reference to network segment the device is on. 00169 @param inDevID Reference to device's ID. 00170 @return New dynamic instance of specific device class. 00171 */ 00172 static LOW_device* new_Instance( LOW_netSegment &inNetSegment, const LOW_deviceID &inDevID); 00173 00174 00175 00176 //======================================================================================= 00177 private: 00178 00179 //===================================================================================== 00180 // 00181 // static initializer 00182 // 00183 00184 /** Needed for dirty little C++ hack to force static initialization on application start. 00185 @see initialize() 00186 */ 00187 static int initHelper; 00188 00189 /** Static inizializer to register the class with LOW_deviceFactory. 00190 @see initHelper 00191 */ 00192 static int initialize(); 00193 00194 }; 00195 00196 #endif