1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.

Dependents:   MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more

Superseded by MaximInterface.

Revision:
35:5d23395628f6
Parent:
34:11fffbe98ef9
Child:
47:307dc45952db
--- a/OneWire_Masters/DS2465/DS2465.cpp	Fri Apr 01 09:29:55 2016 -0500
+++ b/OneWire_Masters/DS2465/DS2465.cpp	Fri Apr 01 14:29:22 2016 -0500
@@ -255,8 +255,9 @@
   OneWireMaster::CmdResult result;
   if (m_curConfig.cSPU != (level == LEVEL_STRONG))
   {
-    m_curConfig.cSPU = (level == LEVEL_STRONG);
-    result = writeConfig(m_curConfig, true);
+    Config newConfig = m_curConfig;
+    newConfig.cSPU = (level == LEVEL_STRONG);
+    result = writeConfig(newConfig, true);
   }
   else
   {
@@ -300,10 +301,11 @@
     return OneWireMaster::Success;
        
   // set the speed
-  m_curConfig.c1WS = (new_speed == SPEED_OVERDRIVE);
+  Config newConfig = m_curConfig;
+  newConfig.c1WS = (new_speed == SPEED_OVERDRIVE);
 
   // write the new config
-  return writeConfig(m_curConfig, true);
+  return writeConfig(newConfig, true);
 }
 
 //--------------------------------------------------------------------------
@@ -639,25 +641,28 @@
 //
 OneWireMaster::CmdResult DS2465::writeConfig(const Config & config, bool verify)
 {
-   std::uint8_t configBuf;
-   OneWireMaster::CmdResult result;
+  std::uint8_t configBuf;
+  OneWireMaster::CmdResult result;
    
-   configBuf = config.writeByte();
-   result = writeMemory(ADDR_WCFG_REG, &configBuf, 1);
-   if (verify)
-   {
-     if (result == OneWireMaster::Success)
-     {
-       result = readMemory(ADDR_WCFG_REG, &configBuf, 1);
-     }
-     if (result == OneWireMaster::Success)
-     {
-       if (configBuf != config.readByte())
-         result = OneWireMaster::OperationFailure;
-     }
-   }
-   
-   return result;
+  configBuf = config.writeByte();
+  result = writeMemory(ADDR_WCFG_REG, &configBuf, 1);
+  if (verify)
+  {
+    if (result == OneWireMaster::Success)
+    {
+      result = readMemory(ADDR_WCFG_REG, &configBuf, 1);
+    }
+    if (result == OneWireMaster::Success)
+    {
+      if (configBuf != config.readByte())
+        result = OneWireMaster::OperationFailure;
+    }
+  }
+  
+  if (result == OneWireMaster::Success)
+    m_curConfig = config;
+
+  return result;
 }
 
 
@@ -764,11 +769,9 @@
   result = reset();
   if (result != OneWireMaster::Success)
     return result;
-  
-  // default configuration
-   m_curConfig.reset();
 
-   // write the default configuration setup
-   result = writeConfig(m_curConfig, true);
-   return result;
-}
+  // write the default configuration setup
+  Config defaultConfig;
+  result = writeConfig(defaultConfig, true);
+  return result;
+}
\ No newline at end of file