summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve_eos.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-08-09 22:23:08 +0200
committerUros Majstorovic <majstor@majstor.org>2022-08-09 22:23:08 +0200
commit3f913efda03fd840cd526ef72e6f397c7da61bd7 (patch)
tree08f62c93e0e0660fdb7beba32276ff1ceb7a8a3c /fw/fe310/eos/eve_eos.c
parent810dde21ee65653c15606917b19566cfbaaf165e (diff)
code layout
Diffstat (limited to 'fw/fe310/eos/eve_eos.c')
-rw-r--r--fw/fe310/eos/eve_eos.c149
1 files changed, 0 insertions, 149 deletions
diff --git a/fw/fe310/eos/eve_eos.c b/fw/fe310/eos/eve_eos.c
deleted file mode 100644
index 351cd79..0000000
--- a/fw/fe310/eos/eve_eos.c
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "platform.h"
-
-#include "eos.h"
-#include "interrupt.h"
-#include "event.h"
-#include "pwr.h"
-
-#include "board.h"
-
-#include "eve/eve.h"
-#include "eve/eve_touch_engine.h"
-
-#include "eve_eos.h"
-
-static int _run;
-
-static void handle_time(unsigned char type) {
- if (_run) {
- eve_spi_start();
- eve_handle_time();
- eve_spi_stop();
- }
-}
-
-static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
- if (_run) {
- eve_spi_start();
- eve_handle_intr();
- eve_spi_stop();
-
- GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
- }
-}
-
-static void handle_intr(void) {
- GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
- GPIO_REG(GPIO_LOW_IP) = (1 << EVE_PIN_INTR);
- 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_OUTPUT_EN) &= ~(1 << EVE_PIN_INTR);
-
- GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
-
- eos_intr_enable(INT_GPIO_BASE + EVE_PIN_INTR);
- _run = 1;
-}
-
-static void _stop(void) {
- _run = 0;
- eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR);
-
- GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
-
- eve_touch_stop();
- eve_stop();
-}
-
-int eos_eve_init(uint8_t wakeup_cause, uint8_t gpio_dir, const uint32_t *touch_matrix) {
- int rst = (wakeup_cause == EOS_PWR_WAKE_RST);
- int rv = EVE_OK;
-
- eve_spi_start();
- if (rst) {
- rv = eve_init(gpio_dir);
- if (!rv) eve_touch_init_engine(touch_matrix);
- } else {
- eve_activate();
- }
- eve_spi_stop();
-
- if (rv) return EOS_ERR;
-
- eve_touch_init();
-
- eos_evtq_set_handler(EOS_EVT_EVE, handle_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);
-
- return EOS_OK;
-}
-
-void eos_eve_calibrate(void) {
- uint32_t touch_matrix[6];
- int r;
-
- eve_spi_start();
-
- eve_brightness(0x40);
- eve_touch_set_extended(0);
-
- eve_cmd(CMD_TEXT, "hhhhs", EVE_HSIZE/2, EVE_VSIZE/2, 27, EVE_OPT_CENTER, "Please tap on the dot.");
- eve_cmd(CMD_CALIBRATE, "w", 0);
- eve_cmd_exec(0);
-
- do {
- r = eve_cmd_done();
- if (r < 0) break;
- eve_spi_stop();
- eos_evtq_exec();
- eve_spi_start();
- } while (!r);
-
- eve_touch_set_extended(1);
- eve_brightness(0);
-
- touch_matrix[0] = eve_read32(REG_TOUCH_TRANSFORM_A);
- touch_matrix[1] = eve_read32(REG_TOUCH_TRANSFORM_B);
- touch_matrix[2] = eve_read32(REG_TOUCH_TRANSFORM_C);
- touch_matrix[3] = eve_read32(REG_TOUCH_TRANSFORM_D);
- touch_matrix[4] = eve_read32(REG_TOUCH_TRANSFORM_E);
- touch_matrix[5] = eve_read32(REG_TOUCH_TRANSFORM_F);
-
- eve_spi_stop();
-
- printf("TOUCH MATRIX:\n");
- printf("uint32_t touch_matrix[6] = {0x%x,0x%x,0x%x,0x%x,0x%x,0x%x}\n", touch_matrix[0], touch_matrix[1], touch_matrix[2], touch_matrix[3], touch_matrix[4], touch_matrix[5]);
-}
-
-int eos_eve_run(uint8_t wakeup_cause) {
- eve_spi_start();
- _start();
- eve_start_clk();
- eve_spi_stop();
-
- return EOS_OK;
-}
-
-void eos_eve_start(void) {
- eve_spi_start();
- _start();
- eve_spi_stop();
-}
-
-void eos_eve_stop(void) {
- eve_spi_start();
- _stop();
- eve_spi_stop();
-}