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:
81:e2a3ad98874e
Parent:
80:83b0d879cc32
--- a/Temperature/DS1920/DS1920.cpp	Thu Jun 02 21:56:16 2016 +0000
+++ b/Temperature/DS1920/DS1920.cpp	Fri Jun 03 22:15:59 2016 +0000
@@ -49,7 +49,7 @@
 
 
 /**********************************************************************/
-DS1920::DS1920(RandomAccessRomIterator &selector) : OneWireSlave(selector)
+DS1920::DS1920(RandomAccessRomIterator &selector):OneWireSlave(selector)
 {
 }
 
@@ -147,7 +147,7 @@
 }
 
 /**********************************************************************/
-DS1920::CmdResult DS1920::convertTemperature(uint16_t temp)
+DS1920::CmdResult DS1920::convertTemperature(float & temp)
 {
     DS1920::CmdResult deviceResult = DS1920::OpFailure;
     
@@ -163,7 +163,24 @@
             owmResult = master().OWSetLevel(OneWireMaster::NormalLevel);  
             if (owmResult == OneWireMaster::Success)
             {
-                deviceResult = DS1920::Success;
+                uint8_t scratchPadBuff[8];
+                deviceResult = this->readScratchPad(scratchPadBuff);
+                if(deviceResult == DS1920::Success)
+                {
+                    if(scratchPadBuff[0] & 1)
+                    {
+                        temp = (((float) (scratchPadBuff[0] >> 1)) + 0.5F);
+                    }
+                    else
+                    {
+                        temp = ((float) (scratchPadBuff[0] >> 1));
+                    }
+                    
+                    if(scratchPadBuff[1])
+                    {
+                        temp = (temp * -1.0F);
+                    }
+                }
             }
         }
         else