Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

LOW_linkDS2490.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_linkDS2490.h  -  description
00003                              -------------------
00004     begin                : Sun Oct 12 2003
00005     copyright            : (C) 2003 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_LINKDS2490_H
00019 #define LOW_LINKDS2490_H
00020 
00021 
00022 #include "LOW_link.h"
00023 #include "LOW_linkFlexibleSpeed.h"
00024 #include "LOW_portUsb_Factory.h"
00025 
00026 
00027 /** Link class for DS2490 USB to 1-Wire Bridge Chip.
00028 
00029     DS2490 features:
00030 
00031       - Communicates at regular and overdrive 1- Wire® speeds
00032       - Supports 12V EPROM programming and stiff 5V pullup for EEPROM, sensors, and crypto iButton
00033       - Slew rate controlled 1-Wire timing and active pullup to accommodate long
00034         1-Wire network lines and reduce radiation
00035       - Programmable 1-Wire timing and driver characteristics accommodate a wide range of 1-Wire
00036         network configurations
00037       - Low- to high-level command types, including macros, for generating 1-Wire communication
00038       - Crystal oscillator timebase provides precision timed 1-Wire waveforms
00039       - High-speed 12Mbps Universal Serial Bus (USB) interface
00040       - Integrated USB-compliant transceiver
00041       - Supports USB remote wake-up from a 1-Wire device event to resume a suspended host system
00042       - 0oC to +70oC operating temperature range
00043 
00044     The DS2490 is a bridge chip that enables communication between a USB host system and a 1-Wire bus.
00045     It provides regular, overdrive, and flexible 1-Wire communication speeds and a full-speed 12Mbps
00046     connection to USB. USB vendor-specific commands defined in this specification are used to control
00047     the DS2490 and communicate with attached 1-Wire devices.
00048 
00049     This class is thread-safe.
00050     
00051     @todo Provide assignment operator and copy constructor
00052     @todo Finish documentation
00053 
00054     @author  Harald Roelle
00055     @author  Parts of the documentation by Dallas Semiconductors / Maxim Integrated Products
00056  */
00057 class LOW_linkDS2490 : public LOW_link, public LOW_linkFlexibleSpeed {
00058 
00059 //=======================================================================================
00060 public:
00061 
00062   //=====================================================================================
00063   //
00064   // constants
00065   //
00066 
00067   static const LOW_portUsbDevice::usbVendorID_t   usbVendorID  = 0x04fa;        /**< Dallas/Maxim USB vendor ID. */
00068   static const LOW_portUsbDevice::usbProductID_t  usbProductID = 0x2490;        /**< Dallas/Maxim USB DS2490 product ID. */
00069 
00070 
00071   //=====================================================================================
00072   //
00073   // constructors
00074   //
00075 
00076   /** Constructor.
00077 
00078       Timings for flexible speed is configured to the recommeded optimal parameters
00079       as of app note #148.
00080 
00081       @param  inUsbDevSpec        USB device specifier of the DS2490.
00082       @param  inHasExternalPower  Whether the attached bus supplies external power.
00083       @param  inAllowProgPulse    Whether the program pulse should be allowed.
00084    */
00085   LOW_linkDS2490( const LOW_portUsb_Factory::usbDeviceSpecifier_t inUsbDevSpec,
00086                   const bool inHasExternalPower, const bool inAllowProgPulse = false);
00087 
00088                   
00089   /** Destructor.
00090    */
00091   virtual ~LOW_linkDS2490();
00092 
00093 
00094   //=====================================================================================
00095   //
00096   // Standard methods required by LOW_link
00097   //
00098 
00099   virtual std::string getLinkFamily() const { return "DS2490 USB link"; };
00100 
00101   //! @name Bus touch (write/read) methods required by LOW_link
00102   //!@{
00103   virtual bool touchBit( const bool inSendBit, const strongPullup_t inPullup = pullUp_NONE);
00104   virtual uint8_t touchByte( const uint8_t inSendByte, const strongPullup_t inPullup = pullUp_NONE);
00105   virtual byteVec_t touchBlock( const byteVec_t &inBytes, const strongPullup_t inPullup = pullUp_NONE);
00106   //!@}
00107 
00108   //! @name Higher level methods required by LOW_link
00109   //!@{
00110   virtual LOW_deviceID::deviceIDVec_t searchDevices( const bool inOnlyAlarm, const LOW_deviceIDRaw inPreload,
00111                                                      const LOW_deviceIDRaw::devFamCode_t inFamCode, const bool inDoReset);
00112   //!@}
00113 
00114   //! @name Misc methods required by LOW_link
00115   //!@{
00116   virtual void resetLinkAdapter();
00117   virtual bool resetBus();
00118   virtual void strongPullup( const unsigned long inMicroSecs);
00119   virtual void strongPullup( const strongPullup_t inPullupTime);
00120   virtual void programPulse( const unsigned long inMicroSecs);
00121   virtual void programPulse( const progPulse_t inPulseTime);
00122   //!@}
00123 
00124 
00125   //=====================================================================================
00126   //
00127   // Standard methods required by LOW_linkFlexibleSpeed
00128   //
00129 
00130   //! @name Methods required by LOW_linkFlexibleSpeed
00131   //!@{
00132   virtual void setWireSpeed( const wireSpeed_t inWireSpeed);
00133   virtual wireSpeed_t getWireSpeed();
00134   virtual void setPullDownSlewRate( const pdSlewRate_t inPDSR);
00135   virtual pdSlewRate_t getPullDownSlewRate();
00136   virtual void setWrite1LowTime( const w1LowTime_t inW1LT);
00137   virtual w1LowTime_t getWrite1LowTime();
00138   virtual void setSampleOffsetWrite0Rec( const soW0RecTime_t inSOW0RT);
00139   virtual soW0RecTime_t getSampleOffsetWrite0Rec();
00140   //!@}
00141 
00142 
00143 
00144 //=======================================================================================
00145 protected:
00146 
00147 
00148   //=====================================================================================
00149   //
00150   // Standard methods required by LOW_link
00151   //
00152 
00153   virtual void doSearchSequence( const LOW_deviceIDRaw &inBranchVector,
00154                                  LOW_deviceIDRaw &outFoundID, LOW_deviceIDRaw &outDiscrVec);
00155 
00156                                  
00157                                  
00158 //=======================================================================================
00159 private:
00160 
00161   //=====================================================================================
00162   //
00163   // constants
00164   //
00165 
00166   //! @name USB related constants.
00167   //!@{
00168   static const LOW_portUsbDevice::usbInterface_t  usbDefaultInterface = 0;      /**< Default and only USB interface of DS2490. */
00169   static const LOW_portUsbDevice::bmRequestType_t vendorCmd_requestType = 0x40; /**< Request type of DS2490 vendor specific commands. */
00170   //!@}
00171 
00172 
00173   //! @name USB timeout constants.
00174   //!@{
00175   static const LOW_portUsbDevice::usbTimeout_t   ctlCmd_usbTimeout  = 1000; /**< Timeout in ms for control commands. */
00176   static const LOW_portUsbDevice::usbTimeout_t   modCmd_usbTimeout  = 1000; /**< Timeout in ms for mode commands. */
00177   static const LOW_portUsbDevice::usbTimeout_t   comCmd_usbTimeout  = 1000; /**< Timeout in ms for communicaton commands. */
00178   //!@}
00179 
00180 
00181   //! @name USB interface alternate settings.
00182   //!@{
00183   static const LOW_portUsbDevice::usbSetting_t usbAltSetting_10_16 = 0; /**< poll interval EP2/EP3 = 10ms; max packet size = 16 bytes;
00184                                                                              Long interrupt polling interval, small packet size for bulk pipes. */
00185   static const LOW_portUsbDevice::usbSetting_t usbAltSetting_10_64 = 1; /**< poll interval EP2/EP3 = 10ms; max packet size = 64 bytes;
00186                                                                              Long interrupt polling interval, large packet size for bulk pipes. */
00187   static const LOW_portUsbDevice::usbSetting_t usbAltSetting_1_16  = 2; /**< poll interval EP2/EP3 =  1ms; max packet size = 16 bytes;
00188                                                                              Short interrupt polling interval, small packet size for bulk pipes. */
00189   static const LOW_portUsbDevice::usbSetting_t usbAltSetting_1_64  = 3; /**< poll interval EP2/EP3 =  1ms; max packet size = 64 bytes;
00190                                                                              Short interrupt polling interval, large packet size for bulk pipes. */
00191   //!@}
00192 
00193   
00194   //! @name USB endpoints.
00195   //!@{
00196   /** Endpoint for the bi-directional default control pipe. It is used for the USB enumeration process,
00197       USB core request communication, and all DS2490 specific command communication.
00198    */ 
00199   static const LOW_portUsbDevice::usbEndpoint_t usbControlEP  = 0;
00200   /** Endpoint for an interrupt pipe (device to host) and is used to relay DS2490 status register data and
00201       specific command execution completion and/or error information to the host. It is also used to inform
00202       the host of 1-Wire device-attach detection. The polling period requested for EP1 depends on the
00203       alternate interface setting of the 1-Wire interface.
00204    */
00205   static const LOW_portUsbDevice::usbEndpoint_t usbStatusInEP = 1;
00206   /** Endpoint for a bulk data out pipe (data from host) and is used to transmit 1-Wire device data from the
00207       host to the DS2490. The information received at this endpoint will be transmitted as data on the 1-Wire bus.
00208    */
00209   static const LOW_portUsbDevice::usbEndpoint_t usbDataOutEP  = 2;
00210   /** FIFO size in bytes of endpoint usbDataOutEP.
00211    */
00212   static const unsigned int usbDataOutEP_FIFOsize             = 128;
00213   /** Endpoint for a bulk data in pipe (data to host) and is used to send data received by the DS2490 from
00214       the 1-Wire bus back to the host for processing.
00215    */
00216   static const LOW_portUsbDevice::usbEndpoint_t usbDataInEP   = 3;
00217   /** FIFO size in bytes of endpoint usbDataOutEP.
00218    */
00219   static const unsigned int usbDataInEP_FIFOsize              = 128;
00220   //!@}
00221 
00222 
00223   /** @name Command types.
00224       Three different vendor-specific command types exist to control and communicate with the DS2490:
00225       
00226         - Control commands are used to manage various device functions including the processing of
00227           communication commands, buffer clearing, and SW reset.
00228 
00229         - Communication commands are used for 1-Wire data and command I/O.
00230 
00231         - Mode commands are used to establish the 1-Wire operational characteristics of the DS2490
00232           such as slew rate, low time, strong pullup, etc.
00233 
00234       Control, Communication and Mode commands, like USB core requests, are communicated over the
00235       default control pipe at EP0.
00236    */
00237   //!@{
00238   static const LOW_portUsbDevice::bRequest_t control_cmdType = 0x00; //**< 1-Wire interface control commands. */
00239   static const LOW_portUsbDevice::bRequest_t comm_cmdType    = 0x01; //**< 1-Wire interface communication commands. */
00240   static const LOW_portUsbDevice::bRequest_t mode_cmdType    = 0x02; //**< 1-Wire interface operational mode commands. */
00241   //!@}
00242 
00243   
00244   //! @name Control commands.
00245   //!@{
00246   static const LOW_portUsbDevice::wValue_t resetDevice_ctlCmd    = 0x0000;  /**< Control command. */
00247   static const LOW_portUsbDevice::wValue_t startExe_ctlCmd       = 0x0001;  /**< Control command. */
00248   static const LOW_portUsbDevice::wValue_t resumeExe_ctlCmd      = 0x0002;  /**< Control command. */
00249   static const LOW_portUsbDevice::wValue_t haltExeIdle_ctlCmd    = 0x0003;  /**< Control command. */
00250   static const LOW_portUsbDevice::wValue_t haltExeDone_ctlCmd    = 0x0004;  /**< Control command. */
00251   static const LOW_portUsbDevice::wValue_t flushCommCmds_ctlCmd  = 0x0007;  /**< Control command. */
00252   static const LOW_portUsbDevice::wValue_t flushRcvBuffer_ctlCmd = 0x0008;  /**< Control command. */
00253   static const LOW_portUsbDevice::wValue_t flushXmtBuffer_ctlCmd = 0x0009;  /**< Control command. */
00254   static const LOW_portUsbDevice::wValue_t getCommCmds_ctlCmd    = 0x000A;  /**< Control command. */
00255   //!@}
00256 
00257   //! @name Mode commands.
00258   //!@{
00259   static const LOW_portUsbDevice::wValue_t pulseEn_modCmd            = 0x0000;  /**< Mode command. */
00260   static const LOW_portUsbDevice::wValue_t speedChangeEn_modCmd      = 0x0001;  /**< Mode command. */
00261   static const LOW_portUsbDevice::wValue_t oneWireSpeed_modCmd       = 0x0002;  /**< Mode command. */
00262   static const LOW_portUsbDevice::wValue_t strongPuDuration_modCmd   = 0x0003;  /**< Mode command. */
00263   static const LOW_portUsbDevice::wValue_t pulldownSlewRate_modCmd   = 0x0004;  /**< Mode command. */
00264   static const LOW_portUsbDevice::wValue_t progPulseDuration_modCmd  = 0x0005;  /**< Mode command. */
00265   static const LOW_portUsbDevice::wValue_t write1LowTime_modCmd      = 0x0006;  /**< Mode command. */
00266   static const LOW_portUsbDevice::wValue_t dsow0Trec_modCmd          = 0x0007;  /**< Mode command. */
00267   //!@}
00268 
00269   //! @name Base for communication commands.
00270   //!@{
00271   static const LOW_portUsbDevice::wValue_t setDuration_comCmdBase         = 0x0012;  /**< Communication command. */
00272   static const LOW_portUsbDevice::wValue_t pulse_comCmdBase               = 0x0030;  /**< Communication command. */
00273   static const LOW_portUsbDevice::wValue_t oneWireReset_comCmdBase        = 0x0042;  /**< Communication command. */
00274   static const LOW_portUsbDevice::wValue_t bitIO_comCmdBase               = 0x0020;  /**< Communication command. */
00275   static const LOW_portUsbDevice::wValue_t byteIO_comCmdBase              = 0x0052;  /**< Communication command. */
00276   static const LOW_portUsbDevice::wValue_t blockIO_comCmdBase             = 0x0074;  /**< Communication command. */
00277   static const LOW_portUsbDevice::wValue_t matchAccess_comCmdBase         = 0x0064;  /**< Communication command. */
00278   static const LOW_portUsbDevice::wValue_t readStraight_comCmdBase        = 0x0080;  /**< Communication command. */
00279   static const LOW_portUsbDevice::wValue_t doAndRelease_comCmdBase        = 0x6092;  /**< Communication command. */
00280   static const LOW_portUsbDevice::wValue_t setPath_comCmdBase             = 0x00a2;  /**< Communication command. */
00281   static const LOW_portUsbDevice::wValue_t writeSramPage_comCmdBase       = 0x00b2;  /**< Communication command. */
00282   static const LOW_portUsbDevice::wValue_t writeEprom_comCmdBase          = 0x00c4;  /**< Communication command. */
00283   static const LOW_portUsbDevice::wValue_t readCrcProtPage_comCmdBase     = 0x00d4;  /**< Communication command. */
00284   static const LOW_portUsbDevice::wValue_t readRedirectPageCrc_comCmdBase = 0x21e4;  /**< Communication command. */
00285   static const LOW_portUsbDevice::wValue_t searchAccess_comCmdBase        = 0x00f4;  /**< Communication command. */
00286   //!@}
00287 
00288   
00289   //! @name Communication command bitmasks.
00290   //!@{
00291 
00292   /** RTS = 1 returns the discrepancy information to the host if SM = 1 and there are more devices than could
00293               be discovered in the current pass.
00294       RTS = 0 does not return discrepancy information.
00295    */
00296   static const LOW_portUsbDevice::wValue_t RTS_bitmask   = 0x4000;
00297 
00298   /** CIB = 1 prevents a strong pullup to 5V if SPU = 1 and the bit read back from the 1- Wire bus is 1.
00299       CIB = 0 generally enables the strong pullup to 5V.
00300    */
00301   static const LOW_portUsbDevice::wValue_t CIB_bitmask   = 0x4000;
00302 
00303   /** PST = 1 continuously generate 1-Wire Reset sequences until a presence pulse is discovered.
00304       PST = 0 generate only one 1-Wire Reset sequence.
00305    */
00306   static const LOW_portUsbDevice::wValue_t PST_bitmask   = 0x4000;
00307 
00308   /** PS = 1 reduces the preamble size to 2 bytes (rather than 3).
00309       PS = 0 sets preamble size to 3 bytes.
00310    */
00311   static const LOW_portUsbDevice::wValue_t PS_bitmask    = 0x4000;
00312 
00313   /** DT = 1 activates/selects the CRC16 generator.
00314       DT = 0 specifies no CRC.
00315    */
00316   static const LOW_portUsbDevice::wValue_t DT_bitmask    = 0x2000;
00317 
00318   /** SPU = 1 inserts a strong pullup to 5V after a Bit or Byte or Block I/O or Do & Release command.
00319       SPU = 0 no strong pullup.
00320    */
00321   static const LOW_portUsbDevice::wValue_t SPU_bitmask   = 0x1000;
00322 
00323   /** F = 1 clears the buffers in case an error occurred during the execution of the previous command;
00324             requires that ICP = 0 in the previous command.
00325       F = 0 prevents the buffers from being cleared.
00326    */
00327   static const LOW_portUsbDevice::wValue_t F_bitmask     = 0x0800;
00328 
00329   /** NTF = 1 always generate communication command processing result feedback if ICP = 0
00330       NTF = 0 generate communication command processing result feedback only if an error occurs
00331               and ICP = 0. If ICP = 1 command result feedback is suppressed for either case,
00332               see the ICP bit above.
00333    */
00334   static const LOW_portUsbDevice::wValue_t NTF_bitmask   = 0x0400;
00335 
00336   /** ICP = 1 indicates that the command is not the last one of a macro; as a consequence command processing
00337               result feedback messages are suppressed.
00338       ICP = 0 indicates that the command is the last one of a macro or single command operation;
00339               enables command processing result feedback signaling.
00340    */
00341   static const LOW_portUsbDevice::wValue_t ICP_bitmask   = 0x0200;
00342 
00343   /** RST = 1 inserts a 1-Wire Reset before executing the command.
00344       RST = 0 no 1-Wire Reset inserted.
00345    */
00346   static const LOW_portUsbDevice::wValue_t RST_bitmask   = 0x0100;
00347 
00348   /** SE = 1 enable the speed change on the 1-Wire bus.
00349       SE = 0 disable the speed change on the 1-Wire bus.
00350    */
00351   static const LOW_portUsbDevice::wValue_t SE_bitmask    = 0x0008; 
00352 
00353   /** R = 1 performs a read function.
00354       R = 0 performs a write function.
00355    */
00356   static const LOW_portUsbDevice::wValue_t R_bitmask     = 0x0008;
00357 
00358   /** Z = 1 checks if the 0-bits in the byte to be written are 0-bits in the byte read back form the device.
00359       Z = 0 checks if the byte to be written is identical to the one read back from the device.
00360    */
00361   static const LOW_portUsbDevice::wValue_t Z_bitmask     = 0x0008;
00362 
00363   /** SM = 1 searches for and reports ROM Ids without really accessing a particular device.
00364       SM = 0 makes a  Strong Access  to a particular device.
00365    */
00366   static const LOW_portUsbDevice::wValue_t SM_bitmask    = 0x0008;
00367 
00368   /** CH = 1 follows the chain if the page is redirected.
00369       CH = 0 stops reading if the page is redirected.
00370    */
00371   static const LOW_portUsbDevice::wValue_t CH_bitmask    = 0x0008;
00372 
00373   /** D       Data bit value to be written to the 1-Wire bus.
00374    */
00375   static const LOW_portUsbDevice::wValue_t D_bitmask     = 0x0008;
00376 
00377   /** TYPE = 1 specifies programming pulse duration.
00378       TYPE = 0 specifies strong pullup duration.
00379    */
00380   static const LOW_portUsbDevice::wValue_t TYPE_bitmask  = 0x0008;
00381 
00382   /** IM = 1 enables immediate execution of the command. Assumes that all 1-Wire device data required by the
00383              command has been received at EP2.
00384       IM = 0 prevents immediate execution of the command; execution must be started through a
00385              control function command.
00386    */
00387   static const LOW_portUsbDevice::wValue_t IM_bitmask    = 0x0001;
00388   //!@}
00389 
00390   
00391   //! @name State register enable bitmasks.
00392   //!@{
00393   /** SPUE If set to 1, the strong pullup to 5V is enabled, if set to 0, it is disabled.
00394    */
00395   static const uint8_t SPUE_bitmask = 0x01;
00396   /** PRGE If set to 1, a 12V programming pulse is enabled, if set to 0, it is disabled.
00397    */
00398   static const uint8_t PRGE_bitmask = 0x02;
00399   /** SPCE If set to 1, a dynamic 1-Wire bus speed change through a Communication
00400            command is enabled, if set to 0, it is disabled.
00401    */
00402   static const uint8_t SPCE_bitmask = 0x04;
00403   //!@}
00404 
00405   
00406   //! @name State register device status bitmasks.
00407   //!@{
00408   /** SPUA if set to 1, the strong pullup to 5V is currently active, if set to 0, it is inactive.
00409    */
00410   static const uint8_t SPUA_bitmask = 0x01;
00411   /** PRGA if set to 1, a 12V programming pulse is currently being generated, if set to 0, it is not.
00412    */
00413   static const uint8_t PRGA_bitmask = 0x02;
00414   /** 12VP if set to 1, the external 12V programming voltage is present, if set to 0, it is not present.
00415    */
00416   static const uint8_t VP12_bitmask = 0x04;
00417   /** PMOD if set to 1, the DS2490 is powered from USB and external sources,
00418            if set to 0, all DS2490 power is provided from USB.
00419    */
00420   static const uint8_t PMOD_bitmask = 0x08;
00421   /** HALT if set to 1, the DS2490 is currently halted, if set to 0, the device is not halted.
00422    */
00423   static const uint8_t HALT_bitmask = 0x10;
00424   /** IDLE if set to 1, the DS2490 is currently idle, if set to 0, the device is not idle.
00425    */
00426   static const uint8_t IDLE_bitmask = 0x20;
00427   /** EPOF  Endpoint 0 FIFO status, see Note 1.
00428    */
00429   static const uint8_t EP0F_bitmask = 0x80;
00430   //!@}
00431 
00432   
00433   //! @name Communication command error bitmasks.
00434   //!@{
00435 
00436   /** 1-Wire Device Detect Byte
00437    */
00438   static const uint8_t devDetect_code = 0xa5;
00439 
00440   /** EOS A value of 1 indicates that a SEARCH ACCESS with SM = 1 ended sooner than expected
00441           reporting less ROM ID s than specified in the  number of devices  parameter.
00442    */
00443   static const uint8_t EOS_bitmask = 0x80;
00444 
00445   /** RDP A value of 1 indicates that a READ REDIRECT PAGE WITH/CRC encountered a page that is redirected.
00446    */
00447   static const uint8_t RDP_bitmask = 0x40;
00448 
00449   /** CRC A value of 1 indicates that a CRC error occurred when executing one of the following
00450          commands: WRITE SRAM PAGE, WRITE EPROM, READ CRC PROT PAGE, or READ REDIRECT PAGE W/CRC.
00451    */
00452   static const uint8_t CRC_bitmask = 0x20;
00453 
00454   /** CMP A value of 1 indicates an error with one of the following: Error when reading the confirmation
00455           byte with a SET PATH command. The WRITE EPROM command did not program successfully. There was
00456           a difference between the byte written and then read back with a BYTE I/O command
00457    */
00458   static const uint8_t CMP_bitmask = 0x10;
00459 
00460   /** VPP A value of 1 indicates that during a PULSE with TYPE = 1 or WRITE EPROM command the 12V
00461           programming pulse was not seen on the 1-Wire bus; this could indicate that there were other
00462           devices on the bus that clamped the voltage to a value lower than VPP or that the programming
00463           pulse was disabled with a mode command.
00464    */
00465   static const uint8_t VPP_bitmask = 0x08;
00466 
00467   /** APP A value of 1 indicates that a 1-WIRE RESET revealed an Alarming Presence Pulse.
00468    */
00469   static const uint8_t APP_bitmask = 0x04;
00470 
00471   /** SH  A value of 1 indicates that a 1-WIRE RESET revealed a short to the 1-Wire bus or the
00472           SET PATH command could not successfully connect a branch due to a short.
00473    */
00474   static const uint8_t SH_bitmask  = 0x02;
00475 
00476   /** NRS A value of 1 indicates an error with one of the following: 1-WIRE RESET did not reveal
00477           a Presence Pulse. SET PATH command did not get a Presence Pulse from the branch that was
00478           to be connected. No response from one or more ROM ID bits during a SEARCH ACCESS command.
00479    */
00480   static const uint8_t NRS_bitmask = 0x01;
00481 
00482   //!@}
00483 
00484   
00485   //=====================================================================================
00486   //
00487   // type definitions
00488   //
00489     
00490   //! @name DS2490 specific configuration values.
00491   //!@{
00492   /** Type for wirespeed */
00493   typedef enum { /** 16 kbps */ normal_OWSPEED=0x00, flexible_OWSPEED, /** 142 kbps */ overdrive_OWSPEED } OWSPEED_val_t;
00494   /** Type for flexible speed pulldown slew rate in V/microsec */
00495   typedef enum { PDSR_15=0x00,    PDSR_2_2,  PDSR_1_65, PDSR_1_37, PDSR_1_1, PDSR_0_83, PDSR_0_7, PDSR_0_55} PDSR_val_t;
00496   /** Type for flexible speed write-1 low time in microsec */
00497   typedef enum { W1LT_8=0x00,     W1LT_9,    W1LT_10,   W1LT_11,   W1LT_12,  W1LT_13,   W1LT_14,  W1LT_15}   W1LT_val_t;
00498   /** Type for flexible speed DSO/ W0R time in microsec */
00499   typedef enum { SOW0RT_3=0x00,   SOW0RT_4,  SOW0RT_5,  SOW0RT_6,  SOW0RT_7, SOW0RT_8,  SOW0RT_9, SOW0RT_10} SOW0RT_val_t;
00500   //!@}
00501 
00502   /** Type to define result handling with communication commands. */
00503   typedef enum {
00504     noResult_rsltHdl=0x00,    /**< NTF=x  ICP=1, Never generate result register feedback. */
00505     resultOnError_rsltHdl,    /**< NTF=0  ICP=0, Generate result register on error and leave in EP1 FIFO. */
00506     resultAlways_rsltHdl      /**< NTF=1  ICP=0, Always generate result register and leave in EP1 FIFO. */
00507   }  resultHandling_t;
00508 
00509   
00510   //! @name Status and result code types.
00511   //!@{
00512 
00513   /** Status information, raw format from device */
00514   typedef struct deviceFeedbackRaw_t {
00515     uint8_t  enableFlags;
00516     uint8_t  oneWireSpeed;
00517     uint8_t  strongPullupDuration;
00518     uint8_t  progPulseDuration;
00519     uint8_t  pulldownSlewRate;
00520     uint8_t  write1LowTime;
00521     uint8_t  dsow0RecTime;
00522     uint8_t  reserved0;
00523     uint8_t  deviceStatusFlags;
00524     uint8_t  commCmdLO;
00525     uint8_t  commCmdHI;
00526     uint8_t  commCmdBufferStatus;
00527     uint8_t  dataOutBufferStatus;
00528     uint8_t  dataInBufferStatus;
00529     uint8_t  reserved1;
00530     uint8_t  reserved2;
00531     uint8_t  resultCode[16];
00532   } deviceFeedbackRaw_t;
00533 
00534   
00535   /** Status information, decoded format */
00536   typedef struct resultCode_t {
00537     bool deviceDetected;             /**< 1-wire device detect byte found */
00538     bool searchAccessDeviceUnderrun; /**< EOS bit */
00539     bool pageIsRedirected;           /**< RDP bit */
00540     bool crcError;                   /**< CRC bit */
00541     bool compareError;               /**< CMP bit */
00542     bool progVoltageMissingOnBus;    /**< VPP bit */
00543     bool alarmingPresencePulse;      /**< APP bit */
00544     bool shortToGround;              /**< SH bit  */
00545     bool noPresencePulse;            /**< NRS bit */
00546   } resultCode_t;
00547 
00548   typedef std::vector<resultCode_t>   resultCodeVec_t;  /**< Vector type of resultCode_t. */
00549 
00550   /** Status information, decoded format */
00551   typedef struct deviceFeedback_t {
00552     bool           isStrongPullupEnabled;       /**< SPUE bit */
00553     bool           isProgPulseEnabled;          /**< PRGE bit */
00554     bool           isDynSpeedChangeEnabled;     /**< SPCE bit */
00555     OWSPEED_val_t  oneWireSpeed;                /**< current 1-Wire bus speed code */
00556     uint8_t        strongPullupDurationFactor;  /**< current pullup duration */
00557     uint8_t        progPulseDurationFactor;     /**< current programming pulse duration */
00558     PDSR_val_t     pulldownSlewRate;            /**< current pulldown slew rate code */
00559     W1LT_val_t     write1LowTime;               /**< current Write-1 low time code */
00560     SOW0RT_val_t   dsow0RecTime;                /**< current data sample offset/ Write-0 recovery time code */
00561     bool           strongPullupCurrentActive;   /**< SPUA bit */
00562     bool           progPulseCurrentActive;      /**< PRGA bit */
00563     bool           progVoltagePresent;          /**< 12VP bit */
00564     bool           deviceExternalPowered;       /**< PMOD bit */
00565     bool           deviceHalted;                /**< HALT bit */
00566     bool           deviceIdle;                  /**< IDLE bit */
00567     bool           ep0FifoOverflowError;        /**< EPOF bit */
00568     uint16_t       currentCommCmd;              /**< Communication command currently being processed. If the device is idle, a register value of 0x00 is sent. */
00569     uint8_t        commCmdBufferUsage;          /**< Number of data bytes currently contained in the 16-byte FIFO used to hold communication commands. */
00570     uint8_t        dataOutBufferUsage;          /**< Number of data bytes currently contained in the 128-byte FIFO used to write data to the 1-Wire bus. */
00571     uint8_t        dataInBufferUsage;           /**< Number of data bytes currently contained in the 128-byte command FIFO used to read data from the 1-Wire bus. */
00572     uint8_t        resultCount;                 /**< Number of results received. */
00573     resultCode_t   compoundResults;             /**< All results ORed together. */
00574   } deviceFeedback_t;
00575 
00576   //!@}
00577 
00578   
00579 
00580   //=====================================================================================
00581   //
00582   // attributes
00583   //
00584 
00585   LOW_portUsbDevice *usbDevice;  /**< The USB device we use. */
00586 
00587 
00588 
00589   //=====================================================================================
00590   //
00591   // methods
00592   //
00593 
00594   /** @name Mid-layer methods.
00595    */
00596   //!@{
00597 
00598   /** Actions common to all constructors.
00599    */
00600   void commonConstructorActions();
00601   
00602   
00603   /** Fetch device status and all available result codes.
00604       @param outDevFeedback    Device status read from the device.
00605       @param outResultCodeVec  All result codes which were available.
00606    */
00607   void readDeviceStatus( deviceFeedback_t &outDevFeedback, resultCodeVec_t &outResultCodeVec);
00608 
00609   
00610   /** Periodically poll the device status until the it's status is idle.
00611       @param outDeviceFeedback  Feedback status of the last poll.
00612       @param outResultCodeVec   All result codes being available during polling.
00613       @param inTimeout          Maximum time to wait for the device to become idle.
00614    */
00615   void waitUntilIdle( deviceFeedback_t &outDeviceFeedback, resultCodeVec_t &outResultCodeVec, 
00616                       const LOW_portUsbDevice::usbTimeout_t inTimeout);
00617 
00618   /** Universal and internal funtion for single strong pullups.
00619       @param inPullupFactor  Factor of pulse length. Length will be factor times 16ms.
00620    */
00621   void strongPullupInternal( const unsigned int inPullupFactor);
00622 
00623   /** Universal and internal funtion for program pulses.
00624       @param inPullupFactor  Factor of pulse length. Length will be factor times 8us.
00625    */
00626   void progPulseInternal( const unsigned int inPulseFactor);
00627   
00628   //!@}
00629 
00630 
00631   
00632   /** @name Control command methods.
00633       Control commands are used to control the processing of Communication commands/data and can also be used
00634       to issue a device Reset. There are 9 Control commands. Like Mode commands, Control commands are
00635       immediately processed by the DS2490 when they are received.
00636    */
00637   //!@{
00638 
00639   /** Performs a hardware reset equivalent to the power-on reset.
00640       This includes clearing all endpoint buffers and loading the Mode control registers
00641       with their default values.
00642    */
00643   virtual void ctlCmd_resetDevice();
00644 
00645   /** Starts execution of Communication commands.
00646       This command is also required to start the execution of Communication commands with an
00647       IM (immediate execution control) bit set to logic 0.
00648    */
00649   virtual void ctlCmd_startExecution();
00650 
00651 
00652   /** Used to resume execution of a Communication command that was halted with either of
00653       the HALT EXECUTION commands.
00654    */
00655   virtual void ctlCmd_resumeExecution();
00656 
00657 
00658   /** Used to halt the execution of the current Communication command after the 1-Wire bus
00659       has returned to the idle state.
00660       Further Communication command processing is stopped until a RESUME EXECUTION command is received.
00661       This command, or the HALT EXECUTION WHEN DONE command, is also used to terminate a strong pullup
00662       or programming pulse of semi-infinite or infinite duration.
00663    */
00664   virtual void ctlCmd_haltExecutionWhenIdle();
00665 
00666 
00667   /** Used to halt the execution of a Communication command after the current command execution
00668       is complete.
00669       Further Communication command processing is stopped until a RESUME EXECUTION command is received.
00670       This command, or the HALT EXECUTION WHEN IDLE command, is also used to terminate a strong pullup
00671       or programming pulse of semi-infinite or infinite duration.
00672    */
00673   virtual void ctlCmd_haltExecutionWhenDone();
00674 
00675 
00676   /** Used to clear all unexecuted Communication commands from the command FIFO.
00677       The DS2490 must be in a halted state before the FLUSH COMM CMDS command can be processed.
00678    */
00679   virtual void ctlCmd_flushCommCmds();
00680 
00681 
00682   /** Used to clear EP3 receive data FIFO (data from 1- Wire device).
00683       The DS2490 must be in a halted state before the FLUSH DATA RCV BUFFER command can be processed.
00684    */
00685   virtual void ctlCmd_flushDataRcvBuffer();
00686 
00687 
00688   /** Used to clear EP2 transmit data FIFO (data to 1- Wire device).
00689       The DS2490 must be in a halted state before the FLUSH DATA XMT BUFFER command can be processed.
00690    */
00691   virtual void ctlCmd_flushDataXmtBuffer();
00692 
00693 
00694   /** Used to retrieve unexecuted Communication commands and parameters from the command FIFO.
00695 
00696       The DS2490 must be in a halted state before the GET COMM CMDS command can be processed.
00697 
00698       Unexecuted commands are returned over EP0 in the control transfer data phase.
00699       Host software is responsible for determining the number of command/parameter bytes to be returned and
00700       specifying the value in the wLength field of the control transfer setup packet.
00701 
00702       Commands/parameters are deleted from the FIFO as they are transmitted to the host; the command
00703       pointer used with the FIFO is updated as values are read. Any commands/parameters that are not
00704       transferred remain in the FIFO and will be processed when command execution resumes.
00705 
00706       If the wLength value passed is larger than the number of command/parameter bytes, the DS2490 will
00707       terminate the control transfer with a short data packet.
00708    */
00709   virtual void ctlCmd_getCommCmds( byteVec_t &outBytes);
00710   
00711   //!@}
00712 
00713 
00714   
00715   /** @name Mode command methods.
00716       1-Wire characteristics and features (speed, durations, slew rate, etc.) are controlled with discrete 
00717       Mode commands and/or embedded Communication command parameters. Parameter values and enable/disable 
00718       settings are used for characteristic control. Mode settings are stored in the DS2490 State Registers 
00719       and can be read at any time or at the polling interval of EP1. Enable/disable settings are used to 
00720       control three global features:   
00721       
00722         - Strong pullup to +5V   
00723         
00724         - +12V EPROM programming pulse   
00725         
00726         - Dynamic 1-Wire bus communication speed change through a communication command 
00727         
00728       The settings for these three global controls are accessible only through Mode commands; the features 
00729       are either enabled or disabled with the appropriate Mode command. Specific Communication commands 
00730       exist to issue a strong pullup, a programming pulse, or speed change. When the corresponding setting 
00731       is enabled the feature is usable as part of a communication command when disabled the feature is not usable. 
00732       Parameter values and codes are used to specify and control 1-Wire bus characteristics:   
00733       
00734         - 1-Wire bus communication speed   
00735         
00736         - +5V strong pullup duration   
00737         
00738         - +12V programming pulse duration   
00739         
00740         - Pulldown slew rate   
00741         
00742         - Write-1 low time   
00743         
00744         - Data sample offset/Write-0 Recovery time
00745 
00746       These six settings are controllable with discrete Mode commands or as embedded command/parameter values 
00747       in Communications commands. Mode commands are immediately processed by the DS2490 when they are received. 
00748    */
00749   //!@{
00750   /** Used to enable or disable a 1-Wire strong pullup pulse to 5V and/or +12V EPROM programming pulse.
00751       Two bit positions in the parameter byte are used to control the enabled/disabled state for each pulse type. 
00752       The specific pulse is enabled when the respective bit is set to a 1 and disabled when set to a 0. 
00753       The DS2490 power-up default state for both strong pullup and programming pulse is disabled. 
00754    */
00755   virtual void modCmd_setEnablePulse( const bool inEnableStrongPullup, const bool inEnableProgPulse);
00756   
00757   
00758   /** Used to enable or disable a 1-Wire communication speed change. 
00759       Enabled when a TRUE parameter value is passed with the command, disabled with a FALSE. 
00760       The DS2490 power-up default state for speed change is disabled. 
00761    */
00762   virtual void modCmd_setEnableSpeedChange( const bool inEnableSpeedChange);
00763   
00764   
00765   /** Used to set the speed of 1-Wire communication; three settings are possible. 
00766       The DS2490 power-up default communication speed is regular.
00767    */
00768   virtual void modCmd_setOneWireSpeed( const OWSPEED_val_t inWireSpeed);
00769 
00770   
00771   /** Used to set the time duration of a 1-Wire strong pullup. 
00772       The time is controlled with an unsigned 8-bit binary number between 0x00 and 0xFE which specifies 
00773       the duration in multiples of 16ms. A value of 0x01 specifies 16ms, 0x02 equals 32ms, etc. 
00774       A value of 0x00 specifies infinite duration. Parameter value 0xFF is reserved and will cause 
00775       the device to deliver a pullup duration of <1µs. 
00776       To terminate an infinite duration pullup use either the HALT EXECUTION WHEN DONE or 
00777       HALT EXECUTION WHEN IDLE Control commands as described in Appendix 1. 
00778       The DS2490 power-up default strong pullup duration register value is 512ms.
00779    */
00780   virtual void modCmd_setStrongPullupDuration( const uint8_t inSpuDurationFactor);
00781 
00782   
00783   /** Used to set the time duration of a 1-Wire Programming Pulse. 
00784       The time is controlled with a an unsigned 8-bit binary number between 0x00 and 0xFE specifying 
00785       the duration in multiples of 8µs. A value of 0x00 stands for infinite duration. Parameter value 0xFF 
00786       is reserved and will cause the device to deliver a pulse duration of <1µs. To terminate an infinite 
00787       duration programming pulse use the HALT EXECUTION WHEN DONE or HALT EXECUTION WHEN IDLE command.
00788       The DS2490 power-up default strong pullup duration register value is 512µS.
00789    */
00790   virtual void modCmd_setProgPulseDuration( const uint8_t inPpDurationFactor);
00791 
00792   
00793   /** Used to select the pulldown slew rate for 1-Wire bus Flexible Speed operation. 
00794       Eight pulldown slew rates are possible. The nominal pulldown slew rate for Regular speed is 0.83V/s and 
00795       for Overdrive speeds it is 15V/s.
00796       The DS2490 pulldown slew rate power-up default value for Flexible speed is 0.83V/  s.
00797    */
00798   virtual void modCmd_setPulldownSlewRate( const PDSR_val_t inPDSR);
00799   
00800   
00801   /** Used to select the Write-1 low time for 1-Wire bus Flexible speed operation.
00802       Eight Write-1 low time durations are possible. The nominal Write-1 Low Time for Regular speed is 8us, at 
00803       Overdrive speed it is 1us. 
00804       The DS2490 Write-1 Low Time power-up default value for Flexible speed is 12us.
00805    */
00806   virtual void modCmd_setWrite1LowTime( const W1LT_val_t inW1LT);
00807   
00808   
00809   /** Used to select the Data Sample Offset (tDSO) / Write-0 recovery (tW0R) time (DSO/W0R) for 1-Wire 
00810       bus Flexible Speed operation. 
00811       Eight DSO/W0R times are possible. The nominal DSO/W0R time for Regular speed is 3us, for Overdrive 
00812       speed the Data Sample Offset is 1us and the Write-0 Recovery Time is 3 s. 
00813       The DS2490 DSO/W0R power-up default value for Flexible speed is 7us.
00814    */
00815   virtual void modCmd_setDsoW0RecoveryTime( const SOW0RT_val_t inSOW0RT);
00816   
00817   //!@}
00818 
00819   
00820   
00821   /** @name Communication command methods.
00822   
00823       Communication commands are used to communicate with and control an attached 1-Wire device(s). 
00824       Communication commands also contain embedded command bits for conditional control or additional 
00825       functionality. 
00826       
00827       Unlike Mode and Control commands, Communication command processing is controlled by host software 
00828       by setting embedded command bits within a Communication command. For example, a command macro form 
00829       is supported in which several Communication commands and parameter data are sent/buffered in the 
00830       DS2490 and then processed as a group. 
00831       
00832       Embedded command bit ICP is used to create macro command sets. Also, unlike Mode and Control commands, 
00833       several forms of Communication command monitoring exist for host software to track processing progress. 
00834       Depending on the settings of embedded communication command bits ICP and NTF, a Result Register value 
00835       may be generated to provide command processing feedback. 
00836       
00837       Communication command buffer (FIFO) status and 1-Wire data transmit/received buffers (EP2/3 FIFOs) 
00838       status can also be monitored via the State Registers.
00839    */
00840   //!@{
00841   
00842   /** Changes the State Register pulse duration value for either the +12V programming pulse or strong pullup.
00843       The new duration value is loaded into the duration register specified. The duration values can alternatively
00844       be changed using a Mode command. The new duration setting remains effective until changed by another 
00845       SET DURATION or MODE Command. See section  MODE COMMANDS  for duration parameter value setting.
00846    */
00847   virtual void comCmd_setDuration( const uint8_t inTimeFactor,
00848                                    const bool inSpecifyProgPulse,
00849                                    const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00850                                    const bool inImmediateExec = true);
00851   
00852   
00853   /** Used to temporarily pull the 1-Wire bus to +12V in order to program an EPROM device or 
00854       to generate a strong pullup to 5V in order to provide extra power for an attached iButton device, 
00855       e.g., temperature sensor or crypto iButton. 
00856       
00857       The pulse duration is determined by the value in the respective mode register, programming pulse or 
00858       strong pullup. The 12VP bit in the Device Status Flags (bit2) is used to determine whether +12V VPP 
00859       programming voltage is present.
00860    */
00861   virtual void comCmd_pulse( const bool inSpecifyProgPulse,
00862                              const bool inFlushBuffersOnErr,
00863                              const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00864                              const bool inImmediateExec = true);
00865 
00866   
00867   /** Used to generate a reset pulse on the 1-Wire bus and to optionally change the 1-Wire speed. 
00868       The new speed will take effect only if the embedded command bit SE is set to 1. When the 1-WIRE RESET is 
00869       sent after an Overdrive Skip ROM command, SE must be 1 and the new speed must be 0x02. 
00870       See MODE CONTROL section for additional communication speed information. To switch back to regular speed, 
00871       set SE = 1 and the new speed parameter to 0x00 (regular) or 0x01 (flexible).
00872    */
00873   virtual void comCmd_oneWireReset( const bool inLoopUntilPresenceDetect,
00874                                     const bool inEnableSpeedChange,
00875                                     const OWSPEED_val_t inSpeedSelector,
00876                                     const bool inFlushBuffersOnErr,
00877                                     const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00878                                     const bool inImmediateExec = true);
00879 
00880   
00881   /** Generates a single time slot on the 1-Wire bus and reads back the response. 
00882       This time slot may optionally be followed by a strong pullup using embedded command bits SPU and CIB. 
00883       With CIB = 1, a requested strong pullup will only occur if the read-back revealed a 0. 
00884       Data is returned to the host only if the embedded command bit ICP = 0. If ICP = 0, the bit read from 
00885       the 1-Wire device is stored in the EP3 FIFO and is read by the host using an EP3 bulk transaction.
00886    */
00887   virtual void comCmd_bitIO( const bool inWriteBit,
00888                              const bool inDoStrongPullup,
00889                              const bool inSuppressPullupOnRead1,
00890                              const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00891                              const bool inImmediateExec = true);
00892 
00893   
00894   /** Accomplishes a direct 1-Wire write and read with optional strong pullup after the last bit of the byte. 
00895       The optional strong pullup is controlled using embedded command bit SPU. For a write sequence, the data 
00896       byte to be written is included in the command setup packet as shown in Appendix 2.
00897       For a read sequence, the setup packet data byte value is set to 0xFF. 
00898       Data is returned to the host only if the embedded command bit ICP = 0. If ICP = 0, the byte read from 
00899       the 1-Wire device is stored in the EP3 FIFO and is read by the host using an EP3 bulk transaction.
00900    */
00901   virtual void comCmd_byteIO( const uint8_t inWriteByte,
00902                               const bool inDoStrongPullup,
00903                               const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00904                               const bool inImmediateExec = true);
00905 
00906   
00907   /** Accomplishes a direct 1-Wire write or read with optional strong pullup after the last byte of the block. 
00908       The optional strong pullup is controlled using embedded command bit SPU. Embedded command bit RST enables 
00909       a 1-Wire reset before the command executes. To accomplish a READ function all input data should be 0xFF, 
00910       otherwise the data read from the 1-Wire bus will be masked. For a block write sequence the EP2 FIFO must 
00911       be pre-filled with data before command execution. Additionally, for block sizes greater then the FIFO 
00912       size, the FIFO content status must be monitored by host SW so that additional data can be sent to the 
00913       FIFO when necessary. A similar EP3 FIFO content monitoring requirement exists for block read sequences. 
00914       During a block read the number of bytes loaded into the EP3 FIFO must be monitored so that the data can 
00915       be read before the FIFO overflows.
00916    */
00917   virtual void comCmd_blockIO( const uint16_t inWriteSize,
00918                                const bool inBusResetBefore,
00919                                const bool inDoStrongPullup,
00920                                const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00921                                const bool inImmediateExec = true);
00922 
00923   
00924   /** Is used to address a device on the active section of the 1-Wire bus using the Match ROM or Overdrive Match 
00925       command code. 
00926       The EP2 FIFO must be pre-filled with the 8 bytes target ROM ID before command execution. Embedded command 
00927       bit RST enables a 1-Wire reset before the command executes, and embedded command bit SE enables a 1-Wire 
00928       speed change that takes effect before the command executes.
00929    */
00930   virtual void comCmd_matchAccess( const uint8_t inMatchCommand,
00931                                    const bool inBusResetBefore,
00932                                    const bool inEnableSpeedChange,
00933                                    const OWSPEED_val_t inSpeedSelector,
00934                                    const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00935                                    const bool inImmediateExec = true);
00936 
00937   
00938   /** Transmits a user-specified preamble of data to the 1-Wire bus and then reads back as 
00939       many bytes as specified. 
00940       The preamble typically consists of a 1-Wire command code followed by TA1 and TA2. It is possible to include 
00941       a Match ROM command and ROM ID in the preamble to also address a device at the current speed. 
00942       This command can also be used to copy the scratchpad or disconnect a path. Embedded command bit RST enables 
00943       a 1-Wire reset before the command executes. The EP2 FIFO must be pre-filled with preamble data before 
00944       command execution. Additionally, for preamble sizes greater then the FIFO size, the FIFO content status 
00945       must be monitored by host SW so that additional data can be sent to the FIFO when necessary. A similar 
00946       EP3 FIFO content monitoring requirement exists for the block read. During a block read, the number of bytes 
00947       loaded into the EP3 FIFO must be monitored so that the data can be read before the FIFO overflows.
00948    */
00949   virtual void comCmd_readStraight( const uint8_t inWritePreambleSize,
00950                                     const uint16_t inReadSize,
00951                                     const bool inBusResetBefore,
00952                                     const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00953                                     const bool inImmediateExec = true);
00954 
00955   
00956   /** Typically used to control the activity of the CPU of the crypto iButton, which requires a release sequence. 
00957       This command can also be used to read from or write to the I/O buffer or Status Register of the crypto 
00958       iButton. A short preamble (3 bytes) consists of a 1-Wire command code followed by the release sequence. 
00959       A four-byte preamble with embedded command bit R = 1 consists of a 1-Wire command code followed by length 
00960       byte and the release sequence. A 4-byte preamble with embedded command bit R = 0 consists of a 1-Wire command 
00961       code followed by a status byte and the release sequence. The long preamble (minimum 5 bytes, embedded command 
00962       bit R = 0) consists of a 1-Wire command, a length byte, data bytes and the release sequence. In this case, 
00963       the length byte indicates the total number of bytes between the length byte and release sequence. The least 
00964       significant byte of the release sequence is transmitted first. Embedded command bit SPU must be 1 when trying 
00965       to run (start, continue) the CPU of the crypto iButton. In all other cases, SPU should be 0. Additionally, 
00966       embedded command bit F can be used to clear the communication command buffer and EP2/3 FIFOs if an error 
00967       occurs during execution of the command. The EP2 FIFO must be pre-filled with preamble data before command 
00968       execution. Additionally, for preamble sizes greater then the FIFO size, the FIFO content status must be 
00969       monitored by host SW so that additional data can be sent to the FIFO when necessary. A similar EP3 FIFO 
00970       content monitoring requirement exists for the block read. During a block read the number of bytes loaded 
00971       into the EP3 FIFO must be monitored so that the data can be read before the FIFO overflows.
00972    */
00973   virtual void comCmd_doAndRelease( const uint8_t inWritePreambleSize,
00974                                     const bool inDoReadOperation,
00975                                     const bool inDoStrongPullup,
00976                                     const bool inFlushBuffersOnErr,
00977                                     const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00978                                     const bool inImmediateExec = true);
00979 
00980   
00981   /** Used to activate a series of couplers that finally provide the access to the target 1-Wire device. 
00982       Embedded command bit RST enables a 1-Wire reset before the command executes. Additionally, embedded 
00983       command bit F can be used to clear the communication command buffer and EP2/3 FIFOs if an error occurs 
00984       during execution of the command. The EP2 FIFO must be pre-filled with coupler data before command execution. 
00985       Additionally, for coupler data sizes greater then the EP2 FIFO size, the FIFO content status must be 
00986       monitored by host SW so that additional data can be sent to the FIFO when necessary. Upon completion of 
00987       command execution, the EP3 FIFO is loaded with a 1-byte value that indicates the number of couplers 
00988       activated. An NRS error code is an indication that there was no presence pulse on the branch that was 
00989       to be connected.
00990    */
00991   virtual void comCmd_setPath( const uint8_t inPreloadPathSize,
00992                                const bool inBusResetBefore,
00993                                const bool inFlushBuffersOnErr,
00994                                const resultHandling_t inResultHandling = resultOnError_rsltHdl,
00995                                const bool inImmediateExec = true);
00996 
00997   
00998   /** Used to write data to the scratchpad of an SRAM device and optionally check the CRC. To copy the data 
00999       to its final memory location, it is required to send the READ STRAIGHT command with a  copy scratchpad  
01000       preamble and a 0 block size. Embedded command bit DT = 1 activates the CRC16 generator. This command is 
01001       also applicable to the Write IPR function of the Crypto iButton if embedded command bit CIB = 1. To write 
01002       a partial page the page size parameter and the target address need to be set accordingly. The EP2 FIFO must 
01003       be pre-filled with preamble and SRAM data before command execution. Additionally, for data page sizes 
01004       greater then the EP2 FIFO size, the FIFO content status must be monitored by host SW so that additional data 
01005       can be sent to the FIFO when necessary.
01006    */
01007   virtual void comCmd_writeSramPage( const uint8_t inWriteSize,
01008                                      const bool inShortPreambleSize,
01009                                      const bool inActivateCrc16,
01010                                      const bool inFlushBuffersOnErr,
01011                                      const resultHandling_t inResultHandling = resultOnError_rsltHdl,
01012                                      const bool inImmediateExec = true);
01013 
01014   
01015   /** Used to write data directly to the data or status memory of a 1-Wire EPROM device. 
01016       If embedded command bit DT = 1, the CRC16 generator is selected; if DT = 0, CRC8 is used. Embedded command 
01017       bit Z controls the method used for comparison of the data written to the 1-Wire device. Additionally, embedded 
01018       command bit F can be used to clear the Communication command buffer and EP2/3 FIFOs if an error occurs during 
01019       execution of the command. The EP2 FIFO must be pre-filled with preamble and EPROM data before command execution. 
01020       Additionally, for data block sizes greater then the EP2 FIFO size, the FIFO content status must be monitored by 
01021       host SW so that additional data can be sent to the FIFO when necessary.
01022    */
01023   virtual void comCmd_writeEprom( const uint16_t inWriteSize,
01024                                   const bool inActivateCrc16,
01025                                   const bool inCheck0BitsOnly,
01026                                   const bool inFlushBuffersOnErr,
01027                                   const resultHandling_t inResultHandling = resultOnError_rsltHdl,
01028                                   const bool inImmediateExec = true);
01029 
01030   
01031   /** Used to read one or multiple CRC-protected pages of EPROM devices and to read tamper-detect bytes and counter 
01032       value of Monetary iButtons. 
01033       If embedded command bit DT = 1, the CRC16 generator is selected; if DT = 0, CRC8 is used. Embedded command 
01034       bit CIB is used to specify either a 2- or 3-byte read preamble. Additionally, embedded command bit F can be 
01035       used to clear the Communication command buffer and EP2/3 FIFOs if an error occurs during execution of the 
01036       command. The command can also be used to read a single partial page up to the end of that page and reading the 
01037       PIOs of a DS2406. This command is also applicable to the Read IPR function of the crypto iButton if CIB = 1. 
01038       The EP2 FIFO must be pre-filled with preamble data before command execution. To prevent overflow, the EP3 FIFO 
01039       must be monitored (and read if necessary) during command execution if reading more data than the size of the 
01040       EP3 FIFO.
01041    */
01042   virtual void comCmd_readCrcProtPage( const uint8_t inPageCount,
01043                                        const uint8_t inPageSizeLog2,
01044                                        const bool inShortPreambleSize,
01045                                        const bool inActivateCrc16,
01046                                        const bool inFlushBuffersOnErr,
01047                                        const resultHandling_t inResultHandling = resultOnError_rsltHdl,
01048                                        const bool inImmediateExec = true);
01049 
01050   
01051   /** Used to read a single page of data and check the CRC. 
01052       If the page is not redirected, the host will receive the page number and all its data. If the page is 
01053       redirected and embedded command bit CH = 1 the device will follow the trail of redirections until a page is 
01054       found that is not redirected. When found, the host will receive the page number and all data of that 
01055       particular page. If CH = 0 and the first read attempt reveals a redirection the host will only receive the 
01056       number of the page the addressed page is redirected to. Reading starts at a page boundary. Additionally, 
01057       embedded command bit F can be used to clear the communication command buffer and EP2/3 FIFOs if an error occurs 
01058       during execution of the command. An NRS error code is an indication of an infinite loop. The EP2 FIFO must be
01059       pre-filled with ROM ID and command code data before command execution. To prevent overflow, the EP3 FIFO must 
01060       be monitored (and read if necessary) during command execution if reading more data than the size of the EP3 FIFO.
01061    */
01062   virtual void comCmd_readRedirectPageCrc( const uint8_t inPageNumber,
01063                                            const uint8_t inPageSize,
01064                                            const bool inFollowRedirect,
01065                                            const bool inFlushBuffersOnErr,
01066                                            const resultHandling_t inResultHandling = resultOnError_rsltHdl,
01067                                            const bool inImmediateExec = true);
01068   
01069   
01070   /** Is used to either access a device using the Search ROM command or to identify the devices on 
01071       the active segments of a 1-Wire Network. 
01072       Embedded command bit SM is used to specify the type of search. Embedded command bit RTS is used to control 
01073       discrepancy information reporting. Additionally, embedded command bit F can be used to clear the Communication 
01074       command buffer and EP2/3 FIFOs if an error occurs during execution of the command. An NRS error code indicates 
01075       that there was no response on at least one of the 64 bits of the ROM search. The EP2 FIFO must be pre-filled 
01076       with ROM ID data before command execution. To prevent overflow, the EP3 FIFO must be monitored (and read if 
01077       necessary) during command execution if returning more data than the size of the EP3 FIFO.
01078    */
01079   virtual void comCmd_searchAccess( const uint8_t inMaxDevNum,
01080                                     const uint8_t inSearchCommand,
01081                                     const bool inSearchWithoutFullAccess,
01082                                     const bool inReturnDiscrepancyInfo,
01083                                     const bool inBusResetBefore,
01084                                     const bool inFlushBuffersOnErr,
01085                                     const resultHandling_t inResultHandling = resultOnError_rsltHdl,
01086                                     const bool inImmediateExec = true);
01087 
01088                                     
01089   /** Handle common bits of all communication commands.
01090    */
01091   void handleCommonComCmdBits( LOW_portUsbDevice::wValue_t &inOutValueCmd,
01092                                const resultHandling_t inResultHandling, const bool inImmediateExec);
01093 
01094 
01095   //!@}
01096 
01097   
01098   
01099   //=====================================================================================
01100   //!
01101   //! @name Enumeration type conversion methods
01102   //!
01103   //@{
01104 
01105 
01106   /** Convert value of type PDSR_val_t to pdSlewRate_t.
01107       @throw  internal_error  Thrown when conversion not possible (should not happen).
01108    */
01109   virtual const pdSlewRate_t PDSR_val_2_pdSlewRate( const PDSR_val_t inPDSR_val) const;
01110 
01111   /** Convert value of type pdSlewRate_t to PDSR_val_t.
01112       @throw  internal_error  Thrown when conversion not possible (should not happen).
01113    */
01114   virtual const PDSR_val_t pdSlewRate_2_PDSR_val( const pdSlewRate_t inPdSlewRate_t) const;
01115 
01116   /** Convert value of type W1LT_val_t to w1LowTime_t.
01117       @throw  internal_error  Thrown when conversion not possible (should not happen).
01118    */
01119   virtual const w1LowTime_t W1LT_val_2_w1LowTime( const W1LT_val_t inW1LT_val) const;
01120 
01121   /** Convert value of type w1LowTime_t to W1LT_val_t.
01122       @throw  internal_error  Thrown when conversion not possible (should not happen).
01123    */
01124   virtual const W1LT_val_t w1LowTime_2_W1LT_val( const w1LowTime_t inW1LowTime) const;
01125 
01126   /** Convert value of type SOW0RT_val_t to soW0RecTime_t.
01127       @throw  internal_error  Thrown when conversion not possible (should not happen).
01128    */
01129   virtual const soW0RecTime_t SOW0RT_val_2_soW0RecTime( const SOW0RT_val_t inSOW0RT_val) const;
01130 
01131   /** Convert value of type soW0RecTime_t to SOW0RT_val_t.
01132       @throw  internal_error  Thrown when conversion not possible (should not happen).
01133    */
01134   virtual const SOW0RT_val_t soW0RecTime_2_SOW0RT_val( const soW0RecTime_t inSoW0RecTime) const;
01135 
01136   /** Convert value of type OWSPEED_val_t to wireSpeed_t.
01137       @throw  internal_error  Thrown when conversion not possible (should not happen).
01138    */
01139   virtual const wireSpeed_t OWSPEED_val_2_wireSpeed( const OWSPEED_val_t inOWSPEED_val) const;
01140   
01141   /** Convert value of type wireSpeed_t to OWSPEED_val_t.
01142       @throw  internal_error  Thrown when conversion not possible (should not happen).
01143    */
01144   virtual const OWSPEED_val_t wireSpeed_2_OWSPEED_val( const wireSpeed_t inWireSpeed) const;
01145 
01146   /** Convert value of type strongPullup_t to factor of 16ms.
01147       @throw  internal_error  Thrown when conversion not possible (should not happen).
01148    */
01149   virtual const uint8_t strongPullup_2_spFactor( const strongPullup_t inPullup) const;
01150 
01151   /** Convert value of type progPulse_t to factor of 8us.
01152       @throw  internal_error  Thrown when conversion not possible (should not happen).
01153    */
01154   virtual const uint8_t progPulse_2_ppFactor( const progPulse_t inPulse) const;
01155   //@}
01156     
01157 };
01158 
01159 #endif

Generated on Tue Feb 3 11:30:25 2004 for OneWireLibrary++ by doxygen 1.3.2