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:
54:08985bf69691
Parent:
23:e8e403d61359
Child:
56:be69bd88a3e3
--- a/OneWire_Switches/DS2413/ds2413.cpp	Thu Apr 07 11:26:20 2016 -0500
+++ b/OneWire_Switches/DS2413/ds2413.cpp	Wed Apr 13 20:31:41 2016 +0000
@@ -82,7 +82,7 @@
     //current state of pioB OR
     //desired state of pioA OR
     //bits[7:2] should all be 1, per datasheet
-    val = (0xFC | ((local_val & 0x02) | (0x01 & val)));
+    val = (0xFC | (((local_val >> 1) & 0x02) | (0x01 & val)));
     
     //write, bit[1:0] new state of pio
     result = pio_access_write(romId, val);
@@ -119,6 +119,13 @@
 
 
 //*********************************************************************
+Ds2413::CmdResult Ds2413::pio_access_write_chAB(RomId &romId, uint8_t val)
+{
+    return pio_access_write(romId, ((0x03 & val) | 0xFC));
+}
+
+
+//*********************************************************************
 Ds2413::CmdResult Ds2413::pio_access_read(RomId &romId, uint8_t & val)
 {
   Ds2413::CmdResult result = Ds2413::OpFailure;
@@ -153,8 +160,9 @@
 
 
 //*********************************************************************
-Ds2413::CmdResult Ds2413::pio_access_write(RomId &romId, uint8_t val)
+Ds2413::CmdResult Ds2413::pio_access_write(RomId & romId, uint8_t val)
 {
+  static uint32_t cnt = 0;
   Ds2413::CmdResult result = Ds2413::OpFailure;
   
   OneWireMaster::CmdResult ow_result = _owm.OWMatchROM(romId);
@@ -168,15 +176,21 @@
     {
       uint8_t expected_status = ((0x01 & val) | ((0x01 & val) << 1) | 
                                 ((0x02 & val) << 1) | ((0x02 & val) << 2));
-      expected_status |= (~expected_status << 4);
+      //expected_status |= (~expected_status << 4);
       
       uint8_t rcv_block[2];
       ow_result = _owm.OWReadBlock(rcv_block, 2);
       
       if(ow_result == OneWireMaster::Success)
       {
-        if((rcv_block[0] == 0xAA) && (rcv_block[1] == expected_status))
+        printf("\nEntry %d", ++cnt);
+        printf("\nval = 0x%2x", val);
+        printf("\nexpected status = 0x%2x", expected_status);
+        printf("\nrecv_block 0 = 0x%2x", rcv_block[0]);
+        printf("\nrecv_block 1 = 0x%2x\n", rcv_block[1]);
+        if((rcv_block[0] == 0xAA) && ((rcv_block[1] & 0x0F) == expected_status))
         {
+          printf("\nExit %d\n", cnt);
           result = Ds2413::Success;
         }
       }