diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-05-23 23:59:04 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-05-23 23:59:04 +0200 |
commit | 8cab5fea518d4bf6c680816f8ba8b7b7d9ee7401 (patch) | |
tree | faa5c53a57aaf22e53892e22d29f013f79994c5c /code/fe310/eos/eve | |
parent | 34da9599242ed7784c42f548e2d188d3d577c866 (diff) |
eve power amanger fix
Diffstat (limited to 'code/fe310/eos/eve')
-rw-r--r-- | code/fe310/eos/eve/eve.c | 36 | ||||
-rw-r--r-- | code/fe310/eos/eve/eve.h | 10 |
2 files changed, 27 insertions, 19 deletions
diff --git a/code/fe310/eos/eve/eve.c b/code/fe310/eos/eve/eve.c index 430b998..8d8a15a 100644 --- a/code/fe310/eos/eve/eve.c +++ b/code/fe310/eos/eve/eve.c @@ -11,7 +11,7 @@ static uint16_t _cmd_offset; static uint32_t _dl_addr; static uint32_t *_touch_calib; static uint8_t _brigtness; -static char _sleep; +static uint8_t _power_state; void eve_command(uint8_t command, uint8_t parameter) { eve_spi_cs_set(); @@ -235,18 +235,31 @@ void eve_cmd_burst_end(void) { _cmd_burst = 0; } -void eve_active(void){ +void eve_active(void) { 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; + + eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); + eve_write8(REG_CTOUCH_EXTENDED, 0x00); + + _power_state = EVE_PSTATE_ACTIVE; } void eve_standby(void) { + if (_power_state != EVE_PSTATE_ACTIVE) return; + + _brigtness = eve_read8(REG_PWM_DUTY); eve_command(EVE_STANDBY, 0); + + _power_state = EVE_PSTATE_STANDBY; } void eve_sleep(void) { - if (_sleep) return; + if (_power_state != EVE_PSTATE_ACTIVE) return; - _sleep = 1; _brigtness = eve_read8(REG_PWM_DUTY); eve_write8(REG_PWM_DUTY, 0x0); @@ -255,17 +268,8 @@ void eve_sleep(void) { eve_time_sleep(500); eve_command(EVE_SLEEP, 0); -} - -void eve_wake(void) { - eve_command(EVE_ACTIVE, 0); /* start EVE */ - eve_time_sleep(40); - eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); - eve_write8(REG_CTOUCH_EXTENDED, 0x00); - - eve_write8(REG_PWM_DUTY, _brigtness); - _sleep = 0; + _power_state = EVE_PSTATE_SLEEP; } void eve_brightness(uint8_t b) { @@ -373,8 +377,8 @@ int eve_init(int pwr_on) { int rv = _init(); if (rv) return rv; } else { - _sleep = 1; - eve_wake(); + _power_state = EVE_PSTATE_SLEEP; + eve_active(); } eve_init_touch(); diff --git a/code/fe310/eos/eve/eve.h b/code/fe310/eos/eve/eve.h index 2fb2fb5..2ac93a2 100644 --- a/code/fe310/eos/eve/eve.h +++ b/code/fe310/eos/eve/eve.h @@ -5,9 +5,13 @@ #include "eve_track.h" #include "eve_platform.h" -#define EVE_OK 0 -#define EVE_ERR -1 -#define EVE_ERR_TEXT -100 +#define EVE_OK 0 +#define EVE_ERR -1 +#define EVE_ERR_TEXT -100 + +#define EVE_PSTATE_ACTIVE 0 +#define EVE_PSTATE_STANDBY 1 +#define EVE_PSTATE_SLEEP 3 void eve_command(uint8_t command, uint8_t parameter); |