From: Keith Packard Date: Sun, 24 Mar 2013 22:24:42 +0000 (-0700) Subject: altos: Switch ao_stm_flash to read/write binary blocks X-Git-Tag: 1.2.1~47 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=9362d400d06aa3badfc826d8edbd7c55406b4f7d altos: Switch ao_stm_flash to read/write binary blocks Change from development testing code to something that actually reads and writes data from the USB link. Signed-off-by: Keith Packard --- diff --git a/src/stm-flash/ao_stm_flash.c b/src/stm-flash/ao_stm_flash.c index 51856b46..344bceb9 100644 --- a/src/stm-flash/ao_stm_flash.c +++ b/src/stm-flash/ao_stm_flash.c @@ -74,11 +74,11 @@ ao_block_write(void) uint16_t i; if (addr < 0x08002000 || 0x08200000 <= addr) { - puts("Invalid address"); + ao_put_string("Invalid address\n"); return; } for (i = 0; i < 256; i++) - u.data8[i] = i; + u.data8[i] = getchar(); ao_flash_page(p, u.data32); } @@ -103,18 +103,43 @@ ao_block_read(void) for (i = 0; i < 256; i++) { c = *p++; - puthex(c); + (*ao_stdios[ao_cur_stdio].putchar)(c); + } +} + +void +ao_block_read_hex(void) +{ + uint32_t addr = ao_cmd_hex32(); + uint8_t *p = (uint8_t *) addr; + uint16_t i; + uint8_t c; + + for (i = 0; i < 256; i++) { + c = *p++; puthex(c>>4); + puthex(c); if ((i & 0xf) == 0xf) putchar('\n'); } } +static void +ao_show_version(void) +{ + puts("altos-loader"); + ao_put_string("manufacturer "); puts(ao_manufacturer); + ao_put_string("product "); puts(ao_product); + ao_put_string("software-version "); puts(ao_version); +} + __code struct ao_cmds ao_flash_cmds[] = { + { ao_show_version, "v\0Version" }, { ao_application, "a\0Switch to application" }, - { ao_block_erase, "e \0Erase block." }, + { ao_block_erase, "X \0Erase block." }, { ao_block_write, "W \0Write block. 256 binary bytes follow newline" }, - { ao_block_read, "R \0Read block. Returns 256 bytes" }, + { ao_block_read, "R \0Read block. Returns 256 binary bytes" }, + { ao_block_read_hex, "H \0Hex read block. Returns 256 bytes in hex" }, { 0, NULL }, };