summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-09-04 18:16:56 +0200
committerUros Majstorovic <majstor@majstor.org>2022-09-04 18:16:56 +0200
commit2b446dda5db1df77b9951d2c1908259076b1fbe1 (patch)
tree8a9e6a7fe92b93c0b1d6722d6c122eaa66870552
parentec0caa569b356f186e87c13e50550ca1b807dde6 (diff)
eve support when i2s is running
-rw-r--r--fw/fe310/eos/dev/eve.c73
-rw-r--r--fw/fe310/eos/dev/eve.h14
2 files changed, 48 insertions, 39 deletions
diff --git a/fw/fe310/eos/dev/eve.c b/fw/fe310/eos/dev/eve.c
index 4d86677..dd72b0f 100644
--- a/fw/fe310/eos/dev/eve.c
+++ b/fw/fe310/eos/dev/eve.c
@@ -17,16 +17,24 @@
#include "eve.h"
-static void handle_time(unsigned char type) {
- if (!eos_eve_running()) return;
+#define EVE_POLL_INTERVAL 2
+static void handle_time(unsigned char type) {
eve_select();
eve_handle_time();
eve_deselect();
}
-static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
- if (!eos_eve_running()) return;
+static void handle_poll(unsigned char type) {
+ if (eos_eve_intr_enabled()) return;
+
+ eve_select();
+ eve_handle_intr();
+ eve_deselect();
+}
+
+static void handle_intr_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+ if (!eos_eve_intr_enabled()) return;
eve_select();
eve_handle_intr();
@@ -41,26 +49,6 @@ static void handle_intr(void) {
eos_evtq_push_isr(EOS_EVT_EVE | EVE_ETYPE_INTR, NULL, 0);
}
-static void _start(void) {
- eve_touch_start();
- eve_start();
-
- GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INTR);
- GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
-
- eos_intr_enable(INT_GPIO_BASE + EVE_PIN_INTR);
-}
-
-static void _stop(void) {
- eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR);
-
- GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
- GPIO_REG(GPIO_INPUT_EN) &= ~(1 << EVE_PIN_INTR);
-
- eve_touch_stop();
- eve_stop();
-}
-
int eos_eve_init(uint8_t wakeup_cause) {
int rst = (wakeup_cause == EOS_PWR_WAKE_RST);
int rv = EVE_OK;
@@ -81,7 +69,7 @@ int eos_eve_init(uint8_t wakeup_cause) {
eve_touch_init();
- eos_evtq_set_handler(EOS_EVT_EVE, handle_evt);
+ eos_evtq_set_handler(EOS_EVT_EVE, handle_intr_evt);
eos_timer_set_handler(EOS_TIMER_ETYPE_UI, handle_time);
eos_intr_set_handler(INT_GPIO_BASE + EVE_PIN_INTR, handle_intr);
eos_intr_set_priority(INT_GPIO_BASE + EVE_PIN_INTR, IRQ_PRIORITY_EVE);
@@ -128,25 +116,38 @@ void eos_eve_set_tmatrix(const uint32_t *matrix) {
int eos_eve_run(uint8_t wakeup_cause) {
eve_select();
- _start();
- eve_start_clk();
+ eve_touch_start();
+ eve_intr_enable();
+ eve_clk_start();
eve_deselect();
+ eos_eve_intr_enable();
return EOS_OK;
}
-void eos_eve_start(void) {
- eve_select();
- _start();
- eve_deselect();
+void eos_eve_intr_enable(void) {
+ GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INTR);
+ GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
+
+ eos_intr_enable(INT_GPIO_BASE + EVE_PIN_INTR);
+ eos_timer_set_handler(EOS_TIMER_ETYPE_EVE, NULL);
}
-void eos_eve_stop(void) {
- eve_select();
- _stop();
- eve_deselect();
+void eos_eve_intr_disable(void) {
+ eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR);
+
+ GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
+ GPIO_REG(GPIO_INPUT_EN) &= ~(1 << EVE_PIN_INTR);
+ eos_timer_set_handler(EOS_TIMER_ETYPE_EVE, handle_poll);
}
-int eos_eve_running(void) {
+int eos_eve_intr_enabled(void) {
return !!(GPIO_REG(GPIO_INPUT_EN) & (1 << EVE_PIN_INTR));
}
+
+void eos_eve_poll(void) {
+ if (eos_eve_intr_enabled()) return;
+ if (eos_timer_get(EOS_TIMER_ETYPE_EVE) != EOS_TIMER_NONE) return;
+
+ eos_timer_set(EOS_TIMER_ETYPE_EVE, EVE_POLL_INTERVAL);
+}
diff --git a/fw/fe310/eos/dev/eve.h b/fw/fe310/eos/dev/eve.h
index cb48364..1317bec 100644
--- a/fw/fe310/eos/dev/eve.h
+++ b/fw/fe310/eos/dev/eve.h
@@ -1,9 +1,17 @@
#include <stdint.h>
+#define EVE_GPIO_DIR 0xf
+
+#define EVE_GPIO_CAM 0
+#define EVE_GPIO_LCD_EN 1
+#define EVE_GPIO_GAIN 2
+#define EVE_GPIO_HAPT 3
+
int eos_eve_init(uint8_t wakeup_cause);
void eos_eve_calibrate(void);
void eos_eve_set_tmatrix(const uint32_t *matrix);
int eos_eve_run(uint8_t wakeup_cause);
-void eos_eve_start(void);
-void eos_eve_stop(void);
-int eos_eve_running(void);
+void eos_eve_intr_enable(void);
+void eos_eve_intr_disable(void);
+int eos_eve_intr_enabled(void);
+void eos_eve_poll(void);