mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Remove flash_read_bulk(), refactor website and execute_config().
flash_read_bulk() is kind of a printf function. But did not work as well. flash_read_bulk() was used in the http generation so this needed to be changed as well. For the website we decided that we are going to use CSR(Client Side Rendering). So every HTML and JS files are now static. Variables are fetched via json calls and output is render on the client side. Also usefull for the future when we want a REST like API. execute_config() was also using flash_read_bulk(). This have been replaced with flash_read_bulk() and parsing the flash_buf buffer.
This commit is contained in:
+38
-18
@@ -628,24 +628,44 @@ void cmd_parser(void) __banked
|
||||
}
|
||||
}
|
||||
|
||||
#define FLASH_READ_BURST_SIZE 0x100;
|
||||
void execute_config(void) __banked
|
||||
{
|
||||
__xdata uint32_t pos = CONFIG_START;
|
||||
__xdata uint16_t len_left = CONFIG_LEN;
|
||||
do {
|
||||
flash_addr = pos;
|
||||
flash_find_mark("\n", len_left);
|
||||
if (mpos != 0xffff) {
|
||||
__xdata uint16_t len = len_left - mpos;
|
||||
flash_addr = pos;
|
||||
flash_read_bulk(&cmd_buffer[0], len > SBUF_SIZE ? SBUF_SIZE : len);
|
||||
cmd_buffer[len > SBUF_SIZE ? SBUF_SIZE : len] = '\0';
|
||||
len++;
|
||||
pos += len;
|
||||
len_left -= len;
|
||||
if (len && !cmd_tokenize())
|
||||
cmd_parser();
|
||||
}
|
||||
} while (mpos != 0xffff);
|
||||
}
|
||||
memcpyc(flash_buf, "test", 5);
|
||||
print_string_x(flash_buf);
|
||||
|
||||
__xdata uint32_t pos = CONFIG_START;
|
||||
__xdata uint16_t len_left = CONFIG_LEN;
|
||||
do {
|
||||
flash_region.addr = pos;
|
||||
flash_region.len = FLASH_READ_BURST_SIZE;
|
||||
write_char('-'); print_long(flash_region.addr); write_char(':'); print_short(flash_region.len); write_char('\n');
|
||||
|
||||
flash_read_bulk(flash_buf);
|
||||
|
||||
uint8_t cfg_idx = 0;
|
||||
uint8_t c = 0;
|
||||
do {
|
||||
for (uint8_t cmd_idx = 0; cmd_idx < (SBUF_SIZE - 1); cmd_idx++) {
|
||||
c = flash_buf[cfg_idx++];
|
||||
print_byte(c);
|
||||
|
||||
if (c == 0 || c == '\n') {
|
||||
cmd_buffer[cmd_idx] = '\0';
|
||||
write_char('\n'); write_char('#'); print_short(cfg_idx); write_char('-'); print_short(cmd_idx); write_char('-'); print_string_x(cmd_buffer); write_char('\n');
|
||||
if (cmd_idx && !cmd_tokenize())
|
||||
cmd_parser();
|
||||
if (c == 0)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd_buffer[cmd_idx] = c;
|
||||
}
|
||||
write_char('N');
|
||||
} while(cfg_idx);
|
||||
|
||||
len_left -= FLASH_READ_BURST_SIZE;
|
||||
pos += FLASH_READ_BURST_SIZE;
|
||||
} while(len_left);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user