From 6a4c8a1f11f6a7bd57b0fd618f455bcdecbfe538 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 28 Feb 2021 18:38:37 +0100 Subject: net send will do selected spi dev pause/resume if more is set and netowk is not active --- fw/fe310/eos/app/root.c | 12 +++++++++--- fw/fe310/eos/app/root.h | 3 ++- fw/fe310/eos/eos.c | 4 ++-- fw/fe310/eos/eve/eve.c | 4 ++++ fw/fe310/eos/eve/eve_platform.c | 12 ++++++++---- fw/fe310/eos/eve/eve_platform.h | 17 +++++++++++------ fw/fe310/eos/eve/eve_touch.c | 11 ++++++++++- fw/fe310/eos/net.c | 33 ++++++++++++++++++++++++++------- fw/fe310/eos/power.c | 4 ++-- fw/fe310/eos/spi.c | 22 ++++++++++++++++++++-- fw/fe310/eos/spi.h | 7 +++++-- fw/fe310/eos/spi_dev.c | 32 +++++++++++++++++++++++++------- fw/fe310/eos/spi_dev.h | 4 ++-- 13 files changed, 126 insertions(+), 39 deletions(-) (limited to 'fw/fe310/eos') diff --git a/fw/fe310/eos/app/root.c b/fw/fe310/eos/app/root.c index a86b291..43bab11 100644 --- a/fw/fe310/eos/app/root.c +++ b/fw/fe310/eos/app/root.c @@ -46,11 +46,11 @@ static uint8_t kbd_draw(EVEView *v, uint8_t tag0) { return tag0; } -void app_root_init(eve_view_constructor_t home_page) { +void app_screen_init(eve_view_constructor_t home_page) { EVERect g; _app_font_default = &font; - eos_spi_dev_start(EOS_DEV_DISP); + eve_spi_start(); eve_brightness(0x40); @@ -86,11 +86,17 @@ void app_root_init(eve_view_constructor_t home_page) { eve_screen_hide_kbd(&screen); eve_screen_draw(&screen); - eos_spi_dev_stop(); + eve_spi_stop(); eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); } +void app_screen_refresh(void) { + eve_spi_start(); + eve_screen_draw(app_screen()); + eve_spi_stop(); +} + static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { int i; diff --git a/fw/fe310/eos/app/root.h b/fw/fe310/eos/app/root.h index 2b6fc63..69624e7 100644 --- a/fw/fe310/eos/app/root.h +++ b/fw/fe310/eos/app/root.h @@ -22,7 +22,8 @@ typedef struct APPWidgetSpec { } APPWidgetSpec; EVEScreen *app_screen(void); -void app_root_init(eve_view_constructor_t home_page); +void app_screen_init(eve_view_constructor_t home_page); +void app_screen_refresh(void); EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor); void app_form_destroy(EVEForm *form); diff --git a/fw/fe310/eos/eos.c b/fw/fe310/eos/eos.c index b02abed..6214203 100644 --- a/fw/fe310/eos/eos.c +++ b/fw/fe310/eos/eos.c @@ -37,7 +37,7 @@ void eos_init(void) { eos_net_wake(wakeup_cause); eve_set_touch_calibration(eve_touch); - eos_spi_dev_start(EOS_DEV_DISP); + eos_spi_dev_select(EOS_DEV_DISP); eve_init(wakeup_cause == EOS_PWR_WAKE_RST); - eos_spi_dev_stop(); + eos_spi_dev_deselect(); } diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c index 6b3943e..f35ccf7 100644 --- a/fw/fe310/eos/eve/eve.c +++ b/fw/fe310/eos/eve/eve.c @@ -103,6 +103,7 @@ void eve_dl_start(uint32_t addr, char burst) { _dl_addr = addr; _dl_burst = burst; if (burst) { + eve_spi_lock(); eve_spi_cs_set(); eve_spi_xchg24(addr | EVE_MEM_WRITE, EVE_SPI_FLAG_TX); } @@ -121,6 +122,7 @@ void eve_dl_end(void) { if (_dl_burst) { eve_spi_flush(); eve_spi_cs_clear(); + eve_spi_unlock(); _dl_burst = 0; } } @@ -266,6 +268,7 @@ int eve_cmd_exec(int w) { void eve_cmd_burst_start(void) { uint32_t addr = EVE_RAM_CMD + _cmd_offset; + eve_spi_lock(); eve_spi_cs_set(); eve_spi_xchg24(addr | EVE_MEM_WRITE, EVE_SPI_FLAG_TX); _cmd_burst = 1; @@ -274,6 +277,7 @@ void eve_cmd_burst_start(void) { void eve_cmd_burst_end(void) { eve_spi_flush(); eve_spi_cs_clear(); + eve_spi_unlock(); _cmd_burst = 0; } diff --git a/fw/fe310/eos/eve/eve_platform.c b/fw/fe310/eos/eve/eve_platform.c index 7f1b775..cfaf6d5 100644 --- a/fw/fe310/eos/eve/eve_platform.c +++ b/fw/fe310/eos/eve/eve_platform.c @@ -11,15 +11,11 @@ #include "irq_def.h" static void handle_time(unsigned char type) { - eos_spi_dev_start(EOS_DEV_DISP); eve_handle_time(); - eos_spi_dev_stop(); } static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) { - eos_spi_dev_start(EOS_DEV_DISP); eve_handle_touch(); - eos_spi_dev_stop(); GPIO_REG(GPIO_LOW_IP) = (1 << EVE_PIN_INTR); GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR); @@ -62,6 +58,14 @@ void eve_platform_init(void) { eos_spi_dev_set_div(EOS_DEV_DISP, 4); } +void eve_spi_start(void) { + eos_spi_dev_select(EOS_DEV_DISP); +} + +void eve_spi_stop(void) { + eos_spi_dev_deselect(); +} + #include void *eve_malloc(size_t size) { diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h index 7d085db..48ea00b 100644 --- a/fw/fe310/eos/eve/eve_platform.h +++ b/fw/fe310/eos/eve/eve_platform.h @@ -11,6 +11,15 @@ #define EVE_SPI_FLAG_BSWAP EOS_SPI_FLAG_BSWAP #define EVE_SPI_FLAG_TX EOS_SPI_FLAG_TX +void *eve_malloc(size_t); +void eve_free(void *); + +//#define eve_malloc malloc +//#define eve_free free + +void eve_spi_start(void); +void eve_spi_stop(void); + #define eve_spi_cs_set eos_spi_cs_set #define eve_spi_cs_clear eos_spi_cs_clear #define eve_spi_flush eos_spi_flush @@ -18,6 +27,8 @@ #define eve_spi_xchg16 eos_spi_xchg16 #define eve_spi_xchg24 eos_spi_xchg24 #define eve_spi_xchg32 eos_spi_xchg32 +#define eve_spi_lock eos_spi_lock +#define eve_spi_unlock eos_spi_unlock void eve_time_sleep(uint32_t ms); void eve_timer_set(uint32_t ms); @@ -25,9 +36,3 @@ void eve_timer_clear(void); uint64_t eve_time_get_tick(void); void eve_platform_init(void); - -//#define eve_malloc malloc -//#define eve_free free - -void *eve_malloc(size_t); -void eve_free(void *); \ 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 e3dae58..fff1eec 100644 --- a/fw/fe310/eos/eve/eve_touch.c +++ b/fw/fe310/eos/eve/eve_touch.c @@ -69,8 +69,11 @@ void eve_handle_touch(void) { char int_ccomplete = 0; uint8_t tag0 = _tag0; uint8_t touch_last = 0; - uint8_t flags = eve_read8(REG_INT_FLAGS) & _intr_mask; + uint8_t flags; + eve_spi_start(); + + flags = eve_read8(REG_INT_FLAGS) & _intr_mask; if (!_multitouch && (flags & EVE_INT_TOUCH)) _multitouch = 1; for (i=0; i