Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
24:8942d8478d68
Parent:
23:e8e403d61359
Child:
26:a361e3f42ba5
--- a/OneWire_Masters/OneWireMaster.cpp	Mon Mar 21 23:18:45 2016 +0000
+++ b/OneWire_Masters/OneWireMaster.cpp	Tue Mar 22 14:24:53 2016 -0500
@@ -108,9 +108,7 @@
 OneWireMaster::CmdResult OneWireMaster::OWVerify(const RomId & romId)
 {
     OneWireMaster::CmdResult result;
-    
     RomId romIdCopy(romId);
-    
     int ld_backup, ldf_backup, lfd_backup;
 
     // keep a backup copy of the current state
@@ -178,13 +176,12 @@
 OneWireMaster::CmdResult OneWireMaster::OWReadROM(RomId & romId)
 {
     OneWireMaster::CmdResult result;
-    
     uint8_t buf[2 + RomId::byteLen];
 
     result = OWReset();
     if (result == OneWireMaster::Success)
     {
-        result = OWWriteByte(0x33); // READ ROM
+        result = OWWriteByte(READ_ROM);
     }
 
     // read the ROM
@@ -194,7 +191,7 @@
     }
     
     // verify CRC8
-    if ((result == OneWireMaster::Success) && romId.crc8Valid() && (buf[1] != 0))
+    if ((result == OneWireMaster::Success) && (RomId::calculateCRC8(buf, RomId::byteLen) == 0))
     {
         romId = RomId(reinterpret_cast<std::uint8_t (&)[RomId::byteLen]>(buf[0]));
     }
@@ -211,7 +208,7 @@
     result = OWReset();
     if (result == OneWireMaster::Success) 
     {
-        result = OWWriteByte(0xCC);
+        result = OWWriteByte(SKIP_ROM);
     }
     
     return result;
@@ -229,7 +226,7 @@
     result = OWReset();
     if (result == OneWireMaster::Success) 
     {
-        buf[0] = 0x55;
+        buf[0] = MATCH_ROM;
         std::memcpy(&buf[1], romId, RomId::byteLen);
         // send command and rom
         result = OWWriteBlock(buf, 1 + RomId::byteLen);
@@ -251,7 +248,7 @@
     
     if (result == OneWireMaster::Success)
     {
-        result = OWWriteByte(0x3C);
+        result = OWWriteByte(OVERDRIVE_SKIP_ROM);
     }
     
     if (result == OneWireMaster::Success)
@@ -274,7 +271,7 @@
     result = OWReset();
     if (result == OneWireMaster::Success) 
     {
-        result = OWWriteByte(0x69);
+        result = OWWriteByte(OVERDRIVE_MATCH_ROM);
         if (result == OneWireMaster::Success) 
         {
             OWSpeed(SPEED_OVERDRIVE);
@@ -294,7 +291,7 @@
     result = OWReset();
     if (result == OneWireMaster::Success) 
     {
-        result = OWWriteByte(0xA5);
+        result = OWWriteByte(RESUME);
     }
     
     return result;