Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
75:8b627804927c
Parent:
74:23be10c32fa3
Child:
76:84e6c4994e29
diff -r 23be10c32fa3 -r 8b627804927c Authenticators/DS28E15_22_25/DS28E15_22_25.cpp
--- a/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp	Fri May 13 07:48:35 2016 -0500
+++ b/Authenticators/DS28E15_22_25/DS28E15_22_25.cpp	Fri May 13 14:52:50 2016 -0500
@@ -1,27 +1,34 @@
-//------------Copyright (C) 2013 Maxim Integrated Products --------------
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-// IN NO EVENT SHALL MAXIM INTEGRATED PRODCUTS BE LIABLE FOR ANY CLAIM, DAMAGES
-// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-// Except as contained in this notice, the name of Maxim Integrated Products
-// shall not be used except as stated in the Maxim Integrated Products
-// Branding Policy.
-// ---------------------------------------------------------------------------
+/******************************************************************//**
+* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+**********************************************************************/
 
 #include "DS28E15_22_25.h"
 #include "Masters/OneWireMaster.h"
@@ -35,16 +42,16 @@
 /// 1-Wire device commands.
 enum Command
 {
-    CMD_WRITE_MEMORY = 0x55,
-    CMD_READ_MEMORY = 0xF0,
-    CMD_LOAD_LOCK_SECRET = 0x33,
-    CMD_COMPUTE_LOCK_SECRET = 0x3C,
-    CMD_READ_WRITE_SCRATCHPAD = 0x0F,
-    CMD_COMPUTE_PAGEMAC = 0xA5,
-    CMD_READ_STATUS = 0xAA,
-    CMD_WRITE_BLOCK_PROTECT = 0xC3,
-    CMD_WRITE_AUTH_MEMORY = 0x5A,
-    CMD_WRITE_AUTH_PROTECT = 0xCC,
+    WriteMemory = 0x55,
+    ReadMemory = 0xF0,
+    LoadAndLockSecret = 0x33,
+    ComputeAndLockSecret = 0x3C,
+    ReadWriteScratchpad = 0x0F,
+    ComputePageMac = 0xA5,
+    ReadStatus = 0xAA,
+    WriteBlockProtection = 0xC3,
+    AuthWriteMemory = 0x5A,
+    AuthWriteBlockProtection = 0xCC,
 };
 
 DS28E15_22_25::Segment DS28E15_22_25::Page::toSegment(unsigned int segmentNum) const
@@ -145,20 +152,20 @@
 
     switch (romId.familyCode())
     {
-    case DS28E25_FAMILY:
-        pages = DS28E25_PAGES;
+    case DS28E25_Family:
+        pages = DS28E25_Pages;
         break;
 
-    case DS28E22_FAMILY:
-        pages = DS28E22_PAGES;
+    case DS28E22_Family:
+        pages = DS28E22_Pages;
         break;
 
-    case DS28E15_FAMILY:
-        pages = DS28E15_PAGES;
+    case DS28E15_Family:
+        pages = DS28E15_Pages;
         break;
 
     default:
-        pages = UNKNOWN_PAGES;
+        pages = Unknown_Pages;
         break;
     }
 
@@ -171,20 +178,20 @@
 
     switch (romId.familyCode())
     {
-    case DS28E25_FAMILY:
-        blocks = DS28E25_BLOCKS;
+    case DS28E25_Family:
+        blocks = DS28E25_Blocks;
         break;
 
-    case DS28E22_FAMILY:
-        blocks = DS28E22_BLOCKS;
+    case DS28E22_Family:
+        blocks = DS28E22_Blocks;
         break;
 
-    case DS28E15_FAMILY:
-        blocks = DS28E15_BLOCKS;
+    case DS28E15_Family:
+        blocks = DS28E15_Blocks;
         break;
 
     default:
-        blocks = UNKNOWN_BLOCKS;
+        blocks = Unknown_Blocks;
         break;
     }
 
@@ -197,7 +204,7 @@
     int cnt = 0;
     Mac mac;
 
-    buf[cnt++] = CMD_WRITE_AUTH_PROTECT;
+    buf[cnt++] = AuthWriteBlockProtection;
     buf[cnt++] = newProtection.statusByte();
 
     // Send command
@@ -213,10 +220,10 @@
     wait_ms(shaComputationDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, cnt) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CommunicationError;
     }
@@ -237,7 +244,7 @@
     cnt += 3;
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, (cnt - 1), OneWireMaster::calculateCRC16(mac, 0, mac.length)) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, (cnt - 1), OneWireMaster::calculateCrc16(mac, 0, mac.length)) != 0xB001)
     {
         return CommunicationError;
     }
@@ -256,7 +263,7 @@
     wait_ms(eepromWriteDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);
@@ -274,7 +281,7 @@
     uint8_t buf[256], cs;
     int cnt = 0;
 
-    buf[cnt++] = CMD_WRITE_BLOCK_PROTECT;
+    buf[cnt++] = WriteBlockProtection;
 
     // compute parameter byte 
     buf[cnt++] = protection.statusByte();
@@ -286,7 +293,7 @@
     cnt += 2;
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, cnt) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CommunicationError;
     }
@@ -298,7 +305,7 @@
     wait_ms(eepromWriteDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);
@@ -336,14 +343,14 @@
     return result;
 }
 
-OneWireSlave::CmdResult DS28E15_22_25::readAllBlockProtection(BlockProtection(&protection)[DS28E15_BLOCKS]) const
+OneWireSlave::CmdResult DS28E15_22_25::readAllBlockProtection(BlockProtection(&protection)[DS28E15_Blocks]) const
 {
-    return readAllBlockProtection<DS28E15_BLOCKS>(protection);
+    return readAllBlockProtection<DS28E15_Blocks>(protection);
 }
 
-OneWireSlave::CmdResult DS28E15_22_25::readAllBlockProtection(BlockProtection(&protection)[DS28E25_BLOCKS]) const
+OneWireSlave::CmdResult DS28E15_22_25::readAllBlockProtection(BlockProtection(&protection)[DS28E25_Blocks]) const
 {
-    return readAllBlockProtection<DS28E25_BLOCKS>(protection);
+    return readAllBlockProtection<DS28E25_Blocks>(protection);
 }
 
 OneWireSlave::CmdResult DS28E15_22_25::readPersonality(Personality & personality) const
@@ -358,7 +365,7 @@
     uint8_t buf[256];
     size_t cnt = 0, offset = 0;
 
-    buf[cnt++] = CMD_READ_STATUS;
+    buf[cnt++] = ReadStatus;
     if (personality)
     {
         buf[cnt++] = 0xE0;
@@ -371,7 +378,7 @@
     {
         // Convert to page number for DS28E22 and DS28E25
         buf[cnt] = blockNum;
-        if ((romId.familyCode() == DS28E25_FAMILY) || (romId.familyCode() == DS28E22_FAMILY))
+        if ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family))
         {
             buf[cnt] *= ds28e22_25_pagesPerBlock;
         }
@@ -393,13 +400,13 @@
     {
         rdnum = 1;
     }
-    else if ((romId.familyCode() == DS28E22_FAMILY) || (romId.familyCode() == DS28E25_FAMILY))
+    else if ((romId.familyCode() == DS28E22_Family) || (romId.familyCode() == DS28E25_Family))
     {
-        rdnum = DS28E25_PAGES; // Need to read extra data on DS28E22 to get CRC16.
+        rdnum = DS28E25_Pages; // Need to read extra data on DS28E22 to get CRC16.
     }
     else // DS28E15
     {
-        rdnum = DS28E15_BLOCKS;
+        rdnum = DS28E15_Blocks;
     }
     rdnum += crcLen; // Add in CRC length
 
@@ -408,7 +415,7 @@
     cnt += rdnum;
 
     // check the first CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
     {
         return CommunicationError;
     }
@@ -416,7 +423,7 @@
     if (personality || allpages)
     {
         // check the second CRC16
-        if (OneWireMaster::calculateCRC16(buf, offset, (cnt - offset)) != 0xB001)
+        if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
         {
             return CommunicationError;
         }
@@ -424,11 +431,11 @@
 
     // copy the data to the read buffer
     rdnum -= crcLen;
-    if (allpages && ((romId.familyCode() == DS28E25_FAMILY) || (romId.familyCode() == DS28E22_FAMILY)))
+    if (allpages && ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family)))
     {
-        if (romId.familyCode() == DS28E22_FAMILY)
+        if (romId.familyCode() == DS28E22_Family)
         {
-            rdnum -= (DS28E25_PAGES - DS28E22_PAGES);
+            rdnum -= (DS28E25_Pages - DS28E22_Pages);
         }
 
         for (size_t i = 0; i < (rdnum / ds28e22_25_pagesPerBlock); i++)
@@ -474,7 +481,7 @@
     uint8_t buf[256], cs;
     int cnt = 0;
 
-    buf[cnt++] = CMD_COMPUTE_PAGEMAC;
+    buf[cnt++] = ComputePageMac;
     buf[cnt++] = ((anon) ? 0xE0 : 0x00) | page_num;
 
     // Send command
@@ -490,10 +497,10 @@
     wait_ms(shaComputationDelayMs * 2);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, cnt) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CommunicationError;
     }
@@ -509,7 +516,7 @@
     m_OW_master.OWReadBlock(&buf[0], (Mac::length + 2));
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, (Mac::length + 2)) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, (Mac::length + 2)) != 0xB001)
     {
         return CommunicationError;
     }
@@ -525,7 +532,7 @@
     uint8_t buf[256], cs;
     int cnt = 0;
 
-    buf[cnt++] = CMD_COMPUTE_LOCK_SECRET;
+    buf[cnt++] = ComputeAndLockSecret;
     buf[cnt++] = (lock) ? (0xE0 | page_num) : page_num;  // lock flag 
 
     // Send command
@@ -536,7 +543,7 @@
     cnt += 2;
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, cnt) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CommunicationError;
     }
@@ -548,7 +555,7 @@
     wait_ms(shaComputationDelayMs * 2 + secretEepromWriteDelayMs());
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);
@@ -566,8 +573,8 @@
     uint8_t buf[256];
     int cnt = 0, offset;
 
-    buf[cnt++] = CMD_READ_WRITE_SCRATCHPAD;
-    if ((romId.familyCode() == DS28E25_FAMILY) || (romId.familyCode() == DS28E22_FAMILY))
+    buf[cnt++] = ReadWriteScratchpad;
+    if ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family))
     {
         buf[cnt++] = 0x20;
     }
@@ -597,13 +604,13 @@
     cnt += 2;
 
     // check first CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
     {
         return CommunicationError;
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCRC16(buf, offset, (cnt - offset)) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CommunicationError;
     }
@@ -616,8 +623,8 @@
     uint8_t buf[256];
     int cnt = 0, offset;
 
-    buf[cnt++] = CMD_READ_WRITE_SCRATCHPAD;
-    if ((romId.familyCode() == DS28E25_FAMILY) || (romId.familyCode() == DS28E22_FAMILY))
+    buf[cnt++] = ReadWriteScratchpad;
+    if ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family))
     {
         buf[cnt++] = 0x2F;
     }
@@ -644,13 +651,13 @@
     cnt += 2;
 
     // check first CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
     {
         return CommunicationError;
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCRC16(buf, offset, (cnt - offset)) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CommunicationError;
     }
@@ -666,7 +673,7 @@
     uint8_t buf[256], cs;
     int cnt = 0;
 
-    buf[cnt++] = CMD_LOAD_LOCK_SECRET;
+    buf[cnt++] = LoadAndLockSecret;
     buf[cnt++] = (lock) ? 0xE0 : 0x00;  // lock flag 
 
     // Send command
@@ -677,7 +684,7 @@
     cnt += 2;
 
     // check CRC16
-    if (OneWireMaster::calculateCRC16(buf, 0, cnt) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, 0, cnt) != 0xB001)
     {
         return CommunicationError;
     }
@@ -689,7 +696,7 @@
     wait_ms(secretEepromWriteDelayMs());
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);
@@ -713,7 +720,7 @@
     // check if not continuing a previous block write
     if (!continuing)
     {
-        buf[cnt++] = CMD_READ_MEMORY;
+        buf[cnt++] = ReadMemory;
         buf[cnt++] = page;   // address 
 
         // Send command
@@ -733,14 +740,14 @@
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CommunicationError;
         }
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCRC16(buf, offset, (cnt - offset)) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CommunicationError;
     }
@@ -762,7 +769,7 @@
     // check if not continuing a previous block write
     if (!continuing)
     {
-        buf[cnt++] = CMD_WRITE_AUTH_MEMORY;
+        buf[cnt++] = AuthWriteMemory;
         buf[cnt++] = (segmentNum << 5) | pageNum;   // address 
 
         // Send command
@@ -794,12 +801,12 @@
     wait_ms(shaComputationDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CommunicationError;
         }
@@ -809,15 +816,15 @@
     unsigned short CRC16 = 0;
 
     // DS28E25/DS28E22, crc gets calculagted with CS byte 
-    if ((romId.familyCode() == DS28E25_FAMILY) || (romId.familyCode() == DS28E22_FAMILY))
+    if ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family))
     {
         if (continuing)
         {
-            CRC16 = OneWireMaster::calculateCRC16(CRC16, 0xAA);
+            CRC16 = OneWireMaster::calculateCrc16(CRC16, 0xAA);
         }
     }
 
-    CRC16 = OneWireMaster::calculateCRC16(buf, offset, (cnt - offset), CRC16);
+    CRC16 = OneWireMaster::calculateCrc16(buf, offset, (cnt - offset), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -828,14 +835,14 @@
     m_OW_master.OWWriteBlock(mac, mac.length);
 
     // calculate CRC on MAC
-    CRC16 = OneWireMaster::calculateCRC16(mac, 0, mac.length);
+    CRC16 = OneWireMaster::calculateCrc16(mac, 0, mac.length);
 
     // append read of CRC16 and CS byte
     m_OW_master.OWReadBlock(&buf[0], 3);
     cnt = 3;
 
     // ckeck CRC16
-    CRC16 = OneWireMaster::calculateCRC16(buf, 0, (cnt - 1), CRC16);
+    CRC16 = OneWireMaster::calculateCrc16(buf, 0, (cnt - 1), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -855,7 +862,7 @@
     wait_ms(eepromWriteDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);
@@ -929,7 +936,7 @@
     // check if not continuing a previous block write
     if (!continuing)
     {
-        buf[cnt++] = CMD_WRITE_AUTH_MEMORY;
+        buf[cnt++] = AuthWriteMemory;
         buf[cnt++] = (segmentNum << 5) | pageNum;   // address 
 
         // Send command
@@ -961,12 +968,12 @@
     wait_ms(shaComputationDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CommunicationError;
         }
@@ -976,13 +983,13 @@
     unsigned short CRC16 = 0;
 
     // DS28E25/DS28E22, crc gets calculagted with CS byte
-    if ((romId.familyCode() == DS28E25_FAMILY) || (romId.familyCode() == DS28E22_FAMILY))
+    if ((romId.familyCode() == DS28E25_Family) || (romId.familyCode() == DS28E22_Family))
     {
         if (continuing)
-            CRC16 = OneWireMaster::calculateCRC16(CRC16, 0xAA);
+            CRC16 = OneWireMaster::calculateCrc16(CRC16, 0xAA);
     }
 
-    CRC16 = OneWireMaster::calculateCRC16(buf, offset, (cnt - offset), CRC16);
+    CRC16 = OneWireMaster::calculateCrc16(buf, offset, (cnt - offset), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -1002,14 +1009,14 @@
     m_OW_master.OWWriteBlock(mac, mac.length);
 
     // calculate CRC on MAC
-    CRC16 = OneWireMaster::calculateCRC16(mac, 0, mac.length);
+    CRC16 = OneWireMaster::calculateCrc16(mac, 0, mac.length);
 
     // append read of CRC16 and CS byte
     m_OW_master.OWReadBlock(&buf[0], 3);
     cnt = 3;
 
     // ckeck CRC16
-    CRC16 = OneWireMaster::calculateCRC16(buf, 0, (cnt - 1), CRC16);
+    CRC16 = OneWireMaster::calculateCrc16(buf, 0, (cnt - 1), CRC16);
 
     if (CRC16 != 0xB001)
     {
@@ -1029,7 +1036,7 @@
     wait_ms(eepromWriteDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);
@@ -1049,7 +1056,7 @@
 
     if (!continuing)
     {
-        buf[0] = CMD_READ_MEMORY;
+        buf[0] = ReadMemory;
         buf[1] = (segment << 5) | page;
 
         // Transmit command
@@ -1084,7 +1091,7 @@
     // check if not continuing a previous block write
     if (!continuing)
     {
-        buf[cnt++] = CMD_WRITE_MEMORY;
+        buf[cnt++] = WriteMemory;
         buf[cnt++] = (block << 5) | page;   // address 
 
         // Send command 
@@ -1113,14 +1120,14 @@
     // check the first CRC16
     if (!continuing)
     {
-        if (OneWireMaster::calculateCRC16(buf, 0, offset) != 0xB001)
+        if (OneWireMaster::calculateCrc16(buf, 0, offset) != 0xB001)
         {
             return CommunicationError;
         }
     }
 
     // check the second CRC16
-    if (OneWireMaster::calculateCRC16(buf, offset, (cnt - offset)) != 0xB001)
+    if (OneWireMaster::calculateCrc16(buf, offset, (cnt - offset)) != 0xB001)
     {
         return CommunicationError;
     }
@@ -1132,7 +1139,7 @@
     wait_ms(eepromWriteDelayMs);
 
     // disable strong pullup
-    m_OW_master.OWSetLevel(OneWireMaster::LEVEL_NORMAL);
+    m_OW_master.OWSetLevel(OneWireMaster::NormalLevel);
 
     // read the CS byte
     m_OW_master.OWReadByte(cs);