summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/dev/lcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/dev/lcd.c')
-rw-r--r--fw/fe310/eos/dev/lcd.c79
1 files changed, 49 insertions, 30 deletions
diff --git a/fw/fe310/eos/dev/lcd.c b/fw/fe310/eos/dev/lcd.c
index 69651d0..4557fb0 100644
--- a/fw/fe310/eos/dev/lcd.c
+++ b/fw/fe310/eos/dev/lcd.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <stdint.h>
-#include "encoding.h"
#include "platform.h"
#include "eos.h"
@@ -9,7 +8,7 @@
#include "board.h"
#include "soc/timer.h"
-#include "soc/pwr.h"
+#include "soc/i2s.h"
#include "eve/eve.h"
#include "eve.h"
@@ -42,7 +41,7 @@ static int lcd_disable(void) {
return EOS_OK;
}
-int lcd_select(void) {
+static int lcd_select(void) {
int rv;
GPIO_REG(GPIO_OUTPUT_XOR) |= (1 << SPI_CSPIN_LCD);
@@ -60,32 +59,36 @@ int lcd_select(void) {
return EOS_OK;
}
-void lcd_deselect(void) {
+static void lcd_deselect(void) {
eos_spi_deselect();
GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << SPI_CSPIN_LCD);
GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << SPI_CSPIN_LCD);
GPIO_REG(GPIO_OUTPUT_VAL) &= ~(1 << SPI_CSPIN_LCD);
}
-int eos_lcd_init(uint8_t wakeup_cause) {
- int rst = (wakeup_cause == EOS_PWR_WAKE_RST);
+static int lcd_init(void) {
int rv;
- rv = eos_lcd_wake();
+ rv = lcd_enable();
if (rv) return rv;
- eos_gt911_init();
- if (rst) {
- eos_gt911_reset();
- } else {
- /* There is a problem with GT911 and sleep */
- // eos_gt911_wake();
- eos_gt911_reset();
+ eos_time_sleep(200);
+
+ rv = lcd_select();
+ if (rv) {
+ lcd_disable();
+ return rv;
}
- return EOS_OK;
+
+ rv = eos_ili9806e_init();
+ if (rv == EOS_ERR_ABSENT) eve_lcd_absent();
+ lcd_deselect();
+
+ if (rv) lcd_disable();
+ return rv;
}
-int eos_lcd_sleep(void) {
+static int lcd_sleep(void) {
int rv;
rv = lcd_select();
@@ -97,29 +100,45 @@ int eos_lcd_sleep(void) {
rv = lcd_disable();
if (rv) return rv;
+ return EOS_OK;
+}
+
+int eos_lcd_init(uint8_t wakeup_cause) {
+ int rv;
+
+ rv = lcd_init();
+ if (rv) return rv;
+
+ rv = eos_gt911_init(wakeup_cause);
+ if (rv) return rv;
+
+ return EOS_OK;
+}
+
+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;
}
int eos_lcd_wake(void) {
int rv;
- rv = lcd_enable();
- if (rv) return rv;
-
- eos_time_sleep(200);
+ if (eos_i2s_running()) return EOS_ERR_BUSY;
- rv = lcd_select();
- if (rv) {
- lcd_disable();
- return rv;
- }
+ rv = lcd_init();
+ if (rv) return rv;
- rv = eos_ili9806e_init();
- if (rv == EOS_ERR_ABSENT) eve_lcd_absent();
- lcd_deselect();
+ /* There is a problem with GT911 and sleep */
+ // eos_gt911_wake();
- if (rv) lcd_disable();
- return rv;
+ return EOS_OK;
}