summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/dev
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2023-04-21 21:18:29 +0200
committerUros Majstorovic <majstor@majstor.org>2023-04-21 21:18:29 +0200
commit9cb8a37e71945800da5aa6fc05a9a32dc7bd0b69 (patch)
tree28ce0f9d040f2a9d84ae197a1eb4e8e9878887ff /fw/fe310/eos/dev
parenta0059ab4365f41c84bb8bdf914477f5d4feeb985 (diff)
fixed gpio out val change when i2s is running
Diffstat (limited to 'fw/fe310/eos/dev')
-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;
}