diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-12-09 23:50:58 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-12-09 23:50:58 +0100 |
commit | 7d03a941be6e9226e71cb5f5b4f7949e06bbfb02 (patch) | |
tree | cde9218dbe97837f972c426552c463f5f2a6a256 /fw/fe310/eos/eve | |
parent | 9c8f5a5e8f11e4a5012d55b96afae290242b8fdd (diff) |
improved init process
Diffstat (limited to 'fw/fe310/eos/eve')
-rw-r--r-- | fw/fe310/eos/eve/eve.c | 1 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_eos.c | 58 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_touch.c | 1 |
3 files changed, 37 insertions, 23 deletions
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c index 7bb8ff4..91458d8 100644 --- a/fw/fe310/eos/eve/eve.c +++ b/fw/fe310/eos/eve/eve.c @@ -1,7 +1,6 @@ #include <stdlib.h> #include <stdarg.h> -#include "power.h" #include "eve.h" #define EVE_MEM_WRITE 0x800000 diff --git a/fw/fe310/eos/eve/eve_eos.c b/fw/fe310/eos/eve/eve_eos.c index 35c237e..283aa6a 100644 --- a/fw/fe310/eos/eve/eve_eos.c +++ b/fw/fe310/eos/eve/eve_eos.c @@ -5,7 +5,7 @@ #include "eos.h" #include "interrupt.h" #include "event.h" -#include "power.h" +#include "pwr.h" #include "board.h" @@ -38,16 +38,41 @@ static void handle_intr(void) { eos_evtq_push_isr(EOS_EVT_UI | EVE_ETYPE_INTR, NULL, 0); } + +static void _start(void) { + 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_stop(); +} + int eos_eve_init(uint8_t wakeup_cause, uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) { int rst = (wakeup_cause == EOS_PWR_WAKE_RST); - int rv; + int rv = EVE_OK; + eve_spi_start(); if (rst) { rv = eve_init(gpio_dir, touch_calibrate, touch_matrix); - if (rv) return EOS_ERR; } else { eve_active(); } + eve_spi_stop(); + + if (rv) return EOS_ERR; eos_evtq_set_handler(EOS_EVT_UI, handle_evt); eos_timer_set_handler(EOS_TIMER_ETYPE_UI, handle_time); @@ -58,31 +83,22 @@ int eos_eve_init(uint8_t wakeup_cause, uint8_t gpio_dir, int touch_calibrate, ui } int eos_eve_run(uint8_t wakeup_cause) { - eos_eve_start(); + eve_spi_start(); + _start(); eve_start_clk(); + eve_spi_stop(); return EOS_OK; } void eos_eve_start(void) { - eve_start(); - - GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INTR); - GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << EVE_PIN_INTR); - GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << EVE_PIN_INTR); - GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << EVE_PIN_INTR); - - GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR); - - eos_intr_enable(INT_GPIO_BASE + EVE_PIN_INTR); - _run = 1; + eve_spi_start(); + _start(); + eve_spi_stop(); } void eos_eve_stop(void) { - _run = 0; - eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR); - - GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR); - - eve_stop(); + eve_spi_start(); + _stop(); + eve_spi_stop(); }
\ No newline at end of file diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c index 4f8a543..7c06f81 100644 --- a/fw/fe310/eos/eve/eve_touch.c +++ b/fw/fe310/eos/eve/eve_touch.c @@ -2,7 +2,6 @@ #include <string.h> #include <math.h> -#include "power.h" #include "eve.h" static int touch_multi; |