From c1a41b3ce91f2b839faf8559822c1478c12d69d8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 24 May 2019 09:10:38 +0200 Subject: add ccs811, max44006, max44009 drivers. Not all are working. --- src/driver/ccs811.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/driver/ccs811.cc (limited to 'src/driver/ccs811.cc') diff --git a/src/driver/ccs811.cc b/src/driver/ccs811.cc new file mode 100644 index 0000000..a2b3940 --- /dev/null +++ b/src/driver/ccs811.cc @@ -0,0 +1,29 @@ +#include "driver/ccs811.h" +#include "driver/gpio.h" +#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C) +#include "driver/i2c.h" +#else +#include "driver/soft_i2c.h" +#endif + +#ifdef MULTIPASS_ARCH_esp8266 +#define nWAKE GPIO::d5 +#endif + +void CCS811::init() +{ + gpio.output(nWAKE); + gpio.write(nWAKE, 1); +} + +short CCS811::check() +{ + gpio.write(nWAKE, 0); + txbuf[0] = 0x20; + rxbuf[0] = 0; + i2c.xmit(address, 1, txbuf, 1, rxbuf); + gpio.write(nWAKE, 1); + return rxbuf[0]; +} + +CCS811 ccs811(0x5a); -- cgit v1.2.3