diff options
Diffstat (limited to 'fw')
-rw-r--r-- | fw/fe310/eos/board.h | 3 | ||||
-rw-r--r-- | fw/fe310/eos/eos.c | 6 | ||||
-rw-r--r-- | fw/fe310/eos/eve/Makefile | 2 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve.c | 130 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve.h | 16 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_eos.c | 88 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_eos.h | 6 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_platform.c | 62 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_platform.h | 12 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_touch.c | 76 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_touch.h | 5 | ||||
-rw-r--r-- | fw/fe310/eos/i2c.c | 1 | ||||
-rw-r--r-- | fw/fe310/eos/net.c | 5 | ||||
-rw-r--r-- | fw/fe310/eos/spi.c | 1 | ||||
-rw-r--r-- | fw/fe310/eos/spi_dev.c | 9 |
15 files changed, 226 insertions, 196 deletions
diff --git a/fw/fe310/eos/board.h b/fw/fe310/eos/board.h index 62111a9..a695029 100644 --- a/fw/fe310/eos/board.h +++ b/fw/fe310/eos/board.h @@ -39,6 +39,9 @@ #define I2S_IDLE_CYCLES 8 +#define CTP_PIN_INT 1 +#define CTP_PIN_RST 19 + #define EVE_GPIO_DIR 0xf #define EVE_GPIO_CAM 0 diff --git a/fw/fe310/eos/eos.c b/fw/fe310/eos/eos.c index 2f1f4d3..68d299a 100644 --- a/fw/fe310/eos/eos.c +++ b/fw/fe310/eos/eos.c @@ -16,7 +16,7 @@ #include "cell.h" #include "sock.h" #include "i2c/bq25895.h" -#include "eve/eve.h" +#include "eve/eve_eos.h" #include "board.h" @@ -56,7 +56,7 @@ void eos_init(void) { if (rv) printf("BQ25895 INIT ERR:%d\n", rv); eos_spi_select(EOS_SPI_DEV_EVE); - rv = eve_init(wakeup_cause, touch_calibrate, touch_matrix, EVE_GPIO_DIR); + rv = eos_eve_init(wakeup_cause, EVE_GPIO_DIR, touch_calibrate, touch_matrix); eos_spi_deselect(); if (rv) printf("EVE INIT ERR:%d\n", rv); @@ -74,7 +74,7 @@ void eos_run(uint8_t wakeup_cause) { int rv; eos_spi_select(EOS_SPI_DEV_EVE); - rv = eve_run(wakeup_cause); + rv = eos_eve_run(wakeup_cause); eos_spi_deselect(); if (rv) printf("EVE RUN ERR:%d\n", rv); diff --git a/fw/fe310/eos/eve/Makefile b/fw/fe310/eos/eve/Makefile index e55ef7a..7a5351f 100644 --- a/fw/fe310/eos/eve/Makefile +++ b/fw/fe310/eos/eve/Makefile @@ -2,7 +2,7 @@ include ../../common.mk CFLAGS += -I.. -I../../bsp/include -obj = eve.o eve_platform.o eve_touch.o eve_phy.o eve_vtrack.o eve_font.o eve_kbd.o eve_text.o clipb.o +obj = eve.o eve_eos.o eve_platform.o eve_touch.o eve_phy.o eve_vtrack.o eve_font.o eve_kbd.o eve_text.o clipb.o %.o: %.c %.h diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c index ddfd4c0..7bb8ff4 100644 --- a/fw/fe310/eos/eve/eve.c +++ b/fw/fe310/eos/eve/eve.c @@ -303,7 +303,14 @@ void eve_cmd_burst_end(void) { cmd_burst = 0; } -static int _init(uint8_t gpio_dir) { +void eve_handle_intr(void) { + uint16_t intr_flags; + + intr_flags = eve_read16(REG_INT_FLAGS); + eve_handle_touch(intr_flags); +} + +int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) { uint8_t chipid = 0; uint8_t reset = 0x07; uint16_t timeout; @@ -359,6 +366,9 @@ static int _init(uint8_t gpio_dir) { eve_write8(REG_VOL_SOUND, 0x00); /* turn synthesizer volume off */ eve_write8(REG_VOL_PB, 0x00); /* turn recorded audio volume off */ + /* configure interrupts */ + eve_write16(REG_INT_MASK, 0); + /* write a basic display-list to get things started */ eve_dl_start(EVE_RAM_DL, 0); eve_dl_write(CLEAR_COLOR_RGB(0,0,0)); @@ -372,18 +382,35 @@ static int _init(uint8_t gpio_dir) { #endif /* nothing is being displayed yet... the pixel clock is still 0x00 */ + eve_touch_init(touch_calibrate, touch_matrix); return EVE_OK; } -static void _start(void) { +void eve_start(void) { + eve_touch_start(); + + /* enable interrupts */ + eve_write8(REG_INT_EN, 0x01); + while(eve_read8(REG_INT_FLAGS)); +} + +void eve_stop(void) { + eve_touch_stop(); + + /* disable interrupts */ + eve_write8(REG_INT_EN, 0x00); + while(eve_read8(REG_INT_FLAGS)); +} + +void eve_start_clk(void) { uint16_t gpiox; + eve_write8(REG_PCLK, EVE_PCLK); /* start clocking data to the LCD panel */ 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 */ + eve_write16(REG_GPIOX, gpiox); /* enable the DISP signal to the LCD panel, it is set to output in REG_GPIOX_DIR */ } -static void _stop(void) { +void eve_stop_clk(void) { uint16_t gpiox; gpiox = eve_read16(REG_GPIOX) & ~0x8000; @@ -391,45 +418,43 @@ static void _stop(void) { eve_write8(REG_PCLK, 0); } -int eve_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix, uint8_t gpio_dir) { - int rv; - int rst = (wakeup_cause == EVE_WAKE_RST); - - if (rst) { - int rv = _init(gpio_dir); - if (rv) return rv; - } else { - eve_command(EVE_ACTIVE, 0); - eve_time_sleep(40); - } +void eve_active(void) { + eve_command(EVE_ACTIVE, 0); + eve_time_sleep(40); +} - rv = eve_touch_init(wakeup_cause, touch_calibrate, touch_matrix); - if (rv) return rv; +void eve_standby(void) { + if (power_state != EVE_PSTATE_ACTIVE) return; - eve_platform_init(); + eve_command(EVE_STANDBY, 0); - return EVE_OK; + power_state = EVE_PSTATE_STANDBY; } -int eve_run(uint8_t wakeup_cause) { - int rv; +void eve_sleep(void) { + if (power_state != EVE_PSTATE_ACTIVE) return; - _start(); - rv = eve_touch_run(wakeup_cause); + eve_stop_clk(); + eve_stop(); - return rv; -} + eve_command(EVE_SLEEP, 0); -void eve_start(void) { - _start(); - eve_touch_start(); + power_state = EVE_PSTATE_SLEEP; } -void eve_stop(void) { - uint16_t gpiox; +void eve_wake(void) { + eve_active(); - eve_touch_stop(); - _stop(); + if (power_state == EVE_PSTATE_SLEEP) { + eve_start(); + eve_start_clk(); + } + + power_state = EVE_PSTATE_ACTIVE; +} + +void eve_brightness(uint8_t b) { + eve_write8(REG_PWM_DUTY, b); } int eve_gpio_get(int gpio) { @@ -459,42 +484,3 @@ void eve_gpio_set_dir(uint8_t dir) { reg |= dir & 0x0f; eve_write16(REG_GPIOX_DIR, reg); } - -void eve_standby(void) { - uint16_t gpiox; - - if (power_state != EVE_PSTATE_ACTIVE) return; - - eve_command(EVE_STANDBY, 0); - - power_state = EVE_PSTATE_STANDBY; -} - -void eve_sleep(void) { - uint16_t gpiox; - - if (power_state != EVE_PSTATE_ACTIVE) return; - - eve_stop(); - - eve_command(EVE_SLEEP, 0); - - power_state = EVE_PSTATE_SLEEP; -} - -void eve_active(void) { - uint16_t gpiox; - - eve_command(EVE_ACTIVE, 0); - - if (power_state == EVE_PSTATE_SLEEP) { - eve_time_sleep(40); - eve_start(); - } - - power_state = EVE_PSTATE_ACTIVE; -} - -void eve_brightness(uint8_t b) { - eve_write8(REG_PWM_DUTY, b); -} diff --git a/fw/fe310/eos/eve/eve.h b/fw/fe310/eos/eve/eve.h index ae0a672..02fa697 100644 --- a/fw/fe310/eos/eve/eve.h +++ b/fw/fe310/eos/eve/eve.h @@ -56,17 +56,21 @@ int eve_cmd_exec(int w); 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); -int eve_run(uint8_t wakeup_cause); +void eve_handle_intr(void); + +int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix); void eve_start(void); void eve_stop(void); +void eve_start_clk(void); +void eve_stop_clk(void); + +void eve_active(void); +void eve_standby(void); +void eve_sleep(void); +void eve_wake(void); int eve_gpio_get(int gpio); void eve_gpio_set(int gpio, int val); uint8_t eve_gpio_get_dir(void); void eve_gpio_set_dir(uint8_t dir); - -void eve_standby(void); -void eve_sleep(void); -void eve_active(void); void eve_brightness(uint8_t b); diff --git a/fw/fe310/eos/eve/eve_eos.c b/fw/fe310/eos/eve/eve_eos.c new file mode 100644 index 0000000..35c237e --- /dev/null +++ b/fw/fe310/eos/eve/eve_eos.c @@ -0,0 +1,88 @@ +#include <stdlib.h> + +#include "platform.h" + +#include "eos.h" +#include "interrupt.h" +#include "event.h" +#include "power.h" + +#include "board.h" + +#include "eve.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_UI | EVE_ETYPE_INTR, NULL, 0); +} + +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; + + if (rst) { + rv = eve_init(gpio_dir, touch_calibrate, touch_matrix); + if (rv) return EOS_ERR; + } else { + eve_active(); + } + + eos_evtq_set_handler(EOS_EVT_UI, handle_evt); + eos_timer_set_handler(EOS_TIMER_ETYPE_UI, handle_time); + eos_intr_set(INT_GPIO_BASE + EVE_PIN_INTR, IRQ_PRIORITY_UI, handle_intr); + eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR); + + return EOS_OK; +} + +int eos_eve_run(uint8_t wakeup_cause) { + eos_eve_start(); + eve_start_clk(); + + 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; +} + +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(); +}
\ No newline at end of file diff --git a/fw/fe310/eos/eve/eve_eos.h b/fw/fe310/eos/eve/eve_eos.h new file mode 100644 index 0000000..80eea86 --- /dev/null +++ b/fw/fe310/eos/eve/eve_eos.h @@ -0,0 +1,6 @@ +#include <stdint.h> + +int eos_eve_init(uint8_t wakeup_cause, uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix); +int eos_eve_run(uint8_t wakeup_cause); +void eos_eve_start(void); +void eos_eve_stop(void); diff --git a/fw/fe310/eos/eve/eve_platform.c b/fw/fe310/eos/eve/eve_platform.c index 2a43f1c..4450412 100644 --- a/fw/fe310/eos/eve/eve_platform.c +++ b/fw/fe310/eos/eve/eve_platform.c @@ -1,61 +1,36 @@ #include <stdlib.h> - -#include "platform.h" +#include <stdio.h> #include "eos.h" -#include "interrupt.h" -#include "event.h" - -#include "board.h" #include "eve.h" #include "eve_platform.h" - -static void handle_time(unsigned char type) { - eve_handle_time(); -} - -static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) { - eve_handle_touch(); - - GPIO_REG(GPIO_LOW_IP) = (1 << EVE_PIN_INTR); - GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR); -} - -static void handle_intr(void) { - GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR); - eos_evtq_push_isr(EOS_EVT_UI | EVE_ETYPE_INTR, NULL, 0); - return; +void *eve_malloc(size_t size) { + void *p = malloc(size); + printf("MALLOC:%p %d\n", p, size); + return p; } -void eve_time_sleep(uint32_t ms) { - eos_time_sleep(ms); +void eve_free(void *p) { + printf("FREE:%p\n", p); + free(p); } void eve_timer_set(uint32_t ms) { eos_timer_set(ms, EOS_TIMER_ETYPE_UI); } -void eve_timer_clear(void) { - eos_timer_clear(EOS_TIMER_ETYPE_UI); +void eve_time_sleep(uint32_t ms) { + eos_time_sleep(ms); } uint64_t eve_time_get_tick(void) { return eos_time_get_tick(); } -void eve_platform_init(void) { - eos_evtq_set_handler(EOS_EVT_UI, handle_evt); - eos_timer_set_handler(EOS_TIMER_ETYPE_UI, handle_time); - - 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_set(INT_GPIO_BASE + EVE_PIN_INTR, IRQ_PRIORITY_UI, handle_intr); +void eve_timer_clear(void) { + eos_timer_clear(EOS_TIMER_ETYPE_UI); } void eve_spi_start(void) { @@ -65,16 +40,3 @@ void eve_spi_start(void) { void eve_spi_stop(void) { eos_spi_deselect(); } - -#include <stdio.h> - -void *eve_malloc(size_t size) { - void *p = malloc(size); - printf("MALLOC:%p %d\n", p, size); - return p; -} - -void eve_free(void *p) { - printf("FREE:%p\n", p); - free(p); -} diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h index b33bd48..77afffc 100644 --- a/fw/fe310/eos/eve/eve_platform.h +++ b/fw/fe310/eos/eve/eve_platform.h @@ -1,9 +1,9 @@ #include <stdint.h> +#include <stdlib.h> +#include "timer.h" #include "spi.h" #include "spi_dev.h" -#include "power.h" -#include "timer.h" #define EVE_ETYPE_INTR 1 @@ -12,10 +12,6 @@ #define EVE_SPI_FLAG_BSWAP EOS_SPI_FLAG_BSWAP #define EVE_SPI_FLAG_TX EOS_SPI_FLAG_TX -#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 *); @@ -36,8 +32,6 @@ void eve_spi_stop(void); #define eve_spi_unlock eos_spi_unlock void eve_time_sleep(uint32_t ms); +uint64_t eve_time_get_tick(void); void eve_timer_set(uint32_t ms); void eve_timer_clear(void); -uint64_t eve_time_get_tick(void); - -void eve_platform_init(void); diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c index ff155d5..4f8a543 100644 --- a/fw/fe310/eos/eve/eve_touch.c +++ b/fw/fe310/eos/eve/eve_touch.c @@ -5,7 +5,6 @@ #include "power.h" #include "eve.h" -static int touch_intr_mask = EVE_INT_TAG | EVE_INT_TOUCH; static int touch_multi; static uint8_t touch_tag0; @@ -39,16 +38,15 @@ static const uint32_t _reg_track[] = { REG_TRACKER_4 }; -void eve_handle_touch(void) { +void eve_handle_touch(uint16_t intr_flags) { int i; char touch_ex = 0; char int_ccomplete = 0; - uint8_t flags; + uint16_t intr_mask; - eve_spi_start(); + intr_mask = eve_read16(REG_INT_MASK); + if (!touch_multi && (intr_flags & EVE_INT_TOUCH)) touch_multi = 1; - flags = eve_read8(REG_INT_FLAGS) & touch_intr_mask; - if (!touch_multi && (flags & EVE_INT_TOUCH)) touch_multi = 1; for (i=0; i<EVE_MAX_TOUCH; i++) { uint8_t touch_tag; uint32_t touch_xy; @@ -123,7 +121,7 @@ void eve_handle_touch(void) { } touch->x = touch_x; touch->y = touch_y; - if (touch_multi || (flags & EVE_INT_TAG)) { + if (touch_multi || (intr_flags & EVE_INT_TAG)) { touch_tag = eve_read8(_reg_tag[i]); } else { touch_tag = touch->tag; @@ -241,16 +239,12 @@ void eve_handle_touch(void) { if (touch_multi) int_ccomplete = 1; - if (int_ccomplete && !(touch_intr_mask & EVE_INT_CONVCOMPLETE)) { - touch_intr_mask |= EVE_INT_CONVCOMPLETE; - eve_write8(REG_INT_MASK, touch_intr_mask); + if (int_ccomplete && !(intr_mask & EVE_INT_CONVCOMPLETE)) { + eve_write16(REG_INT_MASK, intr_mask | EVE_INT_CONVCOMPLETE); } - if (!int_ccomplete && (touch_intr_mask & EVE_INT_CONVCOMPLETE)) { - touch_intr_mask &= ~EVE_INT_CONVCOMPLETE; - eve_write8(REG_INT_MASK, touch_intr_mask); + if (!int_ccomplete && (intr_mask & EVE_INT_CONVCOMPLETE)) { + eve_write16(REG_INT_MASK, intr_mask & ~EVE_INT_CONVCOMPLETE); } - - eve_spi_stop(); } void eve_handle_time(void) { @@ -260,8 +254,6 @@ void eve_handle_time(void) { int more = 0; uint16_t touch_evt = 0; - eve_spi_start(); - if (touch_timer.evt & EVE_TOUCH_ETYPE_LPRESS) { touch_evt |= EVE_TOUCH_ETYPE_LPRESS; if (touch) touch->eevt |= EVE_TOUCH_EETYPE_LPRESS; @@ -295,12 +287,10 @@ void eve_handle_time(void) { if (touch_handler && touch_evt) { touch_handler(touch, touch_evt, touch_timer.tag0, touch_handler_param); } - - eve_spi_stop(); } } -static void _init(int touch_calibrate, uint32_t *touch_matrix) { +void eve_touch_init(int touch_calibrate, uint32_t *touch_matrix) { /* configure touch */ eve_write8(REG_CPURESET, 2); /* touch engine reset */ eve_write16(REG_TOUCH_CONFIG, 0x4000); /* host mode multi touch */ @@ -329,49 +319,37 @@ static void _init(int touch_calibrate, uint32_t *touch_matrix) { } eve_write8(REG_CTOUCH_EXTENDED, 0x00); /* set extended mode */ - - /* configure interrupts */ - eve_write8(REG_INT_MASK, touch_intr_mask); - eve_write8(REG_INT_EN, 0x01); - while(eve_read8(REG_INT_FLAGS)); -} - -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); +void eve_touch_start(void) { + uint16_t intr_mask; int i; - eve_vtrack_init(); - + touch_multi = 0; + touch_tag0 = 0; + memset(&touch_timer, 0, sizeof(touch_timer)); for (i=0; i<EVE_MAX_TOUCH; i++) { EVETouch *touch = &touch_obj[i]; + + memset(&touch_obj[i], 0, sizeof(EVETouch)); touch->eevt |= EVE_TOUCH_EETYPE_NOTOUCH; } + eve_vtrack_init(); - if (rst) _init(touch_calibrate, touch_matrix); + intr_mask = eve_read16(REG_INT_MASK); + eve_write16(REG_INT_MASK, intr_mask | EVE_INT_TAG | EVE_INT_TOUCH); - return EVE_OK; + eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); } -int eve_touch_run(uint8_t wakeup_cause) { - _start(); - - return EVE_OK; -} +void eve_touch_stop(void) { + uint16_t intr_mask; -void eve_touch_start(void) { - _start(); -} + intr_mask = eve_read16(REG_INT_MASK); + eve_write16(REG_INT_MASK, intr_mask & ~(EVE_INT_TAG | EVE_INT_TOUCH | EVE_INT_CONVCOMPLETE)); + eve_touch_timer_clear(touch_timer.touch); -void eve_touch_stop(void) { - _stop(); + eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF); } 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 37c4013..b10fde2 100644 --- a/fw/fe310/eos/eve/eve_touch.h +++ b/fw/fe310/eos/eve/eve_touch.h @@ -98,11 +98,10 @@ typedef struct EVETouchTimer { typedef void (*eve_touch_handler_t) (EVETouch *, uint16_t, uint8_t, void *); -void eve_handle_touch(void); +void eve_handle_touch(uint16_t intr_flags); void eve_handle_time(void); -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_init(int touch_calibrate, uint32_t *touch_matrix); void eve_touch_start(void); void eve_touch_stop(void); diff --git a/fw/fe310/eos/i2c.c b/fw/fe310/eos/i2c.c index 972deae..63dd7e6 100644 --- a/fw/fe310/eos/i2c.c +++ b/fw/fe310/eos/i2c.c @@ -12,6 +12,7 @@ int eos_i2c_init(uint8_t wakeup_cause) { eos_i2c_stop(); eos_i2c_speed(EOS_I2C_SPEED); + return EOS_OK; } diff --git a/fw/fe310/eos/net.c b/fw/fe310/eos/net.c index 167a879..4d9aadf 100644 --- a/fw/fe310/eos/net.c +++ b/fw/fe310/eos/net.c @@ -311,6 +311,10 @@ static void net_start(void) { SPI1_REG(SPI_REG_CSID) = eos_spi_csid(EOS_SPI_DEV_NET); } +static void net_stop(void) { + eos_intr_set_handler(INT_SPI1_BASE, NULL); +} + int eos_net_init(uint8_t wakeup_cause) { int i; @@ -400,6 +404,7 @@ void eos_net_stop(void) { if (!done) asm volatile ("wfi"); set_csr(mstatus, MSTATUS_MIE); } + net_stop(); } int eos_net_sleep(uint32_t timeout) { diff --git a/fw/fe310/eos/spi.c b/fw/fe310/eos/spi.c index a4b164e..11a0703 100644 --- a/fw/fe310/eos/spi.c +++ b/fw/fe310/eos/spi.c @@ -102,6 +102,7 @@ void eos_spi_start(uint16_t div, uint8_t csid, uint8_t cspin, unsigned char evt) void eos_spi_stop(void) { eos_spi_flush(); + eos_intr_set_handler(INT_SPI1_BASE, NULL); spi_evt = 0; } diff --git a/fw/fe310/eos/spi_dev.c b/fw/fe310/eos/spi_dev.c index 54b337a..2d3d8f5 100644 --- a/fw/fe310/eos/spi_dev.c +++ b/fw/fe310/eos/spi_dev.c @@ -40,7 +40,6 @@ int eos_spi_dev_init(uint8_t wakeup_cause) { } int eos_spi_select(unsigned char dev) { - if (dev == EOS_SPI_DEV_NET) return EOS_ERR; if (spi_lock) return EOS_ERR_BUSY; if (spi_dev == EOS_SPI_DEV_NET) { @@ -50,14 +49,18 @@ int eos_spi_select(unsigned char dev) { } spi_dev = dev; - eos_spi_start(spi_div[dev], spi_cfg[dev].csid, spi_cfg[dev].cspin, spi_cfg[dev].evt); + if (dev == EOS_SPI_DEV_NET) { + eos_net_start(); + } else { + eos_spi_start(spi_div[dev], spi_cfg[dev].csid, spi_cfg[dev].cspin, spi_cfg[dev].evt); + } return EOS_OK; } int eos_spi_deselect(void) { - if (spi_dev == EOS_SPI_DEV_NET) return EOS_ERR; if (spi_lock) return EOS_ERR_BUSY; + if (spi_dev == EOS_SPI_DEV_NET) return EOS_ERR; eos_spi_stop(); |