⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memorybankeprom.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*--------------------------------------------------------------------------- * Copyright (C) 1999,2000 Dallas Semiconductor Corporation, All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Dallas Semiconductor * shall not be used except as stated in the Dallas Semiconductor * Branding Policy. *--------------------------------------------------------------------------- */package com.dalsemi.onewire.container;// importsimport com.dalsemi.onewire.OneWireException;import com.dalsemi.onewire.adapter.*;import com.dalsemi.onewire.utils.*;import com.dalsemi.onewire.container.OneWireContainer;/** * Memory bank class for the EPROM section of iButtons and 1-Wire devices. * *  @version    0.00, 28 Aug 2000 *  @author     DS */class MemoryBankEPROM   implements OTPMemoryBank{   //--------   //-------- Static Final Variables   //--------   /**     * Read Memory Command     */   public static final byte READ_MEMORY_COMMAND = ( byte ) 0xF0;   /**     * Main memory read command     */   public static final byte MAIN_READ_PAGE_COMMAND = ( byte ) 0xA5;   /**     * Status memory read command     */   public static final byte STATUS_READ_PAGE_COMMAND = ( byte ) 0xAA;   /**     * Main memory write command     */   public static final byte MAIN_WRITE_COMMAND = ( byte ) 0x0F;   /**     * Status memory write command     */   public static final byte STATUS_WRITE_COMMAND = ( byte ) 0x55;   //--------   //-------- Variables   //--------   /**    * Reference to the OneWireContainer this bank resides on.    */   protected OneWireContainer ib;   /**     * Read page with CRC command     */   protected byte READ_PAGE_WITH_CRC;   /**     * Number of CRC bytes (1-2)     */   protected int numCRCBytes;   /**     * Get crc after sending command,address     */   protected boolean crcAfterAddress;   /**     * Get crc during a normal read     */   protected boolean normalReadCRC;   /**     * Program Memory Command     */   protected byte WRITE_MEMORY_COMMAND;   /**    * block of 0xFF's used for faster read pre-fill of 1-Wire blocks    */   protected byte[] ffBlock;   /**    * Flag to indicate that speed needs to be set    */   protected boolean doSetSpeed;   //--------   //-------- Protected Variables for MemoryBank implementation    //--------   /**    * Size of memory bank in bytes    */   protected int size;   /**    * Memory bank descriptions    */   protected String bankDescription;   /**    * Memory bank usage flags    */   protected boolean generalPurposeMemory;   /**    * Flag if memory bank is read/write    */   protected boolean readWrite;   /**    * Flag if memory bank is write once (EPROM)    */   protected boolean writeOnce;   /**    * Flag if memory bank is read only    */   protected boolean readOnly;   /**    * Flag if memory bank is non volatile    * (will not erase when power removed)    */   protected boolean nonVolatile;   /**    * Flag if memory bank needs program Pulse to write    */   protected boolean programPulse;   /**    * Flag if memory bank needs power delivery to write    */   protected boolean powerDelivery;   /**    * Starting physical address in memory bank.  Needed for different    * types of memory in the same logical memory bank.  This can be    * used to seperate them into two virtual memory banks.  Example:    * DS2406 status page has mixed EPROM and Volatile RAM.    */   protected int startPhysicalAddress;   /**    * Flag if read back verification is enabled in 'write()'.    */   protected boolean writeVerification;   //--------   //-------- Protected Variables for PagedMemoryBank implementation    //--------   /**    * Number of pages in memory bank    */   protected int numberPages;   /**    *  page length in memory bank    */   protected int pageLength;   /**    * Max data length in page packet in memory bank    */   protected int maxPacketDataLength;   /**    * Flag if memory bank has page auto-CRC generation    */   protected boolean pageAutoCRC;   /**    * Flag if reading a page in memory bank provides optional    * extra information (counter, tamper protection, SHA-1...)    */   protected boolean extraInfo;   /**    * Length of extra information when reading a page in memory bank    */   protected int extraInfoLength;   /**    * Extra information descriptoin when reading page in memory bank    */   protected String extraInfoDescription;   //--------   //-------- Protected Variables for OTPMemoryBank implementation    //--------   /**    * Flag if memory bank can have pages redirected    */   protected boolean redirectPage;   /**    * Flag if memory bank can have pages locked    */   protected boolean lockPage;   /**    * Flag if memory bank can have pages locked from redirected    */   protected boolean lockRedirectPage;   /**    * Memory bank to lock pages in 'this' memory bank    */   protected PagedMemoryBank mbLock;   /**    * Memory bank to redirect pages in 'this' memory bank    */   protected PagedMemoryBank mbRedirect;   /**    * Memory bank to lock redirect bytes in 'this' memory bank    */   protected PagedMemoryBank mbLockRedirect;   /**    * Byte offset into memory bank 'mbLock' to indicate where page 0 can be locked    */   protected int lockOffset;   /**    * Byte offset into memory bank 'mbRedirect' to indicate where page 0 can be redirected    */   protected int redirectOffset;   /**    * Byte offset into memory bank 'mbLockRedirect' to indicate where page 0 can have    * its redirection byte locked    */   protected int lockRedirectOffset;   //--------   //-------- Constructor   //--------   /**    * Memory bank contstuctor.  Requires reference to the OneWireContainer    * this memory bank resides on.  Requires reference to memory banks used    * in OTP operations.    */   public MemoryBankEPROM (OneWireContainer ibutton)   {      // keep reference to ibutton where memory bank is      ib = ibutton;      // get references to MemoryBanks used in OTP operations, assume no locking/redirection      mbLock             = null;      mbRedirect         = null;      mbLockRedirect     = null;      lockOffset         = 0;      redirectOffset     = 0;      lockRedirectOffset = 0;      // initialize attributes of this memory bank - DEFAULT: Main memory DS1985 w/o lock stuff      generalPurposeMemory = true;      bankDescription      = "Main Memory";      numberPages          = 64;      size                 = 2048;      pageLength           = 32;      maxPacketDataLength  = 29;      readWrite            = false;      writeOnce            = true;      readOnly             = false;      nonVolatile          = true;      pageAutoCRC          = true;      redirectPage         = false;      lockPage             = false;      lockRedirectPage     = false;      programPulse         = true;      powerDelivery        = false;      extraInfo            = true;      extraInfoLength      = 1;      extraInfoDescription = "Inverted redirection page";      writeVerification    = true;      startPhysicalAddress = 0;      READ_PAGE_WITH_CRC   = MAIN_READ_PAGE_COMMAND;      WRITE_MEMORY_COMMAND = MAIN_WRITE_COMMAND;      numCRCBytes          = 2;      crcAfterAddress      = true;      normalReadCRC        = false;      doSetSpeed           = true;      // create the ffblock (used for faster 0xFF fills)      ffBlock = new byte [50];      for (int i = 0; i < 50; i++)         ffBlock [i] = ( byte ) 0xFF;   }   //--------   //-------- MemoryBank query methods   //--------   /**    * Query to see get a string description of the current memory bank.    *    * @return  String containing the memory bank description    */   public String getBankDescription ()   {      return bankDescription;   }   /**    * Query to see if the current memory bank is general purpose    * user memory.  If it is NOT then it is Memory-Mapped and writing    * values to this memory will affect the behavior of the 1-Wire    * device.    *    * @return  'true' if current memory bank is general purpose    */   public boolean isGeneralPurposeMemory ()   {      return generalPurposeMemory;   }   /**    * Query to see if current memory bank is read/write.    *    * @return  'true' if current memory bank is read/write    */   public boolean isReadWrite ()   {      return readWrite;   }   /**    * Query to see if current memory bank is write write once such    * as with EPROM technology.    *    * @return  'true' if current memory bank can only be written once    */   public boolean isWriteOnce ()   {      return writeOnce;   }   /**    * Query to see if current memory bank is read only.    *    * @return  'true' if current memory bank can only be read    */   public boolean isReadOnly ()   {      return readOnly;   }   /**    * Query to see if current memory bank non-volatile.  Memory is    * non-volatile if it retains its contents even when removed from    * the 1-Wire network.    *    * @return  'true' if current memory bank non volatile.    */   public boolean isNonVolatile ()   {      return nonVolatile;   }   /**    * Query to see if current memory bank pages need the adapter to    * have a 'ProgramPulse' in order to write to the memory.    *    * @return  'true' if writing to the current memory bank pages    *                 requires a 'ProgramPulse'.    */   public boolean needsProgramPulse ()   {      return programPulse;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -