summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-10-19 10:04:33 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-10-19 10:04:33 +0200
commit9eb1066824bd8141914334c9b13e2d4f876e9138 (patch)
tree6fc1f16b06051202abb6fbdd855b75dfe8dc2018
parent6192b8ceda6b34c90eea39f4d6c7bea709ad3611 (diff)
LM75: Add getOS, getHyst accessors
-rw-r--r--include/driver/lm75.h2
-rw-r--r--src/driver/lm75.cc18
2 files changed, 20 insertions, 0 deletions
diff --git a/include/driver/lm75.h b/include/driver/lm75.h
index e357574..5bb92fa 100644
--- a/include/driver/lm75.h
+++ b/include/driver/lm75.h
@@ -12,6 +12,8 @@ class LM75 {
LM75(unsigned char const addr) : address(addr) {}
float getTemp();
+ unsigned int getOS();
+ unsigned int getHyst();
void setOS(unsigned char os);
void setHyst(unsigned char hyst);
};
diff --git a/src/driver/lm75.cc b/src/driver/lm75.cc
index 9f20e9b..83b2dcf 100644
--- a/src/driver/lm75.cc
+++ b/src/driver/lm75.cc
@@ -15,6 +15,24 @@ float LM75::getTemp()
return rxbuf[0] + (rxbuf[1] / 256.0);
}
+unsigned int LM75::getOS()
+{
+ txbuf[0] = 0x03;
+ rxbuf[0] = 0;
+ rxbuf[1] = 0;
+ i2c.xmit(address, 1, txbuf, 2, rxbuf);
+ return rxbuf[0];
+}
+
+unsigned int LM75::getHyst()
+{
+ txbuf[0] = 0x02;
+ rxbuf[0] = 0;
+ rxbuf[1] = 0;
+ i2c.xmit(address, 1, txbuf, 2, rxbuf);
+ return rxbuf[0];
+}
+
void LM75::setOS(unsigned char os)
{
txbuf[0] = 0x03;