Implementation of 1-Wire with added Alarm Search Functionality

Dependents:   Max32630_One_Wire_Interface

Revision:
76:84e6c4994e29
Parent:
75:8b627804927c
Child:
77:529edb329ee0
diff -r 8b627804927c -r 84e6c4994e29 Bridge/DS28E17/DS28E17.cpp
--- a/Bridge/DS28E17/DS28E17.cpp	Fri May 13 14:52:50 2016 -0500
+++ b/Bridge/DS28E17/DS28E17.cpp	Sat May 14 14:27:56 2016 -0500
@@ -32,9 +32,11 @@
 
 #include "DS28E17.h"
 #include "Masters/OneWireMaster.h"
+#include "RomCommands.h"
 
-using OneWire::Bridge::DS28E17;
-using OneWire::Masters::OneWireMaster;
+using OneWire::DS28E17;
+using OneWire::OneWireMaster;
+using namespace OneWire::RomCommands;
 
 
 enum Command
@@ -57,7 +59,7 @@
 
 //*********************************************************************
 DS28E17::DS28E17(OneWireMaster &owm)
-    : _owm(owm)
+    : OneWireSlave(&owm)
 {
 
 }
@@ -73,7 +75,7 @@
     size_t send_cnt = 0;
     uint8_t send_block[0xff];
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -124,7 +126,7 @@
     size_t send_cnt = 0;
     uint8_t send_block[0xff];
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -172,7 +174,7 @@
     size_t send_cnt = 0;
     uint8_t send_block[0xff];
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -218,7 +220,7 @@
     size_t send_cnt = 0;
     uint8_t send_block[0xff];
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -267,7 +269,7 @@
     size_t idx = 0;
     uint8_t send_block[0xff];
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -308,7 +310,7 @@
         bridge_result = send_packet(send_block, send_cnt, status, wr_status);
         if (bridge_result == DS28E17::Success)
         {
-            ow_result = _owm.OWReadBlock(read_data, nu_bytes_read);
+            ow_result = p_owMaster->OWReadBlock(read_data, nu_bytes_read);
             if (ow_result == OneWireMaster::Success)
             {
                 bridge_result = DS28E17::Success;
@@ -333,7 +335,7 @@
     size_t send_cnt = 0;
     uint8_t send_block[0xff];
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -363,7 +365,7 @@
         bridge_result = send_packet(send_block, send_cnt, status);
         if (bridge_result == DS28E17::Success)
         {
-            ow_result = _owm.OWReadBlock(read_data, nu_bytes_read);
+            ow_result = p_owMaster->OWReadBlock(read_data, nu_bytes_read);
             if (ow_result == OneWireMaster::Success)
             {
                 bridge_result = DS28E17::Success;
@@ -384,14 +386,14 @@
 {
     DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
         // Send CMD and Data
         uint8_t send_block[] = { WriteConfigurationCmd, data };
 
-        ow_result = _owm.OWWriteBlock(send_block, 2);
+        ow_result = p_owMaster->OWWriteBlock(send_block, 2);
         if (ow_result == OneWireMaster::Success)
         {
             _i2c_speed = data & 0x03; // Save off _i2c_speed setting to be used by other functions
@@ -412,15 +414,15 @@
 {
     DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
         // Send CMD and receive Data
-        ow_result = _owm.OWWriteByte(ReadConfigurationCmd);
+        ow_result = p_owMaster->OWWriteByte(ReadConfigurationCmd);
         if (ow_result == OneWireMaster::Success)
         {
-            ow_result = _owm.OWReadByte(config);
+            ow_result = p_owMaster->OWReadByte(config);
             if (ow_result == OneWireMaster::Success)
             {
                 bridge_result = DS28E17::Success;
@@ -445,12 +447,12 @@
 {
     DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
         // Send CMD
-        ow_result = _owm.OWWriteByte(EnableSleepModeCmd);
+        ow_result = p_owMaster->OWWriteByte(EnableSleepModeCmd);
         if (ow_result == OneWireMaster::Success)
         {
             bridge_result = DS28E17::Success;
@@ -470,15 +472,15 @@
 {
     DS28E17::CmdResult bridge_result = DS28E17::OperationFailure;
 
-    OneWireMaster::CmdResult ow_result = _owm.OWMatchRom(romId);
+    OneWireMaster::CmdResult ow_result = OWMatchRom(*p_owMaster, romId);
 
     if (ow_result == OneWireMaster::Success)
     {
         // Send CMD and receive Data
-        ow_result = _owm.OWWriteByte(ReadDeviceRevisionCmd);
+        ow_result = p_owMaster->OWWriteByte(ReadDeviceRevisionCmd);
         if (ow_result == OneWireMaster::Success)
         {
-            ow_result = _owm.OWReadByte(rev);
+            ow_result = p_owMaster->OWReadByte(rev);
             if (ow_result == OneWireMaster::Success)
             {
                 bridge_result = DS28E17::Success;
@@ -525,7 +527,7 @@
     DS28E17::CmdResult bridge_result = DS28E17::CommsWriteBlockError;
     uint32_t poll_count = 0;
 
-    OneWireMaster::CmdResult ow_result = _owm.OWWriteBlock(data, data_length);
+    OneWireMaster::CmdResult ow_result = p_owMaster->OWWriteBlock(data, data_length);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -533,7 +535,7 @@
         uint8_t recvbit = 0x01;
         do
         {
-            ow_result = _owm.OWReadBit(recvbit);
+            ow_result = p_owMaster->OWReadBit(recvbit);
         } while (recvbit && (poll_count++ < pollLimit) && (ow_result == OneWireMaster::Success));
 
         if (ow_result == OneWireMaster::Success)
@@ -543,7 +545,7 @@
                 //Read Status and write status
                 uint8_t read_block[2];
 
-                ow_result = _owm.OWReadBlock(read_block, 2);
+                ow_result = p_owMaster->OWReadBlock(read_block, 2);
 
                 if (ow_result == OneWireMaster::Success)
                 {
@@ -578,7 +580,7 @@
     DS28E17::CmdResult bridge_result = DS28E17::CommsWriteBlockError;
     uint32_t poll_count = 0;
 
-    OneWireMaster::CmdResult ow_result = _owm.OWWriteBlock(data, data_length);
+    OneWireMaster::CmdResult ow_result = p_owMaster->OWWriteBlock(data, data_length);
 
     if (ow_result == OneWireMaster::Success)
     {
@@ -586,7 +588,7 @@
         uint8_t recvbit = 0x01;
         do
         {
-            ow_result = _owm.OWReadBit(recvbit);
+            ow_result = p_owMaster->OWReadBit(recvbit);
         } while (recvbit && (poll_count++ < pollLimit) && (ow_result == OneWireMaster::Success));
 
         if (ow_result == OneWireMaster::Success)
@@ -594,7 +596,7 @@
             if (poll_count < pollLimit)
             {
                 //Read Status 
-                ow_result = _owm.OWReadByte(status);
+                ow_result = p_owMaster->OWReadByte(status);
                 if (ow_result == OneWireMaster::Success)
                 {
                     bridge_result = DS28E17::Success;