Loading Makefile +5 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,11 @@ ifneq ($(findstring lm75,${drivers}), ) COMMON_FLAGS += -DDRIVER_LM75 endif ifneq ($(findstring s5851a,${drivers}), ) CXX_TARGETS += src/driver/s5851a.cc COMMON_FLAGS += -DDRIVER_S5851A endif ifneq ($(findstring am2320,${drivers}), ) CXX_TARGETS += src/driver/am2320.cc COMMON_FLAGS += -DDRIVER_AM2320 Loading include/driver/s5851a.h 0 → 100644 +19 −0 Original line number Diff line number Diff line #ifndef S5851A_H #define S5851A_H class S5851A { private: S5851A(const S5851A ©); unsigned char const address; unsigned char txbuf[1]; unsigned char rxbuf[2]; public: S5851A(unsigned char const addr) : address(addr) {} float getTemp(); }; extern S5851A s5851a; #endif src/app/i2cdetect/main.cc +13 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ #ifdef DRIVER_LM75 #include "driver/lm75.h" #endif #ifdef DRIVER_S5851A #include "driver/s5851a.h" #endif #ifdef DRIVER_AM2320 #include "driver/am2320.h" #endif Loading Loading @@ -45,6 +48,10 @@ void loop(void) kout.printf_float(lm75.getTemp()); kout << endl; #endif #ifdef DRIVER_S5851A kout.printf_float(s5851a.getTemp()); kout << endl; #endif #ifdef DRIVER_AM2320 am2320.read(); if (am2320.getStatus() == 0) { Loading Loading @@ -116,6 +123,12 @@ void loop(void) kout << "CCS811 status is " << ccs811.check() << endl; #endif #ifdef DRIVER_HDC1080 /* hdc1080.heater(1); for (unsigned char i = 0; i < 50; i++) { hdc1080.getTemp(); } */ kout << "HDC1080 temperature " << hdc1080.getTemp() << " degC" << endl; kout << "HDC1080 humidity " << hdc1080.getRH() << " %H" << endl; #endif Loading src/driver/s5851a.cc 0 → 100644 +18 −0 Original line number Diff line number Diff line #include "driver/s5851a.h" #if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C) #include "driver/i2c.h" #else #include "driver/soft_i2c.h" #endif float S5851A::getTemp() { txbuf[0] = 0; rxbuf[0] = 0; rxbuf[1] = 0; i2c.xmit(address, 1, txbuf, 2, rxbuf); return rxbuf[0] + (rxbuf[1] / 256.0); } S5851A s5851a(0x4b); Loading
Makefile +5 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,11 @@ ifneq ($(findstring lm75,${drivers}), ) COMMON_FLAGS += -DDRIVER_LM75 endif ifneq ($(findstring s5851a,${drivers}), ) CXX_TARGETS += src/driver/s5851a.cc COMMON_FLAGS += -DDRIVER_S5851A endif ifneq ($(findstring am2320,${drivers}), ) CXX_TARGETS += src/driver/am2320.cc COMMON_FLAGS += -DDRIVER_AM2320 Loading
include/driver/s5851a.h 0 → 100644 +19 −0 Original line number Diff line number Diff line #ifndef S5851A_H #define S5851A_H class S5851A { private: S5851A(const S5851A ©); unsigned char const address; unsigned char txbuf[1]; unsigned char rxbuf[2]; public: S5851A(unsigned char const addr) : address(addr) {} float getTemp(); }; extern S5851A s5851a; #endif
src/app/i2cdetect/main.cc +13 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ #ifdef DRIVER_LM75 #include "driver/lm75.h" #endif #ifdef DRIVER_S5851A #include "driver/s5851a.h" #endif #ifdef DRIVER_AM2320 #include "driver/am2320.h" #endif Loading Loading @@ -45,6 +48,10 @@ void loop(void) kout.printf_float(lm75.getTemp()); kout << endl; #endif #ifdef DRIVER_S5851A kout.printf_float(s5851a.getTemp()); kout << endl; #endif #ifdef DRIVER_AM2320 am2320.read(); if (am2320.getStatus() == 0) { Loading Loading @@ -116,6 +123,12 @@ void loop(void) kout << "CCS811 status is " << ccs811.check() << endl; #endif #ifdef DRIVER_HDC1080 /* hdc1080.heater(1); for (unsigned char i = 0; i < 50; i++) { hdc1080.getTemp(); } */ kout << "HDC1080 temperature " << hdc1080.getTemp() << " degC" << endl; kout << "HDC1080 humidity " << hdc1080.getRH() << " %H" << endl; #endif Loading
src/driver/s5851a.cc 0 → 100644 +18 −0 Original line number Diff line number Diff line #include "driver/s5851a.h" #if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C) #include "driver/i2c.h" #else #include "driver/soft_i2c.h" #endif float S5851A::getTemp() { txbuf[0] = 0; rxbuf[0] = 0; rxbuf[1] = 0; i2c.xmit(address, 1, txbuf, 2, rxbuf); return rxbuf[0] + (rxbuf[1] / 256.0); } S5851A s5851a(0x4b);