summaryrefslogtreecommitdiff
path: root/src/driver/max44006.cc
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-05-24 09:10:38 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-05-24 09:10:38 +0200
commitc1a41b3ce91f2b839faf8559822c1478c12d69d8 (patch)
tree6edb355ceb8baacc36e9fd1fa91b3929e9dac275 /src/driver/max44006.cc
parent942d0d174f8b109bd1e7c1597820dd8228dbcec2 (diff)
add ccs811, max44006, max44009 drivers. Not all are working.
Diffstat (limited to 'src/driver/max44006.cc')
-rw-r--r--src/driver/max44006.cc71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/driver/max44006.cc b/src/driver/max44006.cc
new file mode 100644
index 0000000..a61e7df
--- /dev/null
+++ b/src/driver/max44006.cc
@@ -0,0 +1,71 @@
+#include "driver/max44006.h"
+#include "arch.h"
+#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
+#include "driver/i2c.h"
+#else
+#include "driver/soft_i2c.h"
+#endif
+
+signed char MAX44006::setup()
+{
+ txbuf[0] = 0;
+ txbuf[1] = 0;
+ i2c.xmit(2, txbuf, 0, rxbuf);
+
+ arch.delay_us(10);
+
+ txbuf[0] = 0x01;
+ txbuf[1] = 0x20;
+ i2c.xmit(2, txbuf, 0, rxbuf);
+
+ arch.delay_us(10);
+
+ txbuf[0] = 0x02;
+ txbuf[1] = 0x02;
+ i2c.xmit(2, txbuf, 0, rxbuf);
+
+ return 0;
+}
+
+void MAX44006::wakeup()
+{
+ txbuf[0] = 0;
+ txbuf[1] = 0;
+ i2c.xmit(2, txbuf, 0, rxbuf);
+}
+
+void MAX44006::sleep()
+{
+ txbuf[0] = 0x00;
+ txbuf[1] = 0x08;
+
+ i2c.xmit(2, txbuf, 0, rxbuf);
+}
+
+float LM75::getTemp()
+{
+ txbuf[0] = 0;
+ rxbuf[0] = 0;
+ rxbuf[1] = 0;
+ i2c.xmit(address, 1, txbuf, 2, rxbuf);
+
+ return rxbuf[0] + (rxbuf[1] / 256.0);
+}
+
+void LM75::setOS(unsigned char os)
+{
+ txbuf[0] = 0x03;
+ txbuf[1] = os;
+ txbuf[2] = 0;
+ i2c.xmit(address, 3, txbuf, 0, rxbuf);
+}
+
+void LM75::setHyst(unsigned char hyst)
+{
+ txbuf[0] = 0x02;
+ txbuf[1] = hyst;
+ txbuf[2] = 0;
+ i2c.xmit(address, 3, txbuf, 0, rxbuf);
+}
+
+MAX44006 max44006(0x45);