summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/i2c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-11-17 20:42:47 +0100
committerUros Majstorovic <majstor@majstor.org>2021-11-17 20:42:47 +0100
commitb0e84c72d7a533f62ca750a73445da7fcebe8d18 (patch)
treed091c2307cd667fc9dd1c22e7c80e9ab9ceed445 /fw/fe310/eos/i2c
parent9d1721008fe1d35abdedbff063ef29d35996124c (diff)
wakeup cause added to init functions
Diffstat (limited to 'fw/fe310/eos/i2c')
-rw-r--r--fw/fe310/eos/i2c/bq25895.c24
-rw-r--r--fw/fe310/eos/i2c/bq25895.h2
2 files changed, 17 insertions, 9 deletions
diff --git a/fw/fe310/eos/i2c/bq25895.c b/fw/fe310/eos/i2c/bq25895.c
index 934b5e7..2b45f88 100644
--- a/fw/fe310/eos/i2c/bq25895.c
+++ b/fw/fe310/eos/i2c/bq25895.c
@@ -3,20 +3,28 @@
#include <stdio.h>
#include "eos.h"
+#include "power.h"
#include "i2c.h"
#include "i2c/bq25895.h"
-void eos_bq25895_init(void) {
- uint8_t data = 0;
+void eos_bq25895_init(uint8_t wakeup_cause) {
+ int rst = (wakeup_cause == EOS_PWR_WAKE_RST);
int i, ret = EOS_OK;
+ uint8_t data = 0;
eos_i2c_start(100000);
- ret = eos_i2c_write8(BQ25895_ADDR, 0x07, 0x8d); // disable watchdog
- if (ret) printf("I2C ERROR 0x07\n");
- ret = eos_i2c_write8(BQ25895_ADDR, 0x00, 0x28); // 2.1A input current
- if (ret) printf("I2C ERROR 0x00\n");
- ret = eos_i2c_write8(BQ25895_ADDR, 0x03, 0x1e); // sysmin 3.7, disable otg
- if (ret) printf("I2C ERROR 0x03\n");
+ if (rst) {
+ ret = eos_i2c_write8(BQ25895_ADDR, 0x14, 0x80); // reset
+ if (ret) printf("I2C ERROR 0x14\n");
+ ret = eos_i2c_write8(BQ25895_ADDR, 0x14, 0x00); // disable watchdog
+ if (ret) printf("I2C ERROR 0x14\n");
+ ret = eos_i2c_write8(BQ25895_ADDR, 0x07, 0x8d); // disable watchdog
+ if (ret) printf("I2C ERROR 0x07\n");
+ ret = eos_i2c_write8(BQ25895_ADDR, 0x00, 0x28); // 2.1A input current
+ if (ret) printf("I2C ERROR 0x00\n");
+ ret = eos_i2c_write8(BQ25895_ADDR, 0x02, 0x20); // disaable MaxCharge, ICO and
+ if (ret) printf("I2C ERROR 0x02\n");
+ }
printf("BQ25895:\n");
for (i=0; i<0x15; i++) {
diff --git a/fw/fe310/eos/i2c/bq25895.h b/fw/fe310/eos/i2c/bq25895.h
index f61a46f..39c6b68 100644
--- a/fw/fe310/eos/i2c/bq25895.h
+++ b/fw/fe310/eos/i2c/bq25895.h
@@ -2,4 +2,4 @@
#define BQ25895_ADDR 0x6A
-void eos_bq25895_init(void);
+void eos_bq25895_init(uint8_t wakeup_cause);