modify the write function for temperature update If you use update temperature, you modify the repeat condition when write function use - read16() -> m_I2C.write(m_Addr, &reg, 1); //stop condition - read16() -> m_I2C.write(m_Addr, &reg, 1,1); //repeat condition

Fork of LM75B by Neil Thiessen

Files at this revision

API Documentation at this revision

Comitter:
eunkyoungkim
Date:
Mon Jul 20 09:36:26 2015 +0000
Parent:
12:fc27dc535ea9
Commit message:
modify the Source code(in LM75B.cpp); - in LM75B::read16(char reg); write function is modified from stop condition to repeated condition for temperture value update; m_I2C.write(m_Addr, &reg, 1) ->m_I2C.write(m_Addr, &reg,1,1);;

Changed in this revision

LM75B.cpp Show annotated file Show diff for this revision Revisions of this file
LM75B.h Show annotated file Show diff for this revision Revisions of this file
diff -r fc27dc535ea9 -r c62f1e2d721e LM75B.cpp
--- a/LM75B.cpp	Mon Sep 16 21:32:18 2013 +0000
+++ b/LM75B.cpp	Mon Jul 20 09:36:26 2015 +0000
@@ -16,12 +16,14 @@
 
 #include "LM75B.h"
 
-LM75B::LM75B(PinName sda, PinName scl, Address addr) : m_I2C(sda, scl)
+LM75B::LM75B(PinName sda, PinName scl, Address addr, int hz) : m_I2C(sda, scl)
 {
     //Set the internal device address
     m_Addr = (int)addr;
+    m_I2C.frequency(hz);
 }
 
+
 bool LM75B::open(void)
 {
     //Probe for the LM75B using a Zero Length Transfer
@@ -187,13 +189,12 @@
 
     //Read the 11-bit raw temperature value
     value = read16(REG_TEMP) >> 5;
-
     //Sign extend negative numbers
     if (value & (1 << 10))
         value |= 0xFC00;
 
     //Return the temperature in °C
-    return value * 0.125;
+    return value*0.125;
 }
 
 char LM75B::read8(char reg)
@@ -227,7 +228,7 @@
     char buff[2];
 
     //Select the register
-    m_I2C.write(m_Addr, &reg, 1);
+    m_I2C.write(m_Addr, &reg, 1,1);
 
     //Read the 16-bit register
     m_I2C.read(m_Addr, buff, 2);
diff -r fc27dc535ea9 -r c62f1e2d721e LM75B.h
--- a/LM75B.h	Mon Sep 16 21:32:18 2013 +0000
+++ b/LM75B.h	Mon Jul 20 09:36:26 2015 +0000
@@ -101,7 +101,8 @@
      * @param scl The I2C clock pin.
      * @param addr The I2C slave address (defaults to ADDRESS_0).
      */
-    LM75B(PinName sda, PinName scl, Address addr = ADDRESS_0);
+    //LM75B(PinName sda, PinName scl, Address addr = ADDRESS_0);
+    LM75B::LM75B(PinName sda, PinName scl, Address addr, int hz);
 
     /** Probe for the LM75B and reset it to default configuration if present
      *