Mike Fruge / OneWire

Dependents:   Max32630_One_Wire_Interface

Files at this revision

API Documentation at this revision

Comitter:
IanBenzMaxim
Date:
Wed Mar 23 15:25:40 2016 -0500
Parent:
25:bdb1c5a53b58
Child:
27:d5aaefa252f1
Commit message:
Rework the OneWireMaster virtual interface for simplicity.

Changed in this revision

OneWire_Masters/DS2465/DS2465.cpp Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/DS2465/DS2465.hpp Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/DS2480B/ds2480b.cpp Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/DS2480B/ds2480b.h Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/DS248x/ds248x.cpp Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/DS248x/ds248x.h Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/GPIO/owgpio.cpp Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/GPIO/owgpio.h Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/OneWireMaster.cpp Show annotated file Show diff for this revision Revisions of this file
OneWire_Masters/OneWireMaster.h Show annotated file Show diff for this revision Revisions of this file
--- a/OneWire_Masters/DS2465/DS2465.cpp	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/DS2465/DS2465.cpp	Wed Mar 23 15:25:40 2016 -0500
@@ -262,11 +262,34 @@
 //   
 OneWireMaster::CmdResult DS2465::ConfigureAPU(bool apu_enable)	
 {
-   // clear power down bit in the global config state
-   m_curConfig.cAPU = apu_enable;
+  OneWireMaster::CmdResult result;
+  if (m_curConfig.cAPU != apu_enable)
+  {
+    m_curConfig.cAPU = apu_enable;
+    result = WriteConfig(m_curConfig);
+  }
+  else
+  {
+    result = OneWireMaster::Success;
+  }
+  return result;
+}
+
 
-   // write the new config
-   return WriteConfig(m_curConfig);
+
+OneWireMaster::CmdResult DS2465::ConfigureSPU(bool spu_enable)
+{
+  OneWireMaster::CmdResult result;
+  if (m_curConfig.cSPU != spu_enable)
+  {
+    m_curConfig.cSPU = spu_enable;
+    result = WriteConfig(m_curConfig);
+  }
+  else
+  {
+    result = OneWireMaster::Success;
+  }
+  return result;
 }
 
 //--------------------------------------------------------------------------
@@ -275,125 +298,24 @@
 // Returns:  true  successful
 //           false failure during communication
 //
-OneWireMaster::CmdResult DS2465::OWPowerUp(void)
-{
-   OneWireMaster::CmdResult rt;
-
-  // clear power down bit in the global config state
-   m_curConfig.cPDN = false;
-
-   // write the new config
-   rt = WriteConfig(m_curConfig);
-
-   // delay 2ms to allow units to power up
-   wait_ms(2);
-
-   return rt;
-}
-
-//--------------------------------------------------------------------------
-// Power down 1-Wire using extended function
-//
-// Returns:  true  successful
-//           false program voltage not available
-//
-OneWireMaster::CmdResult DS2465::OWPowerDown(void)
-{
-   // set power down bit in the global config state
-   m_curConfig.cPDN = true;
-
-   // write the new config
-   return WriteConfig(m_curConfig);
-}
-
-//--------------------------------------------------------------------------
-// Send 1 bit of communication to the 1-Wire Net and verify that the
-// response matches the 'applyPowerResponse' bit and apply power delivery
-// to the 1-Wire net.  Note that some implementations may apply the power
-// first and then turn it off if the response is incorrect.
-//
-// 'applyPowerResponse' - 1 bit response to check, if correct then start
-//                        power delivery 
-//
-// Returns:  true: bit written and response correct, strong pullup now on
-//           false: response incorrect
-//
-OneWireMaster::CmdResult DS2465::OWReadBitPower(uint8_t applyPowerResponse)
+OneWireMaster::CmdResult DS2465::ConfigurePowerDown(bool pdn_enable)
 {
   OneWireMaster::CmdResult result;
-  uint8_t rdbit;
-
-  // set strong pull-up enable
-  m_curConfig.cSPU = true;
-
-  // write the new config
-  result = WriteConfig(m_curConfig);
-  if (result != OneWireMaster::Success)
-    return result;
-
-  // perform read bit
-  result = OWReadBit(rdbit);
-  if (result != OneWireMaster::Success)
-    return result;
-
-  // check if response was correct, if not then turn off strong pull-up
-  if (rdbit != applyPowerResponse)
+  if (m_curConfig.cPDN != pdn_enable)
   {
-    OWLevel(LEVEL_NORMAL);
-    return OneWireMaster::OperationFailure;
+      m_curConfig.cPDN = pdn_enable;
+      result = WriteConfig(m_curConfig);
+      if (!pdn_enable) 
+        wait_ms(2); // Delay 2ms to allow units to power up
   }
-
-  return OneWireMaster::Success;
-}
-
-//--------------------------------------------------------------------------
-// Read 8 bits of communication from the 1-Wire Net.  After the
-// 8 bits are read then change the level of the 1-Wire net.
-//
-// Returns:  8 bits read from 1-Wire Net
-//
-OneWireMaster::CmdResult DS2465::OWReadBytePower(uint8_t & recvbyte)
-{
-  OneWireMaster::CmdResult result;
-  
-  // set strong pull-up enable
-  m_curConfig.cSPU = true;
-
-  // write the new config
-  result = WriteConfig(m_curConfig);
-  if (result != OneWireMaster::Success)
-    return result;
-
-  // do the read byte
-  result = OWReadByte(recvbyte);
+  else
+  {
+    result = OneWireMaster::Success;
+  }
   return result;
 }
 
 //--------------------------------------------------------------------------
-// Send 8 bits of communication to the 1-Wire Net and verify that the
-// 8 bits read from the 1-Wire Net is the same (write operation).  
-// The parameter 'sendbyte' least significant 8 bits are used.  After the
-// 8 bits are sent change the level of the 1-Wire net.
-//
-// 'sendbyte' - 8 bits to send (least significant bit)
-//
-OneWireMaster::CmdResult DS2465::OWWriteBytePower(uint8_t sendbyte)
-{
-  OneWireMaster::CmdResult result;
-  
-  // set strong pull-up enable
-  m_curConfig.cSPU = true;
-
-  // write the new config
-  result = WriteConfig(m_curConfig);
-  if (result != OneWireMaster::Success)
-    return result;
-
-  // perform write byte
-  return OWWriteByte(sendbyte);
-}
-
-//--------------------------------------------------------------------------
 // Set the 1-Wire Net line level pull-up to normal. The DS2465 does only
 // allows enabling strong pull-up on a bit or byte event. Consequently this
 // function only allows the MODE_STANDARD argument. To enable strong pull-up
@@ -508,7 +430,7 @@
       }
 
       // issue the search command 
-      OWWriteByte(0xF0);  
+      OneWireMaster::OWWriteByte(0xF0);  
 
       // loop to do the search
       do
@@ -677,33 +599,12 @@
 }
 
 //--------------------------------------------------------------------------
-// The 'OWBlock' transfers a block of data to and from the
-// 1-Wire Net. The result is returned in the same buffer.
-//
-// 'tran_buf' - pointer to a block of unsigned
-//              chars of length 'tran_len' that will be sent
-//              to the 1-Wire Net
-// 'tran_len' - length in bytes to transfer
-//
-OneWireMaster::CmdResult DS2465::OWBlock(uint8_t *tran_buf, uint8_t tran_len)
-{
-  OneWireMaster::CmdResult result;
-  for (uint8_t i = 0; i < tran_len; i++)
-  {
-    result = OWTouchByte(tran_buf[i]);
-    if (result != OneWireMaster::Success)
-      break;
-  }
-  return result;
-}
-
-//--------------------------------------------------------------------------
 // Send 8 bits of read communication to the 1-Wire Net and return the
 // result 8 bits read from the 1-Wire Net.
 //
 // Returns:  8 bits read from 1-Wire Net
 //
-OneWireMaster::CmdResult DS2465::OWReadByte(uint8_t & recvbyte)	
+OneWireMaster::CmdResult DS2465::OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level)	
 {
   OneWireMaster::CmdResult result;
   uint8_t buf;
@@ -716,6 +617,10 @@
   //                                  
   //  [] indicates from slave
   //  DD data read
+  
+  result = ConfigureSPU(after_level == LEVEL_STRONG);
+  if (result != OneWireMaster::Success)
+    return result;
    
   buf = CMD_1WRB;
   result = WriteMemory(ADDR_CMD_REG, &buf, 1);
@@ -742,7 +647,7 @@
 // Returns:  true: bytes written and echo was the same
 //           false: echo was not the same
 //
-OneWireMaster::CmdResult DS2465::OWWriteByte(uint8_t sendbyte)	
+OneWireMaster::CmdResult DS2465::OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level)	
 {    
   // 1-Wire Write Byte (Case B)
   //   S AD,0 [A] ADDR_CMD_REG [A] 1WWB [A] DD [A] Sr AD,1 [A] [Status] A [Status] A\ P
@@ -752,6 +657,11 @@
   //  DD data to write
   
   OneWireMaster::CmdResult result;
+  
+  result = ConfigureSPU(after_level == LEVEL_STRONG);
+  if (result != OneWireMaster::Success)
+    return result;
+  
   uint8_t command[2] = { CMD_1WWB, sendbyte };
   
   result = WriteMemory(ADDR_CMD_REG, command, 2);
@@ -772,7 +682,7 @@
 // Returns: 0:   0 bit read from sendbit
 //          1:   1 bit read from sendbit
 //
-OneWireMaster::CmdResult DS2465::OWTouchBit(uint8_t & sendrecvbit)	
+OneWireMaster::CmdResult DS2465::OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level)	
 {
   // 1-Wire bit (Case B)
   //   S AD,0 [A] ADDR_CMD_REG [A] 1WSB [A] BB [A] Sr AD,1 [A] [Status] A [Status] A\ P
@@ -782,6 +692,11 @@
   //  BB indicates byte containing bit value in msbit
 
   OneWireMaster::CmdResult result;
+  
+  result = ConfigureSPU(after_level == LEVEL_STRONG);
+  if (result != OneWireMaster::Success)
+    return result;
+  
   uint8_t command[2] = { CMD_1WSB, (sendrecvbit ? 0x80 : 0x00) };
   uint8_t status;
   
--- a/OneWire_Masters/DS2465/DS2465.hpp	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/DS2465/DS2465.hpp	Wed Mar 23 15:25:40 2016 -0500
@@ -58,25 +58,20 @@
   // 1-Wire Master Commands
   virtual OneWireMaster::CmdResult OWInitMaster(void);
   virtual OneWireMaster::CmdResult OWReset(void);                                   // Issues a 1-Wire Reset Pulse
-  virtual OneWireMaster::CmdResult OWSearch(RomId & romId);
-  virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte);
-  virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte);
-  virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit);
-  virtual OneWireMaster::CmdResult OWSpeed(OW_SPEED new_speed);
-  virtual OneWireMaster::CmdResult OWLevel(OW_LEVEL new_level);
+  virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level);
+  virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level);
+  virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level);
   virtual OneWireMaster::CmdResult OWReadBlock(uint8_t *rx_buf, uint8_t rx_len);
   virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
   OneWireMaster::CmdResult OWWriteBlock(bool tx_mac, const uint8_t *tran_buf, uint8_t tran_len);
-  OneWireMaster::CmdResult OWPowerDown(void);
-  OneWireMaster::CmdResult OWPowerUp(void);
-  OneWireMaster::CmdResult ConfigureAPU(bool apu_enable);
-  OneWireMaster::CmdResult Triplet(Direction search_direction, uint8_t & status);
+  virtual OneWireMaster::CmdResult OWSpeed(OW_SPEED new_speed);
+  virtual OneWireMaster::CmdResult OWLevel(OW_LEVEL new_level);
+  virtual OneWireMaster::CmdResult OWSearch(RomId & romId);
   
-  virtual OneWireMaster::CmdResult OWWriteBytePower(uint8_t sendbyte);
-  virtual OneWireMaster::CmdResult OWReadBytePower(uint8_t & recvbyte);
-  virtual OneWireMaster::CmdResult OWReadBitPower(uint8_t applyPowerResponse);
-  
-  virtual OneWireMaster::CmdResult OWBlock(uint8_t *tran_buf, uint8_t tran_len);
+  OneWireMaster::CmdResult ConfigurePowerDown(bool pdn_enable);
+  OneWireMaster::CmdResult ConfigureAPU(bool apu_enable);
+  OneWireMaster::CmdResult ConfigureSPU(bool spu_enable);
+  OneWireMaster::CmdResult Triplet(Direction search_direction, uint8_t & status);
   
   //DS2465 Coprocessor Commands
   OneWireMaster::CmdResult Compute_NextMasterSecret(bool swap, unsigned int pageNum, PageRegion region);
--- a/OneWire_Masters/DS2480B/ds2480b.cpp	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/DS2480B/ds2480b.cpp	Wed Mar 23 15:25:40 2016 -0500
@@ -62,7 +62,7 @@
 //*********************************************************************
 OneWireMaster::CmdResult Ds2480b::OWInitMaster(void)
 {
-  OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
+    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
     
     //TODO
     
@@ -81,20 +81,7 @@
 }
 
 
-//*********************************************************************
-OneWireMaster::CmdResult Ds2480b::OWTouchBit(uint8_t & sendrecvbit)
-{
-    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
-    
-    //TODO
-    
-    return result;
-}
-
-
-
-//*********************************************************************
-OneWireMaster::CmdResult Ds2480b::OWWriteByte(uint8_t sendbyte)
+OneWireMaster::CmdResult Ds2480b::OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
     
@@ -105,7 +92,18 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult Ds2480b::OWReadByte(uint8_t & recvbyte)
+OneWireMaster::CmdResult Ds2480b::OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level)
+{
+    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
+    
+    //TODO
+    
+    return result;
+}
+
+
+//*********************************************************************
+OneWireMaster::CmdResult Ds2480b::OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
     
@@ -167,33 +165,4 @@
     //TODO
     
     return result;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult Ds2480b::OWWriteBytePower(uint8_t sendbyte)
-{
-    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
-    
-    //TODO
-    
-    return result;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult Ds2480b::OWReadBitPower(uint8_t applyPowerResponse)
-{
-    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
-    
-    //TODO
-    
-    return result;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult Ds2480b::OWReadBytePower(uint8_t & recvbyte)
-{
-    return OneWireMaster::OperationFailure;
-}
+}
\ No newline at end of file
--- a/OneWire_Masters/DS2480B/ds2480b.h	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/DS2480B/ds2480b.h	Wed Mar 23 15:25:40 2016 -0500
@@ -94,11 +94,11 @@
     
     virtual OneWireMaster::CmdResult OWReset(void);
     
-    virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit);
+    virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level);
 
-    virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte);
+    virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level);
 
-    virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte);
+    virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level);
     
     virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
     
@@ -109,12 +109,6 @@
     virtual OneWireMaster::CmdResult OWSpeed(OW_SPEED new_speed);
 
     virtual OneWireMaster::CmdResult OWLevel(OW_LEVEL new_level);
-
-    virtual OneWireMaster::CmdResult OWWriteBytePower(uint8_t sendbyte);
-
-    virtual OneWireMaster::CmdResult OWReadBitPower(uint8_t applyPowerResponse);
-    
-    virtual OneWireMaster::CmdResult OWReadBytePower(uint8_t & recvbyte);
     
     private:
     
--- a/OneWire_Masters/DS248x/ds248x.cpp	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/DS248x/ds248x.cpp	Wed Mar 23 15:25:40 2016 -0500
@@ -397,10 +397,14 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult Ds248x::OWTouchBit(uint8_t & sendrecvbit)
+OneWireMaster::CmdResult Ds248x::OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result;
     
+    result = ConfigureSPU(after_level == LEVEL_STRONG);
+    if (result != OneWireMaster::Success)
+        return result;
+    
     uint8_t poll_count = 0;
     char status;
     char packet[] = {CMD_1WSB, sendrecvbit ? 0x80 : 0x00};
@@ -463,10 +467,14 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult Ds248x::OWWriteByte(uint8_t sendbyte)
+OneWireMaster::CmdResult Ds248x::OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result;
     
+    result = ConfigureSPU(after_level == LEVEL_STRONG);
+    if (result != OneWireMaster::Success)
+        return result;
+    
     uint8_t poll_count = 0;
     char status;
     char packet [] = {CMD_1WWB, sendbyte};
@@ -519,72 +527,89 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult Ds248x::OWReadByte(uint8_t & recvbyte)
+OneWireMaster::CmdResult Ds248x::OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result;
     
-    uint8_t poll_count = 0;
-    char data, status;
-    char packet[2] = {CMD_1WRB, 0};
-
-    // 1-Wire Read Bytes (Case C)
-    //   S AD,0 [A] 1WRB [A] Sr AD,1 [A] [Status] A [Status] A\
-    //                                   \--------/
-    //                     Repeat until 1WB bit has changed to 0
-    //   Sr AD,0 [A] SRP [A] E1 [A] Sr AD,1 [A] DD A\ P
-    //
-    //  [] indicates from slave
-    //  DD data read
-
-    if(_p_i2c_bus->write(_w_adrs, packet, 1) != I2C_WRITE_OK)
+    if (after_level == LEVEL_STRONG) // Enabling strong pull-up after a Read Byte command is not supported natively by the DS248x
     {
-        result = OneWireMaster::CommunicationWriteError;
+        uint8_t recvbit;
+        recvbyte = 0;
+        
+        for (unsigned int i = 1; i <= 8; i++)
+        {
+            // Set strong pull-up on last bit
+            result = OWReadBit(recvbit, (i == 8 ? LEVEL_STRONG : LEVEL_NORMAL));
+            if (result != Success)
+                break;
+            recvbyte = (recvbyte << 1) | recvbit;
+        }
     }
     else
     {
-        // loop checking 1WB bit for completion of 1-Wire operation
-        // abort if poll limit reached
-        //dummy write for loop 
-        result = OneWireMaster::Success; //so far
-        do 
+        uint8_t poll_count = 0;
+        char data, status;
+        char packet[2] = {CMD_1WRB, 0};
+
+        // 1-Wire Read Bytes (Case C)
+        //   S AD,0 [A] 1WRB [A] Sr AD,1 [A] [Status] A [Status] A\
+        //                                   \--------/
+        //                     Repeat until 1WB bit has changed to 0
+        //   Sr AD,0 [A] SRP [A] E1 [A] Sr AD,1 [A] DD A\ P
+        //
+        //  [] indicates from slave
+        //  DD data read
+
+        if(_p_i2c_bus->write(_w_adrs, packet, 1) != I2C_WRITE_OK)
         {
-            if(_p_i2c_bus->read(_r_adrs, &status, 1) != I2C_READ_OK)
-            {
-                result = OneWireMaster::CommunicationReadError;
-            }
-        } 
-        while ((status & STATUS_1WB) && (poll_count++ < POLL_LIMIT) && (result != OneWireMaster::CommunicationReadError));
-        
-        if((result == OneWireMaster::CommunicationReadError) || (poll_count >= POLL_LIMIT))
-        {
-            // check for failure due to poll limit reached
-            if (poll_count >= POLL_LIMIT) 
-            {
-                // handle error
-                // ...
-                reset();
-                result = OneWireMaster::TimeoutError;
-            }
+            result = OneWireMaster::CommunicationWriteError;
         }
         else
         {
-            packet[0] = CMD_SRP;
-            packet[1] = 0xE1;
-        
-            if(_p_i2c_bus->write(_w_adrs, packet, 2) != I2C_WRITE_OK)
+            // loop checking 1WB bit for completion of 1-Wire operation
+            // abort if poll limit reached
+            //dummy write for loop 
+            result = OneWireMaster::Success; //so far
+            do 
             {
-                result = OneWireMaster::CommunicationWriteError;
+                if(_p_i2c_bus->read(_r_adrs, &status, 1) != I2C_READ_OK)
+                {
+                    result = OneWireMaster::CommunicationReadError;
+                }
+            } 
+            while ((status & STATUS_1WB) && (poll_count++ < POLL_LIMIT) && (result != OneWireMaster::CommunicationReadError));
+            
+            if((result == OneWireMaster::CommunicationReadError) || (poll_count >= POLL_LIMIT))
+            {
+                // check for failure due to poll limit reached
+                if (poll_count >= POLL_LIMIT) 
+                {
+                    // handle error
+                    // ...
+                    reset();
+                    result = OneWireMaster::TimeoutError;
+                }
             }
             else
             {
-                if(_p_i2c_bus->read(_r_adrs, &data, 1) != I2C_READ_OK)
+                packet[0] = CMD_SRP;
+                packet[1] = 0xE1;
+            
+                if(_p_i2c_bus->write(_w_adrs, packet, 2) != I2C_WRITE_OK)
                 {
-                    result = OneWireMaster::CommunicationReadError;
+                    result = OneWireMaster::CommunicationWriteError;
                 }
                 else
                 {
-                    recvbyte = data;
-                    result = OneWireMaster::Success;
+                    if(_p_i2c_bus->read(_r_adrs, &data, 1) != I2C_READ_OK)
+                    {
+                        result = OneWireMaster::CommunicationReadError;
+                    }
+                    else
+                    {
+                        recvbyte = data;
+                        result = OneWireMaster::Success;
+                    }
                 }
             }
         }
@@ -601,7 +626,7 @@
     
     for(uint8_t idx = 0; idx < tran_len; idx++)
     {
-        result = OWWriteByte(tran_buf[idx]);
+        result = OneWireMaster::OWWriteByte(tran_buf[idx]);
         if(result != OneWireMaster::Success)
         {
             break;
@@ -620,7 +645,7 @@
     for(uint8_t idx = 0; idx < rx_len; idx++)
     {
         //OwReadByte() uses pass by reference
-        result = OWReadByte(rx_buf[idx]);
+        result = OneWireMaster::OWReadByte(rx_buf[idx]);
         if(result != OneWireMaster::Success)
         {
             break;
@@ -664,7 +689,7 @@
       }
 
       // issue the search command 
-      OWWriteByte(0xF0);  
+      OneWireMaster::OWWriteByte(0xF0);  
 
       // loop to do the search
       do
@@ -799,82 +824,19 @@
 }
 
 
-//*********************************************************************
-OneWireMaster::CmdResult Ds248x::OWWriteBytePower(uint8_t sendbyte)
-{
-    OneWireMaster::CmdResult result;
-    
-    // set strong pull-up enable
-    _cSPU = CONFIG_SPU;
-    
-    // write the new config
-    result = write_config(_c1WS | _cSPU | _cPDN | _cAPU);
-    if (result == OneWireMaster::Success)
-    {
-        // perform write byte
-        result = OWWriteByte(sendbyte);
-    }
-    
-    return result;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult Ds248x::OWReadBitPower(uint8_t applyPowerResponse)
+OneWireMaster::CmdResult Ds248x::ConfigureSPU(bool spu_enable)
 {
-    OneWireMaster::CmdResult result;
-    uint8_t rdbit;
-
-    // set strong pull-up enable
-    _cSPU = CONFIG_SPU;
-
-    // write the new config
-    result = write_config(_c1WS | _cSPU | _cPDN | _cAPU);
-    if (result == OneWireMaster::Success)
-    {
-        // perform read bit
-        result = OWReadBit(rdbit);
-        if(result == OneWireMaster::Success)
-        {
-            // check if response was correct, if not then turn off strong pull-up
-            if (rdbit != applyPowerResponse) 
-            {
-                OWLevel(LEVEL_NORMAL);
-                result = OneWireMaster::OperationFailure;
-            }
-        }
-    }
-
-    return result;
-}
-
-
-OneWireMaster::CmdResult Ds248x::OWReadBytePower(uint8_t & recvbyte)
-{
-    OneWireMaster::CmdResult result = Success;
-    uint8_t recvbit;
-    
-    recvbyte = 0;
-    for (unsigned int i = 1; i <= 8; i++)
-    {
-        // Set strong pull-up on last bit
-        if (i == 8)
-        {
-            // set strong pull-up enable
-            _cSPU = CONFIG_SPU;
-
-            // write the new config
-            result = write_config(_c1WS | _cSPU | _cPDN | _cAPU);
-            if (result != Success)
-                break;
-        }
-        result = OWReadBit(recvbit);
-        if (result != Success)
-            break;
-        recvbyte = (recvbyte << 1) | recvbit;
-    }
-    
-    return result;
+  OneWireMaster::CmdResult result;
+  if ((_cSPU == CONFIG_SPU) != spu_enable)
+  {
+    _cSPU = spu_enable;
+    result =  write_config(_c1WS | _cSPU | _cPDN | _cAPU);
+  }
+  else
+  {
+    result = OneWireMaster::Success;
+  }
+  return result;
 }
 
 
--- a/OneWire_Masters/DS248x/ds248x.h	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/DS248x/ds248x.h	Wed Mar 23 15:25:40 2016 -0500
@@ -269,11 +269,11 @@
     
     virtual OneWireMaster::CmdResult OWReset(void);
     
-    virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit);
-
-    virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte);
-
-    virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte);
+    virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level);
+    
+    virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level);
+    
+    virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level);
     
     virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
     
@@ -284,12 +284,8 @@
     virtual OneWireMaster::CmdResult OWSpeed(OW_SPEED new_speed);
 
     virtual OneWireMaster::CmdResult OWLevel(OW_LEVEL new_level);
-
-    virtual OneWireMaster::CmdResult OWWriteBytePower(uint8_t sendbyte);
-
-    virtual OneWireMaster::CmdResult OWReadBitPower(uint8_t applyPowerResponse);
     
-    virtual OneWireMaster::CmdResult OWReadBytePower(uint8_t & recvbyte);
+    OneWireMaster::CmdResult ConfigureSPU(bool spu_enable);
     
     private:
     
--- a/OneWire_Masters/GPIO/owgpio.cpp	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/GPIO/owgpio.cpp	Wed Mar 23 15:25:40 2016 -0500
@@ -137,7 +137,7 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult OwGpio::OWTouchBit(uint8_t & sendrecvbit)
+OneWireMaster::CmdResult OwGpio::OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level)
 {
     uint16_t low_time;
     uint32_t ow_micro_second(SystemCoreClock/1000000);
@@ -209,15 +209,14 @@
 }
 
 
-
 //*********************************************************************
-OneWireMaster::CmdResult OwGpio::OWWriteByte(uint8_t sendbyte)
+OneWireMaster::CmdResult OwGpio::OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result;
     
     for(uint8_t idx = 0; idx < 8; idx++)
     {
-        result = OWWriteBit(0x01 & (sendbyte >> idx));
+        result = OneWireMaster::OWWriteBit(0x01 & (sendbyte >> idx));
         if(result != OneWireMaster::Success)
         {
             break;
@@ -229,7 +228,7 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult OwGpio::OWReadByte(uint8_t & recvbyte)
+OneWireMaster::CmdResult OwGpio::OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level)
 {
     OneWireMaster::CmdResult result;
     uint8_t recvbit;
@@ -240,7 +239,7 @@
     {
         //OWReadBit sets recvbit on entry for read op
         //and then sends to OWTouchbit
-        result = OWReadBit(recvbit);
+        result = OneWireMaster::OWReadBit(recvbit);
         if(result != OneWireMaster::Success)
         {
             break;
@@ -262,7 +261,7 @@
     
     for(uint8_t idx = 0; idx < tran_len; idx++)
     {
-        result = OWWriteByte(tran_buf[idx]);
+        result = OneWireMaster::OWWriteByte(tran_buf[idx]);
         if(result != OneWireMaster::Success)
         {
             break;
@@ -281,7 +280,7 @@
     for(uint8_t idx = 0; idx < rx_len; idx++)
     {
         //OWReadByte() uses pass by reference
-        result = OWReadByte(rx_buf[idx]);
+        result = OneWireMaster::OWReadByte(rx_buf[idx]);
         if(result != OneWireMaster::Success)
         {
             break;
@@ -327,14 +326,14 @@
       }
 
       // issue the search command 
-      OWWriteByte(0xF0);  
+      OneWireMaster::OWWriteByte(0xF0);  
 
       // loop to do the search
       do
       {
          // read a bit and its complement
-         OWReadBit(id_bit);
-         OWReadBit(cmp_id_bit);
+         OneWireMaster::OWReadBit(id_bit);
+         OneWireMaster::OWReadBit(cmp_id_bit);
 
          // check for no devices on 1-wire
          if ((id_bit == 1) && (cmp_id_bit == 1))
@@ -373,7 +372,7 @@
               romId[rom_byte_number] &= ~rom_byte_mask;
 
             // serial number search direction write bit
-            OWWriteBit(search_direction);
+            OneWireMaster::OWWriteBit(search_direction);
 
             // increment the byte counter id_bit_number
             // and shift the mask rom_byte_mask
@@ -437,31 +436,6 @@
 
 
 //*********************************************************************
-OneWireMaster::CmdResult OwGpio::OWWriteBytePower(uint8_t sendbyte)
-{
-    //TODO
-    
-    return OneWireMaster::OperationFailure;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult OwGpio::OWReadBitPower(uint8_t applyPowerResponse)
-{
-    //TODO
-    
-    return OneWireMaster::OperationFailure;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult OwGpio::OWReadBytePower(uint8_t & recvbyte)
-{
-    return OneWireMaster::OperationFailure;
-}
-
-
-//*********************************************************************
 void OwGpio::init_ow_gpio(uint32_t ow_port, uint32_t ow_pin)
 {
     if (MXC_CLKMAN->clk_ctrl_1_gpio == MXC_E_CLKMAN_CLK_SCALE_DISABLED) 
--- a/OneWire_Masters/GPIO/owgpio.h	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/GPIO/owgpio.h	Wed Mar 23 15:25:40 2016 -0500
@@ -44,7 +44,7 @@
 
 class OwGpio: public OneWireMaster
 {
-    public:
+public:
     
     //1-wire timming constants for bit-bang. 
     //Bit-Bang Master only supported  on MAX32600MBED board
@@ -74,10 +74,6 @@
     static const uint16_t TSLOT_OVD = 10;
     
     
-    //counts instances of this class being created
-    static uint32_t ow_instance_cnt;
-    
-    
     /**********************************************************//**
     * @brief Owgpio constructor
     * 
@@ -117,11 +113,11 @@
     
     virtual OneWireMaster::CmdResult OWReset(void);
     
-    virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit);
+    virtual OneWireMaster::CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level);
 
-    virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte);
+    virtual OneWireMaster::CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level);
 
-    virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte);
+    virtual OneWireMaster::CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level);
     
     virtual OneWireMaster::CmdResult OWWriteBlock(const uint8_t *tran_buf, uint8_t tran_len);
     
@@ -132,14 +128,11 @@
     virtual OneWireMaster::CmdResult OWSpeed(OW_SPEED new_speed);
 
     virtual OneWireMaster::CmdResult OWLevel(OW_LEVEL new_level);
-
-    virtual OneWireMaster::CmdResult OWWriteBytePower(uint8_t sendbyte);
+    
+private:
 
-    virtual OneWireMaster::CmdResult OWReadBitPower(uint8_t applyPowerResponse);
-    
-    virtual OneWireMaster::CmdResult OWReadBytePower(uint8_t & recvbyte);
-    
-    private:
+    //counts instances of this class being created
+    static uint32_t ow_instance_cnt;
     
     static void init_ow_timer(void);
     static void release_ow_timer(void);
--- a/OneWire_Masters/OneWireMaster.cpp	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/OneWireMaster.cpp	Wed Mar 23 15:25:40 2016 -0500
@@ -37,54 +37,6 @@
 const uint16_t OneWireMaster::_oddparity[] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
 
 
-//*********************************************************************
-OneWireMaster::CmdResult OneWireMaster::OWWriteBit(uint8_t sendbit)
-{
-    return OWTouchBit(sendbit);
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult OneWireMaster::OWReadBit(uint8_t & recvbit)
-{
-    recvbit = 0x01;
-    return(OWTouchBit(recvbit)); 
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult OneWireMaster::OWTouchByte(uint8_t & sendrecvbyte)
-{
-    OneWireMaster::CmdResult result = OWWriteByte(sendrecvbyte);
-
-    if (result == OneWireMaster::Success)
-    {
-        OWReadByte(sendrecvbyte);
-    }
-    
-    return result;
-}
-
-
-//*********************************************************************
-OneWireMaster::CmdResult OneWireMaster::OWBlock(uint8_t *tran_buf, uint8_t tran_len)
-{
-    OneWireMaster::CmdResult result;
-    
-    for (uint8_t i = 0; i < tran_len; i++) 
-    {
-        result = OWTouchByte(tran_buf[i]);
-        
-        if (result != OneWireMaster::Success)
-        {
-            break;
-        }
-    }
-    
-    return result;
-}
-
-
 OneWireMaster::CmdResult OneWireMaster::OWFirst(RomId & romId)
 {
     // reset the search state
--- a/OneWire_Masters/OneWireMaster.h	Tue Mar 22 15:18:00 2016 -0500
+++ b/OneWire_Masters/OneWireMaster.h	Wed Mar 23 15:25:40 2016 -0500
@@ -68,6 +68,8 @@
     
     static uint16_t calculateCRC16(const uint8_t * data, size_t data_offset, size_t data_len, uint16_t crc = 0);
     
+    virtual ~OneWireMaster() { }
+    
     
     /**********************************************************//**
     * @brief OWInitMaster()
@@ -116,7 +118,7 @@
     *
     * @return CmdResult - zero on success, non-zero on failure
     **************************************************************/
-    virtual CmdResult OWTouchBit(uint8_t & sendrecvbit) = 0;
+    virtual CmdResult OWTouchBit(uint8_t & sendrecvbit, OW_LEVEL after_level) = 0;
     
     
     /**********************************************************//**
@@ -134,7 +136,7 @@
     *
     * @return CmdResult - zero on success, non-zero on failure
     **************************************************************/
-    virtual CmdResult OWWriteByte(uint8_t sendbyte) = 0;
+    virtual CmdResult OWWriteByte(uint8_t sendbyte, OW_LEVEL after_level) = 0;
     
     
     /**********************************************************//**
@@ -149,7 +151,7 @@
     *
     * @return CmdResult - zero on success, non-zero on failure
     **************************************************************/
-    virtual CmdResult OWReadByte(uint8_t & recvbyte) = 0;
+    virtual CmdResult OWReadByte(uint8_t & recvbyte, OW_LEVEL after_level) = 0;
     
     
     /**********************************************************//**
@@ -243,116 +245,17 @@
     **************************************************************/
     virtual CmdResult OWLevel(OW_LEVEL new_level) = 0;
     
-    
-    /**********************************************************//**
-    * @brief OWWriteBytePower()
-    * 
-    * @details Send 8 bits of communication to the 1-Wire Net and 
-    *          verify that the 8 bits read from the 1-Wire Net is the 
-    *          same (write operation).  The parameter 'sendbyte' least 
-    *          significant 8 bits are used.  After the 8 bits are sent 
-    *          change the level of the 1-Wire net.
-    *
-    * On Entry:
-    *     @param[in] 'sendbyte' - 8 bits to send (least significant bit)
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    virtual CmdResult OWWriteBytePower(uint8_t sendbyte) = 0;
-    
-    
-    /**********************************************************//**
-    * @brief OWReadBitPower()
-    * 
-    * @details Send 1 bit of communication to the 1-Wire Net and verify
-    *          that the response matches the 'applyPowerResponse' bit 
-    *          and apply power delivery to the 1-Wire net.  Note that 
-    *          some implementations may apply the power first and then 
-    *          turn it off if the response is incorrect. 
-    *
-    * On Entry:
-    *     @param[in] 'applyPowerResponse' - 1 bit response to check, 
-    *                                       if correct 
-    *                                       then start power delivery 
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    virtual CmdResult OWReadBitPower(uint8_t applyPowerResponse) = 0;
-    
-    
-    virtual CmdResult OWReadBytePower(uint8_t & recvbyte) = 0;
-
-    
-    //Part of OneWireInterface that should only be implemented once
-    
+    CmdResult OWWriteBit(uint8_t sendbit, OW_LEVEL after_level) { return OWTouchBit(sendbit, after_level); }
+    CmdResult OWReadBit(uint8_t & recvbit, OW_LEVEL after_level) { recvbit = 0x01; return OWTouchBit(recvbit, after_level); }
     
-    /**********************************************************//**
-    * @brief OWWriteBit()
-    * 
-    * @details Send 1 bit of communication to the 1-Wire Net.
-    *          The parameter 'sendbit' least significant bit is used.
-    *
-    * On Entry:
-    *     @param[in] 'sendbit' - 1 bit to send (least significant byte)
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    CmdResult OWWriteBit(uint8_t sendbit);
-    
-    
-    /**********************************************************//**
-    * @brief OWReadBit()
-    * 
-    * @details Reads 1 bit of communication from the 1-Wire Net and 
-    *          returns the result
-    *
-    * On Entry:
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    CmdResult OWReadBit(uint8_t & recvbit);
-    
-    
-    /**********************************************************//**
-    * @brief OWTouchByte()
-    * 
-    * @details Send 8 bits of communication to the 1-Wire Net and 
-    *        return the result 8 bits read from the 1-Wire Net.  The 
-    *        parameter 'sendbyte' least significant 8 bits are used 
-    *        and the least significant 8 bits of the result is the 
-    *        return byte.
-    *
-    * On Entry:
-    *     @param[in] 'sendbyte' - 8 bits to send (least significant byte)
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure
-    **************************************************************/
-    virtual CmdResult OWTouchByte(uint8_t & sendrecvbyte);
-    
-    
-    /**********************************************************//**
-    * @brief OWBlock()
-    * 
-    * @details The 'OWBlock' transfers a block of data to and from the
-    *        1-Wire Net. The result is returned in the same buffer.
-    *
-    * On Entry:
-    *     @param[in] 'tran_buf' - pointer to a block of unsigned
-    *                             chars of length 'tran_len' that 
-    *                             will be sent to the 1-Wire Net
-    *     @param[in] 'tran_len' - length in bytes to transfer
-    *
-    * On Exit:
-    *
-    * @return CmdResult - zero on success, non-zero on failure 
-    **************************************************************/
-    virtual CmdResult OWBlock(uint8_t *tran_buf, uint8_t tran_len);
+    CmdResult OWWriteBit(uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_NORMAL); }
+    CmdResult OWReadBit(uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_NORMAL); }
+    CmdResult OWWriteBitPower(uint8_t sendbit) { return OWWriteBit(sendbit, LEVEL_STRONG); }
+    CmdResult OWReadBitPower(uint8_t & recvbit) { return OWReadBit(recvbit, LEVEL_STRONG); }
+    CmdResult OWWriteByte(uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_NORMAL); }
+    CmdResult OWReadByte(uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_NORMAL); }
+    CmdResult OWWriteBytePower(uint8_t sendbyte) { return OWWriteByte(sendbyte, LEVEL_STRONG); }
+    CmdResult OWReadBytePower(uint8_t & recvbyte) { return OWReadByte(recvbyte, LEVEL_STRONG); }
     
     
     /**********************************************************//**