summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-11-18 03:18:18 +0100
committerUros Majstorovic <majstor@majstor.org>2021-11-18 03:18:18 +0100
commitc44897fda572cf8837b4535a6d1aaad4605c14af (patch)
treec3c98c36589253da3a1a6308ec2804b5eb4a4d75 /fw
parentb0e84c72d7a533f62ca750a73445da7fcebe8d18 (diff)
eve sleep improved
Diffstat (limited to 'fw')
-rw-r--r--fw/fe310/eos/board.h2
-rw-r--r--fw/fe310/eos/eve/eve.c32
-rw-r--r--fw/fe310/eos/eve/eve_touch.c11
-rw-r--r--fw/fe310/eos/eve/eve_touch.h2
-rw-r--r--fw/fe310/eos/i2c/bq25895.c2
5 files changed, 32 insertions, 17 deletions
diff --git a/fw/fe310/eos/board.h b/fw/fe310/eos/board.h
index 5509f78..611751b 100644
--- a/fw/fe310/eos/board.h
+++ b/fw/fe310/eos/board.h
@@ -38,7 +38,7 @@
#define I2S_IDLE_CYCLES 8
-#define EVE_GPIO_DIR 0x0f
+#define EVE_GPIO_DIR 0xf
#define EVE_GPIO_CAM 0
#define EVE_GPIO_EXT 1
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c
index 0fb55d4..3447d6b 100644
--- a/fw/fe310/eos/eve/eve.c
+++ b/fw/fe310/eos/eve/eve.c
@@ -13,7 +13,6 @@ static uint16_t cmd_offset;
static char dl_burst;
static uint32_t dl_addr;
-static uint8_t brigtness;
static uint8_t power_state;
void eve_command(uint8_t command, uint8_t parameter) {
@@ -323,37 +322,44 @@ void eve_gpio_set_dir(uint8_t dir) {
}
void eve_active(void) {
+ uint16_t gpiox;
+
eve_command(EVE_ACTIVE, 0);
- if (power_state == EVE_PSTATE_SLEEP) eve_time_sleep(40);
- eve_write8(REG_PWM_DUTY, brigtness);
- if (power_state != EVE_PSTATE_SLEEP) return;
+ if (power_state == EVE_PSTATE_SLEEP) {
+ eve_time_sleep(40);
+ eve_touch_active();
+ }
- eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS);
- eve_write8(REG_CTOUCH_EXTENDED, 0x00);
+ gpiox = eve_read16(REG_GPIOX) | 0x8000;
+ eve_write16(REG_GPIOX, gpiox);
power_state = EVE_PSTATE_ACTIVE;
}
void eve_standby(void) {
+ uint16_t gpiox;
+
if (power_state != EVE_PSTATE_ACTIVE) return;
- brigtness = eve_read8(REG_PWM_DUTY);
+ gpiox = eve_read16(REG_GPIOX) & ~0x8000;
+ eve_write16(REG_GPIOX, gpiox);
+
eve_command(EVE_STANDBY, 0);
power_state = EVE_PSTATE_STANDBY;
}
void eve_sleep(void) {
+ uint16_t gpiox;
+
if (power_state != EVE_PSTATE_ACTIVE) return;
- brigtness = eve_read8(REG_PWM_DUTY);
- eve_write8(REG_PWM_DUTY, 0x0);
+ gpiox = eve_read16(REG_GPIOX) & ~0x8000;
+ eve_write16(REG_GPIOX, gpiox);
- eve_write8(REG_CTOUCH_EXTENDED, 0x01);
- eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF);
+ eve_touch_sleep();
- eve_time_sleep(500);
eve_command(EVE_SLEEP, 0);
power_state = EVE_PSTATE_SLEEP;
@@ -394,7 +400,7 @@ static int _init(int touch_calibrate, uint32_t *touch_matrix, uint8_t gpio_dir)
eve_write8(REG_PWM_DUTY, 0x00);
eve_write16(REG_GPIOX_DIR, 0x8000 | (gpio_dir & 0x0f));
- eve_write16(REG_GPIOX, 0);
+ eve_write16(REG_GPIOX, 0x8000);
/* initialize display */
eve_write16(REG_HCYCLE, EVE_HCYCLE); /* total number of clocks per line, incl front/back porch */
diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c
index 77a0bf9..035e122 100644
--- a/fw/fe310/eos/eve/eve_touch.c
+++ b/fw/fe310/eos/eve/eve_touch.c
@@ -300,11 +300,18 @@ void eve_handle_time(void) {
}
}
+void eve_touch_active(void) {
+ eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS);
+}
+
+void eve_touch_sleep(void) {
+ eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF);
+}
+
static void _init(int touch_calibrate, uint32_t *touch_matrix) {
/* configure touch */
- eve_write16(REG_TOUCH_CONFIG, 0xb81); /* enable touch low power mode: 0xb81 - default: 0x381 */
+ eve_write16(REG_TOUCH_CONFIG, 0x381); /* default */
eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); /* enable touch */
- eve_write16(REG_TOUCH_RZTHRESH, EVE_TOUCH_RZTHRESH); /* eliminate any false touches */
if (touch_calibrate) {
eve_write8(REG_PWM_DUTY, 0x40);
diff --git a/fw/fe310/eos/eve/eve_touch.h b/fw/fe310/eos/eve/eve_touch.h
index 148ed48..074d37a 100644
--- a/fw/fe310/eos/eve/eve_touch.h
+++ b/fw/fe310/eos/eve/eve_touch.h
@@ -101,6 +101,8 @@ typedef void (*eve_touch_handler_t) (EVETouch *, uint16_t, uint8_t, void *);
void eve_handle_touch(void);
void eve_handle_time(void);
+void eve_touch_active(void);
+void eve_touch_sleep(void);
void eve_touch_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix);
void eve_touch_set_handler(eve_touch_handler_t handler, void *handler_param);
EVETouch *eve_touch_get(int i);
diff --git a/fw/fe310/eos/i2c/bq25895.c b/fw/fe310/eos/i2c/bq25895.c
index 2b45f88..85b162b 100644
--- a/fw/fe310/eos/i2c/bq25895.c
+++ b/fw/fe310/eos/i2c/bq25895.c
@@ -22,7 +22,7 @@ void eos_bq25895_init(uint8_t wakeup_cause) {
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
+ ret = eos_i2c_write8(BQ25895_ADDR, 0x02, 0x30); // enable ICO, disaable MaxCharge and D+/D-
if (ret) printf("I2C ERROR 0x02\n");
}