summaryrefslogtreecommitdiff
path: root/fw/fe310/eos
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-03-29 13:39:54 +0200
committerUros Majstorovic <majstor@majstor.org>2021-03-29 13:39:54 +0200
commit4566511371a8a80201c1adb0535cde722cbd9b48 (patch)
tree713ddf042dc19ba3d7517ea5957ddd2d7c802d62 /fw/fe310/eos
parent3be79c828b4b9466fecb856b9ccf184304b852e0 (diff)
moved i2c from esp32 to fe310. added bq25895, drv2605 and lsm9ds1 i2c support
Diffstat (limited to 'fw/fe310/eos')
-rw-r--r--fw/fe310/eos/eos.c2
-rw-r--r--fw/fe310/eos/i2c/Makefile17
-rw-r--r--fw/fe310/eos/i2c/bq25895.c24
-rw-r--r--fw/fe310/eos/i2c/bq25895.h5
-rw-r--r--fw/fe310/eos/i2c/drv2605.h3
-rw-r--r--fw/fe310/eos/i2c/lsm9ds1.h4
6 files changed, 55 insertions, 0 deletions
diff --git a/fw/fe310/eos/eos.c b/fw/fe310/eos/eos.c
index 91115f6..2a7f992 100644
--- a/fw/fe310/eos/eos.c
+++ b/fw/fe310/eos/eos.c
@@ -11,6 +11,7 @@
#include "wifi.h"
#include "cell.h"
#include "sock.h"
+#include "i2c/bq25895.h"
#include "eve/eve.h"
#include "eos.h"
@@ -33,6 +34,7 @@ void eos_init(void) {
eos_cell_init();
eos_sock_init();
eos_spi_dev_init();
+ eos_bq25895_init();
eos_net_wake(wakeup_cause);
diff --git a/fw/fe310/eos/i2c/Makefile b/fw/fe310/eos/i2c/Makefile
new file mode 100644
index 0000000..694fbf8
--- /dev/null
+++ b/fw/fe310/eos/i2c/Makefile
@@ -0,0 +1,17 @@
+include ../../common.mk
+
+CFLAGS += -I..
+
+obj = bq25895.o
+
+
+%.o: %.c %.h
+ $(CC) $(CFLAGS) -c $<
+
+%.o: %.S
+ $(CC) $(CFLAGS) -c $<
+
+all: $(obj)
+
+clean:
+ rm -f *.o
diff --git a/fw/fe310/eos/i2c/bq25895.c b/fw/fe310/eos/i2c/bq25895.c
new file mode 100644
index 0000000..ab56904
--- /dev/null
+++ b/fw/fe310/eos/i2c/bq25895.c
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include "eos.h"
+#include "i2c.h"
+#include "i2c/bq25895.h"
+
+void eos_bq25895_init(void) {
+ uint8_t data = 0;
+ int i, ret = EOS_OK;
+
+ eos_i2c_start(400000);
+ eos_i2c_write8(BQ25895_ADDR, 0, 0x26); // input current: 2.0 A
+ eos_i2c_write8(BQ25895_ADDR, 2, 0x28);
+ eos_i2c_write8(BQ25895_ADDR, 7, 0x8d);
+
+ printf("BQ25895:\n");
+ for (i=0; i<0x15; i++) {
+ ret = eos_i2c_read8(BQ25895_ADDR, i, &data);
+ if (!ret) printf("REG%02x: %02x\n", i, data);
+ }
+ eos_i2c_stop();
+}
diff --git a/fw/fe310/eos/i2c/bq25895.h b/fw/fe310/eos/i2c/bq25895.h
new file mode 100644
index 0000000..f61a46f
--- /dev/null
+++ b/fw/fe310/eos/i2c/bq25895.h
@@ -0,0 +1,5 @@
+#include <stdint.h>
+
+#define BQ25895_ADDR 0x6A
+
+void eos_bq25895_init(void);
diff --git a/fw/fe310/eos/i2c/drv2605.h b/fw/fe310/eos/i2c/drv2605.h
new file mode 100644
index 0000000..fe90a9b
--- /dev/null
+++ b/fw/fe310/eos/i2c/drv2605.h
@@ -0,0 +1,3 @@
+#include <stdint.h>
+
+#define DRV2605_ADDR 0x5A
diff --git a/fw/fe310/eos/i2c/lsm9ds1.h b/fw/fe310/eos/i2c/lsm9ds1.h
new file mode 100644
index 0000000..92220e7
--- /dev/null
+++ b/fw/fe310/eos/i2c/lsm9ds1.h
@@ -0,0 +1,4 @@
+#include <stdint.h>
+
+#define LSM9DS1_ADDR_AG 0x1E
+#define LSM9DS1_ADDR_M 0x6B