summaryrefslogtreecommitdiff
path: root/src/app/i2cbench/main.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-10 08:38:30 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-10 08:38:30 +0200
commit231fcce3dce0d83a291e0239efe13fe37ff735a8 (patch)
treee9a13f1ed6a073bc715e94ee07cac547d557ff6c /src/app/i2cbench/main.cc
parent2e1d846a31bc9f45851b46ac70fa75be685a5041 (diff)
Add i2cbench app
Diffstat (limited to 'src/app/i2cbench/main.cc')
-rw-r--r--src/app/i2cbench/main.cc77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/app/i2cbench/main.cc b/src/app/i2cbench/main.cc
new file mode 100644
index 0000000..5825c0b
--- /dev/null
+++ b/src/app/i2cbench/main.cc
@@ -0,0 +1,77 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
+#include "driver/i2c.h"
+#else
+#include "driver/soft_i2c.h"
+#endif
+#ifdef DRIVER_LM75
+#include "driver/lm75.h"
+#endif
+#ifdef DRIVER_AM2320
+#include "driver/am2320.h"
+#endif
+#ifdef DRIVER_EEPROM24LC64
+#include "driver/eeprom24lc64.h"
+#endif
+#ifdef DRIVER_MAX44009
+#include "driver/max44009.h"
+#endif
+#ifdef DRIVER_MMSIMPLE
+#include "driver/mmsimple.h"
+#endif
+
+void loop(void)
+{
+#ifdef DRIVER_LM75
+ kout.printf_float(lm75.getTemp());
+ kout << endl;
+#endif
+#ifdef DRIVER_AM2320
+ am2320.read();
+ if (am2320.getStatus() == 0) {
+ kout.printf_float(am2320.getTemp());
+ kout << " degC @ ";
+ kout.printf_float(am2320.getHumidity());
+ kout << " rel%" << endl;
+ } else {
+ kout << "AM2320 error " << dec << am2320.getStatus() << endl;
+ }
+#endif
+#ifdef DRIVER_MAX44009
+ kout.printf_float(max44009.getLux());
+ kout << endl;
+#endif
+#ifdef DRIVER_EEPROM24LC64
+ char buf[33];
+ static unsigned short page = 0;
+ eeprom24lc64.readPage(page, buf);
+ buf[32] = '\0';
+ kout << "Address " << page << ": " << buf << endl;
+ page = (page + 32) % (256*32);
+#endif
+#ifdef DRIVER_MMSIMPLE
+ moody.toggleBlue();
+#endif
+}
+
+unsigned int i2c_status[128 / (8 * sizeof(unsigned int)) + 1];
+
+int main(void)
+{
+
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+
+ if (i2c.setup() != 0) {
+ return 1;
+ }
+
+ kout << "I2C setup OK" << endl;
+
+ arch.idle_loop();
+
+ return 0;
+}