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 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 30 deletions(-) (limited to 'fw/fe310/eos/eve/eve.c') 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(); } -- cgit v1.2.3