Skip to content
Snippets Groups Projects
Commit 231fcce3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add i2cbench app

parent 2e1d846a
No related branches found
No related tags found
No related merge requests found
arch_drivers += ,i2c
#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;
}
......@@ -73,7 +73,6 @@ int main(void)
kout << "I2C setup OK" << endl;
/*
for (unsigned char i = 0; i < sizeof(i2c_status)/sizeof(unsigned int); i++) {
i2c_status[i] = 0;
}
......@@ -96,7 +95,6 @@ int main(void)
}
}
kout << endl;
*/
arch.idle_loop();
......
......@@ -126,8 +126,6 @@ signed char I2C::xmit(unsigned char address,
unsigned char tx_len, unsigned char *tx_buf,
unsigned char rx_len, unsigned char *rx_buf)
{
unsigned char i;
if (tx_len) {
if (i2c_start_write(address) < 0) {
return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment