From 91ff7f239fc60052f141d8ca98751c610b6b18db Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Mon, 10 May 2021 16:45:27 +0200 Subject: added support for eve cmd loadimage and similar --- fw/fe310/eos/eve/eve.c | 74 ++++++++++++++++++++++++---------------- fw/fe310/eos/eve/eve.h | 6 ++-- fw/fe310/eos/eve/screen/page.c | 1 - fw/fe310/eos/eve/screen/window.c | 10 ++++-- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c index fb5aa28..0423bb9 100644 --- a/fw/fe310/eos/eve/eve.c +++ b/fw/fe310/eos/eve/eve.c @@ -5,6 +5,7 @@ #include "eve.h" #define EVE_MEM_WRITE 0x800000 +#define EVE_SPI_FLAGS(b) ( (b) ? (EVE_SPI_FLAG_TX | EVE_SPI_FLAG_BSWAP) : EVE_SPI_FLAG_BSWAP ) static char cmd_burst; static uint16_t cmd_offset; @@ -73,24 +74,24 @@ void eve_write32(uint32_t addr, uint32_t data) { eve_spi_cs_clear(); } -void eve_readb(uint32_t addr, uint8_t *b, size_t size) { +void eve_readb(uint32_t addr, uint8_t *buf, size_t size) { int i; eve_spi_cs_set(); eve_spi_xchg32(addr << 8, 0); for (i=0; i 0) { + eve_spi_xchg8(0, flags); + i--; + } + } +} + void eve_cmd(uint32_t cmd, const char *fmt, ...) { - uint8_t flags = cmd_burst ? (EVE_SPI_FLAG_TX | EVE_SPI_FLAG_BSWAP) : EVE_SPI_FLAG_BSWAP; + uint8_t flags = EVE_SPI_FLAGS(cmd_burst); va_list argv; uint16_t *p; int i = 0; + int cont = 0; va_start(argv, fmt); - cmd_begin(cmd); + cmd_begin(cmd, flags); while (fmt[i]) { switch (fmt[i]) { case 'b': @@ -213,21 +225,23 @@ void eve_cmd(uint32_t cmd, const char *fmt, ...) { case 'p': cmd_buffer(va_arg(argv, const char *), va_arg(argv, int), flags); break; + case '+': + cont = 1; + break; } + if (cont) break; i++; } va_end(argv); - /* padding */ - i = cmd_offset & 3; /* equivalent to cmd_offset % 4 */ - if (i) { - i = 4 - i; /* 3, 2 or 1 */ - cmd_inc(i); + if (!cont) eve_cmd_end(); +} - while (i > 0) { - eve_spi_xchg8(0, flags); - i--; - } - } +void eve_cmd_write(uint8_t *buffer, size_t size) { + cmd_buffer(buffer, size, EVE_SPI_FLAGS(cmd_burst)); +} + +void eve_cmd_end(void) { + cmd_padding(EVE_SPI_FLAGS(cmd_burst)); cmd_end(); } @@ -236,7 +250,7 @@ uint32_t eve_cmd_result(uint16_t offset) { } void eve_cmd_dl(uint32_t dl) { - cmd_begin(dl); + cmd_begin(dl, EVE_SPI_FLAGS(cmd_burst)); cmd_end(); } diff --git a/fw/fe310/eos/eve/eve.h b/fw/fe310/eos/eve/eve.h index b2c1141..39e96cb 100644 --- a/fw/fe310/eos/eve/eve.h +++ b/fw/fe310/eos/eve/eve.h @@ -37,8 +37,8 @@ void eve_write8(uint32_t addr, uint8_t data); void eve_write16(uint32_t addr, uint16_t data); void eve_write32(uint32_t addr, uint32_t data); -void eve_readb(uint32_t addr, uint8_t *b, size_t size); -void eve_writeb(uint32_t addr, uint8_t *b, size_t size); +void eve_readb(uint32_t addr, uint8_t *buf, size_t size); +void eve_writeb(uint32_t addr, uint8_t *buf, size_t size); void eve_dl_start(uint32_t addr, char burst); void eve_dl_write(uint32_t dl); @@ -47,6 +47,8 @@ void eve_dl_swap(void); uint32_t eve_dl_get_addr(void); void eve_cmd(uint32_t cmd, const char *fmt, ...); +void eve_cmd_write(uint8_t *buffer, size_t size); +void eve_cmd_end(void); uint32_t eve_cmd_result(uint16_t offset); void eve_cmd_dl(uint32_t dl); int eve_cmd_done(void); diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c index 61af288..65dd534 100644 --- a/fw/fe310/eos/eve/screen/page.c +++ b/fw/fe310/eos/eve/screen/page.c @@ -307,7 +307,6 @@ uint8_t eve_page_draw(EVEView *view, uint8_t tag0) { } widget = eve_widget_next(widget); } - eve_cmd_dl(RESTORE_CONTEXT()); for (i=tag0; i + void eve_window_root_draw(EVEWindowRoot *root) { uint8_t tag0 = 0x80; + int rv; eve_cmd_burst_start(); - eve_cmd_dl(CMD_DLSTART); + eve_cmd_dl(CMD_DLSTART); if (root->tag0 != EVE_NOTAG) tag0 = EVE_NOTAG; eve_window_draw(&root->w, tag0); eve_cmd_dl(DISPLAY()); - eve_cmd_dl(CMD_SWAP); + eve_cmd_dl(CMD_SWAP); eve_cmd_burst_end(); - eve_cmd_exec(1); + rv = eve_cmd_exec(1); + if (rv) printf("EVE EXEC ERR\n"); } void eve_window_root_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *win) { -- cgit v1.2.3