Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
69:f915c4c59a69
Parent:
48:6f9208ae280e
Child:
71:562f5c702094
--- a/OneWire_Masters/DS2465/DS2465.cpp	Fri Apr 22 10:36:53 2016 -0500
+++ b/OneWire_Masters/DS2465/DS2465.cpp	Mon May 09 08:29:49 2016 -0500
@@ -40,13 +40,13 @@
 std::uint8_t DS2465::Config::readByte() const
 {
   std::uint8_t config = 0;
-  if (c1WS)
+  if (c1WS())
     config |= 0x08;
-  if (cSPU)
+  if (cSPU())
     config |= 0x04;
-  if (cPDN)
+  if (cPDN())
     config |= 0x02;
-  if (cAPU)
+  if (cAPU())
     config |= 0x01;
   return config;
 }
@@ -59,8 +59,10 @@
 
 void DS2465::Config::reset()
 {
-  c1WS = cSPU = cPDN = false;
-  cAPU = true;
+  setC1WS(false);
+  setCSPU(false);
+  setCPDN(false);
+  setCAPU(true);
 }
 
 DS2465::DS2465(I2C & I2C_interface, std::uint8_t I2C_address)
@@ -197,10 +199,10 @@
 OneWireMaster::CmdResult DS2465::configureLevel(OWLevel level)
 {
   OneWireMaster::CmdResult result;
-  if (m_curConfig.cSPU != (level == LEVEL_STRONG))
+  if (m_curConfig.cSPU() != (level == LEVEL_STRONG))
   {
     Config newConfig = m_curConfig;
-    newConfig.cSPU = (level == LEVEL_STRONG);
+    newConfig.setCSPU(level == LEVEL_STRONG);
     result = writeConfig(newConfig, true);
   }
   else
@@ -221,12 +223,12 @@
 OneWireMaster::CmdResult DS2465::OWSetSpeed(OWSpeed new_speed)
 {
   // Requested speed is already set
-  if (m_curConfig.c1WS == (new_speed == SPEED_OVERDRIVE))
+  if (m_curConfig.c1WS() == (new_speed == SPEED_OVERDRIVE))
     return OneWireMaster::Success;
        
   // set the speed
   Config newConfig = m_curConfig;
-  newConfig.c1WS = (new_speed == SPEED_OVERDRIVE);
+  newConfig.setC1WS(new_speed == SPEED_OVERDRIVE);
 
   // write the new config
   return writeConfig(newConfig, true);
@@ -316,9 +318,6 @@
 
 OneWireMaster::CmdResult DS2465::OWReadByte(std::uint8_t & recvbyte, OWLevel after_level)	
 {
-  OneWireMaster::CmdResult result;
-  std::uint8_t buf;
-
   // 1-Wire Read Bytes (Case C)
   //   S AD,0 [A] ADDR_CMD_REG [A] 1WRB [A] Sr AD,1 [A] [Status] A [Status] A 
   //                                                  \--------/        
@@ -328,6 +327,9 @@
   //  [] indicates from slave
   //  DD data read
   
+  OneWireMaster::CmdResult result;
+  std::uint8_t buf;
+  
   result = configureLevel(after_level);
   if (result != OneWireMaster::Success)
     return result;
@@ -473,7 +475,7 @@
   // loop to read each byte, NAK last byte
   for (i = 0; i < bufLen; i++)
   {
-     buf[i] = m_I2C_interface.read((i == (bufLen - 1)) ? m_I2C_interface.NoACK : m_I2C_interface.ACK);
+     buf[i] = m_I2C_interface.read((i == (bufLen - 1)) ? I2C::NoACK : I2C::ACK);
   }
   m_I2C_interface.stop();
   
@@ -506,11 +508,6 @@
   return result;
 }
 
-DS2465::Config DS2465::currentConfig() const
-{
-  return m_curConfig;
-}
-
 OneWireMaster::CmdResult DS2465::pollBusy(std::uint8_t * pStatus)
 {
   const unsigned int pollLimit = 200;