summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--include/driver/eeprom24lc64.h19
-rw-r--r--src/app/i2cdetect/main.cc13
-rw-r--r--src/driver/eeprom24lc64.cc26
-rw-r--r--src/driver/soft_i2c.cc2
5 files changed, 65 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 4e74e6a..5d8b2ad 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,11 @@ ifneq ($(findstring am2320,${drivers}), )
COMMON_FLAGS += -DDRIVER_AM2320
endif
+ifneq ($(findstring eeprom24lc64,${drivers}), )
+ TARGETS += src/driver/eeprom24lc64.cc
+ COMMON_FLAGS += -DDRIVER_EEPROM24LC64
+endif
+
ifneq ($(findstring max44006,${drivers}), )
TARGETS += src/driver/max44006.cc
COMMON_FLAGS += -DDRIVER_MAX44006
diff --git a/include/driver/eeprom24lc64.h b/include/driver/eeprom24lc64.h
new file mode 100644
index 0000000..66e7666
--- /dev/null
+++ b/include/driver/eeprom24lc64.h
@@ -0,0 +1,19 @@
+#ifndef EEPROM24LC64_H
+#define EEPROM24LC64_H
+
+class EEPROM24LC64 {
+ private:
+ EEPROM24LC64(const EEPROM24LC64 &copy);
+ unsigned char const address;
+ unsigned char txbuf[34];
+
+ public:
+ EEPROM24LC64(unsigned char const addr) : address(addr) {}
+
+ void writePage(unsigned short addr, char *buf);
+ void readPage(unsigned short addr, char *buf);
+};
+
+extern EEPROM24LC64 eeprom24lc64;
+
+#endif
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