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:
96:9b7b63c0105e
Parent:
84:708b7be59fb2
Child:
104:3f48daed532b
diff -r 5ebdf5d955f4 -r 9b7b63c0105e Masters/DS2480B/DS2480B.cpp
--- a/Masters/DS2480B/DS2480B.cpp	Fri Jun 24 21:24:02 2016 +0000
+++ b/Masters/DS2480B/DS2480B.cpp	Wed Jun 29 16:13:33 2016 +0000
@@ -488,9 +488,55 @@
 //*********************************************************************
 OneWireMaster::CmdResult DS2480B::OWSetSpeed(OWSpeed newSpeed)
 {
-    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure;
+    OneWireMaster::CmdResult result = OneWireMaster::OperationFailure; //uchar rt = FALSE;
+
+    uint8_t sendpacket[5];
+    uint8_t sendlen = 0;
 
-    //TODO
+    // check if change from current mode
+    if (((newSpeed == OneWireMaster::OverdriveSpeed) && (_USpeed != OneWireMaster::OverdriveSpeed)) || 
+        ((newSpeed == OneWireMaster::StandardSpeed) && (_USpeed != OneWireMaster::StandardSpeed))) 
+    {
+        if (newSpeed == OneWireMaster::OverdriveSpeed) 
+        {
+            result = DS2480B_ChangeBaud(Bps115200);
+            if (result == OneWireMaster::Success) 
+            {
+                _USpeed = SPEEDSEL_OD;
+            }
+        } 
+        else if (newSpeed == OneWireMaster::StandardSpeed) 
+        {
+            result = DS2480B_ChangeBaud(Bps9600);
+            if (result == OneWireMaster::Success) 
+            {
+                _USpeed = SPEEDSEL_STD;
+            }
+        }
+
+        // if baud rate is set correctly then change DS2480 speed
+        if (result == OneWireMaster::Success) 
+        {
+            // check if correct mode
+            if (_UMode != MODSEL_COMMAND) 
+            {
+                _UMode = MODSEL_COMMAND;
+                sendpacket[sendlen++] = MODE_COMMAND;
+            }
+
+            // proceed to set the DS2480 communication speed
+            sendpacket[sendlen++] = CMD_COMM | FUNCTSEL_SEARCHOFF | _USpeed;
+
+            // send the packet
+            result = WriteCOM(sendlen,sendpacket);
+            if (result != OneWireMaster::Success) 
+            {
+                // lost communication with DS2480 then reset
+                DS2480B_Detect();
+            }
+        }
+    }
+
 
     return result;
 }