summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/i2cdetect/main.cc13
-rw-r--r--src/driver/eeprom24lc64.cc26
-rw-r--r--src/driver/soft_i2c.cc2
3 files changed, 41 insertions, 0 deletions
diff --git a/src/app/i2cdetect/main.cc b/src/app/i2cdetect/main.cc
index 5094fd5..4ec49d9 100644
--- a/src/app/i2cdetect/main.cc
+++ b/src/app/i2cdetect/main.cc
@@ -12,6 +12,9 @@
#ifdef DRIVER_AM2320
#include "driver/am2320.h"
#endif
+#ifdef DRIVER_EEPROM24LC64
+#include "driver/eeprom24lc64.h"
+#endif
#ifdef DRIVER_MAX44009
#include "driver/max44009.h"
#endif
@@ -40,6 +43,16 @@ void loop(void)
kout.printf_float(max44009.getLux());
kout << endl;
#endif
+#ifdef DRIVER_EEPROM24LC64
+ char buf[33];
+ static unsigned char page = 0;
+ eeprom24lc64.writePage(page, "Hello, World! Und so weiter, lol");
+ arch.delay_ms(10);
+ eeprom24lc64.readPage(page, buf);
+ buf[32] = '\0';
+ kout << "Address " << page << ": " << buf << endl;
+ page++;
+#endif
#ifdef DRIVER_MMSIMPLE
moody.toggleBlue();
#endif
diff --git a/src/driver/eeprom24lc64.cc b/src/driver/eeprom24lc64.cc
new file mode 100644
index 0000000..745514b
--- /dev/null
+++ b/src/driver/eeprom24lc64.cc
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include "driver/eeprom24lc64.h"
+#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
+#include "driver/i2c.h"
+#else
+#include "driver/soft_i2c.h"
+#endif
+
+void EEPROM24LC64::readPage(unsigned short addr, char *data)
+{
+ txbuf[0] = addr >> 8;
+ txbuf[1] = addr & 0x00ff;
+ i2c.xmit(address, 2, txbuf, 32, (unsigned char *)data);
+}
+
+void EEPROM24LC64::writePage(unsigned short addr, char *data)
+{
+ txbuf[0] = addr >> 8;
+ txbuf[1] = addr & 0x00ff;
+ for (unsigned char i = 0; i < 32; i++) {
+ txbuf[i+2] = data[i];
+ }
+ i2c.xmit(address, 34, txbuf, 0, NULL);
+}
+
+EEPROM24LC64 eeprom24lc64(0x50);
diff --git a/src/driver/soft_i2c.cc b/src/driver/soft_i2c.cc
index cebd8be..33f77ab 100644
--- a/src/driver/soft_i2c.cc
+++ b/src/driver/soft_i2c.cc
@@ -140,6 +140,8 @@ signed char SoftI2C::xmit(unsigned char address,
SoftI2C i2c(GPIO::d7, GPIO::d8);
#elif MULTIPASS_ARCH_arduino_nano
SoftI2C i2c(GPIO::pc4, GPIO::pc5);
+#elif MULTIPASS_ARCH_blinkenrocket
+SoftI2C i2c(GPIO::pc4, GPIO::pc5);
#elif MULTIPASS_ARCH_msp430fr5969lp
SoftI2C i2c(GPIO::p1_6, GPIO::p1_7);
#endif