Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
23:e8e403d61359
Parent:
21:00c94aeb533e
Child:
24:8942d8478d68
diff -r 686273e55cdc -r e8e403d61359 OneWire_Masters/OneWireMaster.cpp
--- a/OneWire_Masters/OneWireMaster.cpp	Mon Mar 21 21:41:36 2016 +0000
+++ b/OneWire_Masters/OneWireMaster.cpp	Mon Mar 21 23:18:45 2016 +0000
@@ -38,14 +38,14 @@
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWWriteBit(uint8_t sendbit)
+OneWireMaster::CmdResult OneWireMaster::OWWriteBit(uint8_t sendbit)
 {
     return OWTouchBit(sendbit);
 }
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWReadBit(uint8_t & recvbit)
+OneWireMaster::CmdResult OneWireMaster::OWReadBit(uint8_t & recvbit)
 {
     recvbit = 0x01;
     return(OWTouchBit(recvbit)); 
@@ -53,11 +53,11 @@
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWTouchByte(uint8_t & sendrecvbyte)
+OneWireMaster::CmdResult OneWireMaster::OWTouchByte(uint8_t & sendrecvbyte)
 {
-    OneWireInterface::CmdResult result = OWWriteByte(sendrecvbyte);
+    OneWireMaster::CmdResult result = OWWriteByte(sendrecvbyte);
 
-    if (result == OneWireInterface::Success)
+    if (result == OneWireMaster::Success)
     {
         OWReadByte(sendrecvbyte);
     }
@@ -67,15 +67,15 @@
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWBlock(uint8_t *tran_buf, uint8_t tran_len)
+OneWireMaster::CmdResult OneWireMaster::OWBlock(uint8_t *tran_buf, uint8_t tran_len)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     for (uint8_t i = 0; i < tran_len; i++) 
     {
         result = OWTouchByte(tran_buf[i]);
         
-        if (result != OneWireInterface::Success)
+        if (result != OneWireMaster::Success)
         {
             break;
         }
@@ -85,7 +85,7 @@
 }
 
 
-OneWireInterface::CmdResult OneWireMaster::OWFirst(RomId & romId)
+OneWireMaster::CmdResult OneWireMaster::OWFirst(RomId & romId)
 {
     // reset the search state
     _last_discrepancy = 0;
@@ -97,7 +97,7 @@
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWNext(RomId & romId)
+OneWireMaster::CmdResult OneWireMaster::OWNext(RomId & romId)
 {
     // leave the search state alone
     return OWSearch(romId);
@@ -105,9 +105,9 @@
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWVerify(const RomId & romId)
+OneWireMaster::CmdResult OneWireMaster::OWVerify(const RomId & romId)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     RomId romIdCopy(romId);
     
@@ -123,12 +123,12 @@
     _last_device_flag = false;
 
     result = OWSearch(romIdCopy);
-    if (result == OneWireInterface::Success) 
+    if (result == OneWireMaster::Success) 
     {
         // check if same device found
         if (romId != romIdCopy) 
         {
-            result = OneWireInterface::OperationFailure;
+            result = OneWireMaster::OperationFailure;
         }
     }
 
@@ -175,26 +175,26 @@
 
 
 //*********************************************************************
-OneWireInterface::CmdResult OneWireMaster::OWReadROM(RomId & romId)
+OneWireMaster::CmdResult OneWireMaster::OWReadROM(RomId & romId)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     uint8_t buf[2 + RomId::byteLen];
 
     result = OWReset();
-    if (result == OneWireInterface::Success)
+    if (result == OneWireMaster::Success)
     {
         result = OWWriteByte(0x33); // READ ROM
     }
 
     // read the ROM
-    if (result == OneWireInterface::Success)
+    if (result == OneWireMaster::Success)
     {
         result = OWReadBlock(buf, RomId::byteLen);
     }
     
     // verify CRC8
-    if ((result == OneWireInterface::Success) && romId.crc8Valid() && (buf[1] != 0))
+    if ((result == OneWireMaster::Success) && romId.crc8Valid() && (buf[1] != 0))
     {
         romId = RomId(reinterpret_cast<std::uint8_t (&)[RomId::byteLen]>(buf[0]));
     }
@@ -204,12 +204,12 @@
     
 
 //*********************************************************************    
-OneWireInterface::CmdResult OneWireMaster::OWSkipROM(void)
+OneWireMaster::CmdResult OneWireMaster::OWSkipROM(void)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     result = OWReset();
-    if (result == OneWireInterface::Success) 
+    if (result == OneWireMaster::Success) 
     {
         result = OWWriteByte(0xCC);
     }
@@ -219,15 +219,15 @@
     
 
 //*********************************************************************    
-OneWireInterface::CmdResult OneWireMaster::OWMatchROM(const RomId & romId)
+OneWireMaster::CmdResult OneWireMaster::OWMatchROM(const RomId & romId)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     uint8_t buf[1 + RomId::byteLen];
 
     // use MatchROM
     result = OWReset();
-    if (result == OneWireInterface::Success) 
+    if (result == OneWireMaster::Success) 
     {
         buf[0] = 0x55;
         std::memcpy(&buf[1], romId, RomId::byteLen);
@@ -240,21 +240,21 @@
     
 
 //*********************************************************************    
-OneWireInterface::CmdResult OneWireMaster::OWOverdriveSkipROM(void)
+OneWireMaster::CmdResult OneWireMaster::OWOverdriveSkipROM(void)
 {
-    OneWireInterface::CmdResult result = OWSpeed(SPEED_STANDARD);
+    OneWireMaster::CmdResult result = OWSpeed(SPEED_STANDARD);
     
-    if (result == OneWireInterface::Success)
+    if (result == OneWireMaster::Success)
     {
         result = OWReset();
     }
     
-    if (result == OneWireInterface::Success)
+    if (result == OneWireMaster::Success)
     {
         result = OWWriteByte(0x3C);
     }
     
-    if (result == OneWireInterface::Success)
+    if (result == OneWireMaster::Success)
     {
         result = OWSpeed(SPEED_OVERDRIVE);
     }
@@ -264,18 +264,18 @@
     
 
 //*********************************************************************    
-OneWireInterface::CmdResult OneWireMaster::OWOverdriveMatchROM(const RomId & romId)
+OneWireMaster::CmdResult OneWireMaster::OWOverdriveMatchROM(const RomId & romId)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     // use overdrive MatchROM
     OWSpeed(SPEED_STANDARD);
     
     result = OWReset();
-    if (result == OneWireInterface::Success) 
+    if (result == OneWireMaster::Success) 
     {
         result = OWWriteByte(0x69);
-        if (result == OneWireInterface::Success) 
+        if (result == OneWireMaster::Success) 
         {
             OWSpeed(SPEED_OVERDRIVE);
             // send ROM
@@ -287,12 +287,12 @@
     
 
 //*********************************************************************    
-OneWireInterface::CmdResult OneWireMaster::OWResume(void)
+OneWireMaster::CmdResult OneWireMaster::OWResume(void)
 {
-    OneWireInterface::CmdResult result;
+    OneWireMaster::CmdResult result;
     
     result = OWReset();
-    if (result == OneWireInterface::Success) 
+    if (result == OneWireMaster::Success) 
     {
         result = OWWriteByte(0xA5);
     }