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:
78:0cbbac7f2016
Parent:
77:529edb329ee0
Child:
79:7f22823a5a2d
--- a/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp	Mon May 16 10:36:30 2016 -0500
+++ b/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp	Mon May 16 15:18:09 2016 -0500
@@ -32,9 +32,11 @@
 
 #include "DS28E15_22_25.h"
 #include "Masters/OneWireMaster.h"
+#include "crc.h"
 #include "wait_api.h"
 
 using namespace OneWire;
+using namespace OneWire::crc;
 
 /// 1-Wire device commands.
 enum Command
@@ -225,7 +227,7 @@
     master().OWSetLevel(OneWireMaster::NormalLevel);
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
+    if (calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CrcError;
     }
@@ -246,7 +248,7 @@
     cnt += 3;
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, (cnt - 1), OneWireMaster::calculateCrc16(mac, 0, mac.length)) != 0xB001)
+    if (calculateCrc16(buf, 0, (cnt - 1), calculateCrc16(mac, 0, mac.length)) != 0xB001)
     {
         return CrcError;
     }
@@ -300,7 +302,7 @@
     cnt += 2;
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
+    if (calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CrcError;
     }
@@ -429,7 +431,7 @@
     cnt += rdnum;
 
     // check the first CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+    if (calculateCrc16(buf, 0, offset) != 0xB001)
     {
         return CrcError;
     }
@@ -437,7 +439,7 @@
     if (personality || allpages)
     {
         // check the second CRC16
-        if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
+        if (calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
         {
             return CrcError;
         }
@@ -519,7 +521,7 @@
     master().OWSetLevel(OneWireMaster::NormalLevel);
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
+    if (calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CrcError;
     }
@@ -535,7 +537,7 @@
     master().OWReadBlock(&buf[0], (Mac::length + 2));
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, (Mac::length + 2)) != 0xB001)
+    if (calculateCrc16(buf, 0, (Mac::length + 2)) != 0xB001)
     {
         return CrcError;
     }
@@ -567,7 +569,7 @@
     cnt += 2;
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
+    if (calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CrcError;
     }
@@ -633,13 +635,13 @@
     cnt += 2;
 
     // check first CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+    if (calculateCrc16(buf, 0, offset) != 0xB001)
     {
         return CrcError;
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
+    if (calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CrcError;
     }
@@ -685,13 +687,13 @@
     cnt += 2;
 
     // check first CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+    if (calculateCrc16(buf, 0, offset) != 0xB001)
     {
         return CrcError;
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
+    if (calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CrcError;
     }
@@ -723,7 +725,7 @@
     cnt += 2;
 
     // check CRC16
-    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
+    if (calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CrcError;
     }
@@ -784,14 +786,14 @@
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+        if (calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CrcError;
         }
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
+    if (calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CrcError;
     }
@@ -855,7 +857,7 @@
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+        if (calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CrcError;
         }
@@ -869,11 +871,11 @@
     {
         if (continuing)
         {
-            CRC16 = OneWireMaster::calculateCrc16(CRC16, 0xAA);
+            CRC16 = calculateCrc16(CRC16, 0xAA);
         }
     }
 
-    CRC16 = OneWireMaster::calculateCrc16(buf, offset, (cnt - offset), CRC16);
+    CRC16 = calculateCrc16(buf, offset, (cnt - offset), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -884,14 +886,14 @@
     master().OWWriteBlock(mac, mac.length);
 
     // calculate CRC on MAC
-    CRC16 = OneWireMaster::calculateCrc16(mac, 0, mac.length);
+    CRC16 = calculateCrc16(mac, 0, mac.length);
 
     // append read of CRC16 and CS byte
     master().OWReadBlock(&buf[0], 3);
     cnt = 3;
 
     // ckeck CRC16
-    CRC16 = OneWireMaster::calculateCrc16(buf, 0, (cnt - 1), CRC16);
+    CRC16 = calculateCrc16(buf, 0, (cnt - 1), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -1027,7 +1029,7 @@
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+        if (calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CrcError;
         }
@@ -1040,10 +1042,10 @@
     if ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family))
     {
         if (continuing)
-            CRC16 = OneWireMaster::calculateCrc16(CRC16, 0xAA);
+            CRC16 = calculateCrc16(CRC16, 0xAA);
     }
 
-    CRC16 = OneWireMaster::calculateCrc16(buf, offset, (cnt - offset), CRC16);
+    CRC16 = calculateCrc16(buf, offset, (cnt - offset), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -1063,14 +1065,14 @@
     master().OWWriteBlock(mac, mac.length);
 
     // calculate CRC on MAC
-    CRC16 = OneWireMaster::calculateCrc16(mac, 0, mac.length);
+    CRC16 = calculateCrc16(mac, 0, mac.length);
 
     // append read of CRC16 and CS byte
     master().OWReadBlock(&buf[0], 3);
     cnt = 3;
 
     // ckeck CRC16
-    CRC16 = OneWireMaster::calculateCrc16(buf, 0, (cnt - 1), CRC16);
+    CRC16 = calculateCrc16(buf, 0, (cnt - 1), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -1184,14 +1186,14 @@
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
+        if (calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CrcError;
         }
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
+    if (calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CrcError;
     }