diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-05-10 16:45:27 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-05-10 16:45:27 +0200 |
commit | 91ff7f239fc60052f141d8ca98751c610b6b18db (patch) | |
tree | b2d8a88d82281bb275a6df99d5944b630fd0023c /fw | |
parent | 3d5500b437c706819075c0f91cbcd981bd5a153a (diff) |
added support for eve cmd loadimage and similar
Diffstat (limited to 'fw')
-rw-r--r-- | fw/fe310/eos/eve/eve.c | 74 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve.h | 6 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/page.c | 1 | ||||
-rw-r--r-- | 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<size; i++) { - b[i] = eve_spi_xchg8(0, 0); + buf[i] = eve_spi_xchg8(0, 0); } eve_spi_cs_clear(); } -void eve_writeb(uint32_t addr, uint8_t *b, size_t size) { +void eve_writeb(uint32_t addr, uint8_t *buf, size_t size) { int i; eve_spi_cs_set(); eve_spi_xchg24(addr | EVE_MEM_WRITE, 0); for (i=0; i<size; i++) { - eve_spi_xchg8(b[i], 0); + eve_spi_xchg8(buf[i], 0); } eve_spi_cs_clear(); } @@ -111,7 +112,7 @@ void eve_dl_start(uint32_t addr, char burst) { void eve_dl_write(uint32_t dl) { if (dl_burst) { - eve_spi_xchg32(dl, EVE_SPI_FLAG_TX | EVE_SPI_FLAG_BSWAP); + eve_spi_xchg32(dl, EVE_SPI_FLAGS(dl_burst)); } else { eve_write32(dl_addr, dl); } @@ -140,17 +141,13 @@ static void cmd_inc(uint16_t i) { cmd_offset &= 0x0fff; } -static void cmd_begin(uint32_t command) { - uint8_t flags = 0; - - if (cmd_burst) { - flags = EVE_SPI_FLAG_TX; - } else { +static void cmd_begin(uint32_t command, uint8_t flags) { + if (!cmd_burst) { uint32_t addr = EVE_RAM_CMD + cmd_offset; eve_spi_cs_set(); eve_spi_xchg24(addr | EVE_MEM_WRITE, 0); } - eve_spi_xchg32(command, EVE_SPI_FLAG_BSWAP | flags); + eve_spi_xchg32(command, flags); cmd_inc(4); } @@ -158,11 +155,11 @@ static void cmd_end(void) { if (!cmd_burst) eve_spi_cs_clear(); } -static void cmd_string(const char *s, uint8_t flags) { +static void cmd_string(const char *str, uint8_t flags) { int i = 0; - while (s[i] != 0) { - eve_spi_xchg8(s[i], flags); + while (str[i] != 0) { + eve_spi_xchg8(str[i], flags); i++; } eve_spi_xchg8(0, flags); @@ -170,23 +167,38 @@ static void cmd_string(const char *s, uint8_t flags) { cmd_inc(i); } -static void cmd_buffer(const char *b, int size, uint8_t flags) { +static void cmd_buffer(const char *buf, int size, uint8_t flags) { int i = 0; for (i=0; i<size; i++) { - eve_spi_xchg8(b[i], flags); + eve_spi_xchg8(buf[i], flags); } cmd_inc(size); } +static void cmd_padding(uint8_t flags) { + int i = cmd_offset & 3; /* equivalent to cmd_offset % 4 */ + + if (i) { + i = 4 - i; /* 3, 2 or 1 */ + cmd_inc(i); + + while (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<tagN; i++) { diff --git a/fw/fe310/eos/eve/screen/window.c b/fw/fe310/eos/eve/screen/window.c index 63a59a9..d4b15f0 100644 --- a/fw/fe310/eos/eve/screen/window.c +++ b/fw/fe310/eos/eve/screen/window.c @@ -214,19 +214,23 @@ int eve_window_touch(EVEWindow *window, EVETouch *touch, uint16_t evt, uint8_t t return 0; } +#include <stdio.h> + 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) { |