summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-11-30 22:05:17 +0100
committerUros Majstorovic <majstor@majstor.org>2021-11-30 22:05:17 +0100
commit5506d89d97db87f78ab2ba4715c4248a3d49f98f (patch)
treee4ef547d541968e552a6f521ab637084b253fa68 /fw/fe310/eos/eve
parentacce7d8e05ac38776d6340342f6a7868df4f7f28 (diff)
startup code uses init/run
Diffstat (limited to 'fw/fe310/eos/eve')
-rw-r--r--fw/fe310/eos/eve/eve.c46
-rw-r--r--fw/fe310/eos/eve/eve.h3
-rwxr-xr-xfw/fe310/eos/eve/eve_config.h16
-rw-r--r--fw/fe310/eos/eve/eve_platform.h6
-rw-r--r--fw/fe310/eos/eve/eve_touch.c26
-rw-r--r--fw/fe310/eos/eve/eve_touch.h5
6 files changed, 71 insertions, 31 deletions
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c
index 8cca34b..ddfd4c0 100644
--- a/fw/fe310/eos/eve/eve.c
+++ b/fw/fe310/eos/eve/eve.c
@@ -375,8 +375,25 @@ static int _init(uint8_t gpio_dir) {
return EVE_OK;
}
+static void _start(void) {
+ uint16_t gpiox;
+
+ gpiox = eve_read16(REG_GPIOX) | 0x8000;
+ eve_write16(REG_GPIOX, gpiox); /* enable the DISP signal to the LCD panel, it is set to output in REG_GPIOX_DIR by default */
+ eve_write8(REG_PCLK, EVE_PCLK); /* now start clocking data to the LCD panel */
+}
+
+static void _stop(void) {
+ uint16_t gpiox;
+
+ gpiox = eve_read16(REG_GPIOX) & ~0x8000;
+ eve_write16(REG_GPIOX, gpiox);
+ eve_write8(REG_PCLK, 0);
+}
+
int eve_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix, uint8_t gpio_dir) {
- int rst = (wakeup_cause == EVE_INIT_RST);
+ int rv;
+ int rst = (wakeup_cause == EVE_WAKE_RST);
if (rst) {
int rv = _init(gpio_dir);
@@ -386,30 +403,33 @@ int eve_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix,
eve_time_sleep(40);
}
- eve_touch_init(wakeup_cause, touch_calibrate, touch_matrix);
+ rv = eve_touch_init(wakeup_cause, touch_calibrate, touch_matrix);
+ if (rv) return rv;
+
eve_platform_init();
return EVE_OK;
}
-void eve_start(uint8_t wakeup_cause) {
- uint16_t gpiox;
+int eve_run(uint8_t wakeup_cause) {
+ int rv;
- gpiox = eve_read16(REG_GPIOX) | 0x8000;
- eve_write16(REG_GPIOX, gpiox); /* enable the DISP signal to the LCD panel, it is set to output in REG_GPIOX_DIR by default */
- eve_write8(REG_PCLK, EVE_PCLK); /* now start clocking data to the LCD panel */
+ _start();
+ rv = eve_touch_run(wakeup_cause);
- eve_touch_start(wakeup_cause);
+ return rv;
+}
+
+void eve_start(void) {
+ _start();
+ eve_touch_start();
}
void eve_stop(void) {
uint16_t gpiox;
eve_touch_stop();
-
- gpiox = eve_read16(REG_GPIOX) & ~0x8000;
- eve_write16(REG_GPIOX, gpiox);
- eve_write8(REG_PCLK, 0);
+ _stop();
}
int eve_gpio_get(int gpio) {
@@ -469,7 +489,7 @@ void eve_active(void) {
if (power_state == EVE_PSTATE_SLEEP) {
eve_time_sleep(40);
- eve_start(0);
+ eve_start();
}
power_state = EVE_PSTATE_ACTIVE;
diff --git a/fw/fe310/eos/eve/eve.h b/fw/fe310/eos/eve/eve.h
index 363905c..ae0a672 100644
--- a/fw/fe310/eos/eve/eve.h
+++ b/fw/fe310/eos/eve/eve.h
@@ -57,7 +57,8 @@ void eve_cmd_burst_start(void);
void eve_cmd_burst_end(void);
int eve_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix, uint8_t gpio_dir);
-void eve_start(uint8_t wakeup_cause);
+int eve_run(uint8_t wakeup_cause);
+void eve_start(void);
void eve_stop(void);
int eve_gpio_get(int gpio);
diff --git a/fw/fe310/eos/eve/eve_config.h b/fw/fe310/eos/eve/eve_config.h
index b151c63..1126277 100755
--- a/fw/fe310/eos/eve/eve_config.h
+++ b/fw/fe310/eos/eve/eve_config.h
@@ -3,19 +3,20 @@
/* FocusLCDs E50RG84885LWAM520-CA */
-#define EVE_HLPW 20 /* horizontal low pulse width */
-#define EVE_HBP 60 /* horizontal back porch */
-#define EVE_HFP 40 /* horizontal front porch */
+#define EVE_HLPW 6 /* horizontal low pulse width */
+#define EVE_HBP 6 /* horizontal back porch */
+#define EVE_HFP 6 /* horizontal front porch */
#define EVE_HACT 480 /* horizontal active pixels */
#define EVE_HTOT (EVE_HLPW + EVE_HBP + EVE_HFP + EVE_HACT + 10)
-#define EVE_VLPW 26 /* vertical low pulse width */
-#define EVE_VBP 50 /* vertical back porch */
-#define EVE_VFP 30 /* vertical front porch */
+#define EVE_VLPW 6 /* vertical low pulse width */
+#define EVE_VBP 6 /* vertical back porch */
+#define EVE_VFP 6 /* vertical front porch */
#define EVE_VACT 854 /* vertical active pixels */
#define EVE_VTOT (EVE_VLPW + EVE_VBP + EVE_VFP + EVE_VACT + 10)
+
#define EVE_HCYCLE (EVE_HTOT) /* Th Total length of line (visible and non-visible) (in PCLKs) */
#define EVE_HSIZE (EVE_HACT) /* Length of visible part of line (in PCLKs) - display width */
#define EVE_HOFFSET (EVE_HFP + EVE_HLPW + EVE_HBP) /* Length of non-visible part of line (in PCLK cycles) */
@@ -32,7 +33,8 @@
#define EVE_SWIZZLE 0 /* Defines the arrangement of the RGB pins */
#define EVE_CSPREAD 0 /* helps with noise, when set to 1 fewer signals are changed simultaneously, reset-default: 1 */
-#define EVE_PCLK 2 /* 36 MHz */
+#define EVE_PCLK 1 /* Clock from EVE_PCLK_FREQ */
+#define EVE_PCLK_FREQ 27000000
#define EVE_GEN 4
diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h
index 587e1cf..b33bd48 100644
--- a/fw/fe310/eos/eve/eve_platform.h
+++ b/fw/fe310/eos/eve/eve_platform.h
@@ -12,9 +12,9 @@
#define EVE_SPI_FLAG_BSWAP EOS_SPI_FLAG_BSWAP
#define EVE_SPI_FLAG_TX EOS_SPI_FLAG_TX
-#define EVE_INIT_RST EOS_INIT_RST
-#define EVE_INIT_RTC EOS_INIT_RTC
-#define EVE_INIT_BTN EOS_INIT_BTN
+#define EVE_WAKE_RST EOS_PWR_WAKE_RST
+#define EVE_WAKE_RTC EOS_PWR_WAKE_RTC
+#define EVE_WAKE_BTN EOS_PWR_WAKE_BTN
void *eve_malloc(size_t);
void eve_free(void *);
diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c
index fc9d040..ff155d5 100644
--- a/fw/fe310/eos/eve/eve_touch.c
+++ b/fw/fe310/eos/eve/eve_touch.c
@@ -336,8 +336,16 @@ static void _init(int touch_calibrate, uint32_t *touch_matrix) {
while(eve_read8(REG_INT_FLAGS));
}
-void eve_touch_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix) {
- int rst = (wakeup_cause == EVE_INIT_RST);
+static void _start(void) {
+ eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS);
+}
+
+static void _stop(void) {
+ eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF);
+}
+
+int eve_touch_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix) {
+ int rst = (wakeup_cause == EVE_WAKE_RST);
int i;
eve_vtrack_init();
@@ -348,14 +356,22 @@ void eve_touch_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_m
}
if (rst) _init(touch_calibrate, touch_matrix);
+
+ return EVE_OK;
}
-void eve_touch_start(uint8_t wakeup_cause) {
- eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS);
+int eve_touch_run(uint8_t wakeup_cause) {
+ _start();
+
+ return EVE_OK;
+}
+
+void eve_touch_start(void) {
+ _start();
}
void eve_touch_stop(void) {
- eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF);
+ _stop();
}
void eve_touch_set_handler(eve_touch_handler_t handler, void *param) {
diff --git a/fw/fe310/eos/eve/eve_touch.h b/fw/fe310/eos/eve/eve_touch.h
index b6ca6d9..37c4013 100644
--- a/fw/fe310/eos/eve/eve_touch.h
+++ b/fw/fe310/eos/eve/eve_touch.h
@@ -101,8 +101,9 @@ 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_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix);
-void eve_touch_start(uint8_t wakeup_cause);
+int eve_touch_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix);
+int eve_touch_run(uint8_t wakeup_cause);
+void eve_touch_start(void);
void eve_touch_stop(void);
void eve_touch_set_handler(eve_touch_handler_t handler, void *handler_param);