diff options
Diffstat (limited to 'fw/fe310/eos/dev/lcd.c')
-rw-r--r-- | fw/fe310/eos/dev/lcd.c | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/fw/fe310/eos/dev/lcd.c b/fw/fe310/eos/dev/lcd.c index 59215dc..6c005b9 100644 --- a/fw/fe310/eos/dev/lcd.c +++ b/fw/fe310/eos/dev/lcd.c @@ -2,48 +2,47 @@ #include <stdint.h> #include "platform.h" +#include "board.h" #include "eos.h" -#include "board.h" - -#include "soc/timer.h" +#include "soc/pwr.h" #include "soc/i2s.h" +#include "soc/timer.h" + #include "eve/eve.h" +#include "egpio.h" +#include "spi.h" #include "eve.h" -#include "gt911.h" -#include "ili9806e.h" +#include "pwr.h" +#include "drv/ili9806e.h" #include "lcd.h" static int lcd_enable(void) { int rv; - rv = eos_spi_select(EOS_SPI_DEV_EVE); - if (rv) return rv; - - eve_gpio_set(EVE_GPIO_LCD_EN, 1); - eos_spi_deselect(); + if (eos_i2s_running() || !eos_egpio_get_val(EGPIO_PIN_DISP_SEL)) return EOS_ERR_BUSY; - return EOS_OK; + rv = eos_egpio_set_val(EGPIO_PIN_LCD_EN, 1); + return rv; } static int lcd_disable(void) { int rv; - rv = eos_spi_select(EOS_SPI_DEV_EVE); - if (rv) return rv; - - eve_gpio_set(EVE_GPIO_LCD_EN, 0); - eos_spi_deselect(); + if (eos_i2s_running() || !eos_egpio_get_val(EGPIO_PIN_DISP_SEL)) return EOS_ERR_BUSY; - return EOS_OK; + rv = eos_egpio_set_val(EGPIO_PIN_LCD_EN, 0); + return rv; } static int lcd_select(void) { int rv; + if (eos_i2s_running() || !eos_egpio_get_val(EGPIO_PIN_DISP_SEL)) return EOS_ERR_BUSY; + GPIO_REG(GPIO_OUTPUT_XOR) |= (1 << SPI_CSPIN_LCD); GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << SPI_CSPIN_LCD); GPIO_REG(GPIO_OUTPUT_EN) |= (1 << SPI_CSPIN_LCD); @@ -72,7 +71,7 @@ static int lcd_init(void) { rv = lcd_enable(); if (rv) return rv; - eos_time_sleep(200); + eos_sleep(200); rv = lcd_select(); if (rv) { @@ -80,7 +79,7 @@ static int lcd_init(void) { return rv; } - rv = eos_ili9806e_init(); + rv = ili9806e_init(); if (rv == EOS_ERR_NOTFOUND) eve_lcd_absent(); lcd_deselect(); @@ -94,51 +93,38 @@ static int lcd_sleep(void) { rv = lcd_select(); if (rv) return rv; - eos_ili9806e_sleep(); + ili9806e_sleep(); lcd_deselect(); rv = lcd_disable(); - if (rv) return rv; - - return EOS_OK; + return rv; } -int eos_lcd_init(uint8_t wakeup_cause) { - int rv; +int eos_lcd_init(void) { + uint8_t wakeup_cause; + int rv, rst; - rv = lcd_init(); - if (rv) return rv; - - rv = eos_gt911_init(wakeup_cause); - if (rv) return rv; + wakeup_cause = eos_pwr_wakeup_cause(); + rst = (wakeup_cause == EOS_PWR_WAKE_RST); + if (rst) { + rv = lcd_init(); + } else { + rv = eos_lcd_wake(); + } - return EOS_OK; + return rv; } int eos_lcd_sleep(void) { int rv; - if (eos_i2s_running()) return EOS_ERR_BUSY; - - /* There is a problem with GT911 and sleep */ - // eos_gt911_sleep(); - rv = lcd_sleep(); - if (rv) return rv; - - return EOS_OK; + return rv; } int eos_lcd_wake(void) { int rv; - if (eos_i2s_running()) return EOS_ERR_BUSY; - rv = lcd_init(); - if (rv) return rv; - - /* There is a problem with GT911 and sleep */ - // eos_gt911_wake(); - - return EOS_OK; + return rv; } |