Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Revision:
36:0fb61acf7fae
Parent:
34:5618603e5fc3
Child:
37:31f8e9c5d075
--- a/xDotBridge/src/main.cpp	Tue Jan 24 22:47:55 2017 +0000
+++ b/xDotBridge/src/main.cpp	Wed Jan 25 11:03:53 2017 -0700
@@ -3,10 +3,7 @@
 #include "xdot_flash.h"
 #include "dot_util.h"
 #include "RadioEvent.h"
-#include <DS2408.h>
 #include <OneWire.h>
-#include "OwGpio.h"
-
 
 /////////////////////////////////////////////////////////////////////////////
 // -------------------- DOT LIBRARY REQUIRED ------------------------------//
@@ -299,7 +296,40 @@
         // OneWire Play //
         //////////////////
 
-        // TODO search bus
+        OneWire owMaster(I2C_SDA);
+        uint8_t addr[8];
+        uint8_t result;
+
+        // Search Bus
+        do {
+            result = owMaster.search(addr);
+            logInfo("ROM Addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x%02x\n",
+                    addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],addr[6],addr[7]);
+        } while (result == 1);
+
+        uint8_t pioStateAddr[] = {0x00, 0x88};
+        while (true) {
+            owMaster.reset();
+            owMaster.select(addr);
+            owMaster.write(0xF0); // Read Register Command
+            owMaster.write_bytes(pioStateAddr, 2); // Write 2 byte addr
+            result = owMaster.read();
+            logInfo("Reg Value: %02x\n", result);
+            // TODO try reading inverted 16-bit CRC
+
+//            // Try write
+//            owMaster.reset();
+//            owMaster.select(addr);
+//            owMaster.write(0x5A); // Channel Access Write Command
+//            uint8_t val = 0xAA;
+//            owMaster.write(val); // Pull-down all even bits
+//            result = owMaster.read();
+//            logInfo("Read after write value: %02x, expected %02x\n", result, val);
+
+            // Check if the read back is just a latch reg thing or a true logic state
+
+        }
+
 
 
     }