X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/fc454c83abd628f03eb39800b269d25c54f9591a..8315e7f4ea0204718e520e48a48739fd0371bd28:/avr/print-utils.c diff --git a/avr/print-utils.c b/avr/print-utils.c index 050140f..83f86a9 100644 --- a/avr/print-utils.c +++ b/avr/print-utils.c @@ -1,4 +1,11 @@ +/* + * (C) Copyright 2014 Leo C. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + #include "common.h" +#include #include #include #include "con-utils.h" @@ -11,19 +18,28 @@ void print_blanks(uint_fast8_t count) } -void eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count) +int eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count) { eeprom_read_block((void *) buf, (const void *) (size_t) addr, count); + return 0; } -void ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count) +int ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count) { - while (count--) - *buf++ = *(uint8_t *) (size_t) addr++; + while (count--) + *buf++ = *(uint8_t *) (size_t) addr++; + return 0; +} + +int flash_read_buf(uint8_t *buf, uint32_t addr, uint8_t count) +{ + while (count--) + *buf++ = *(const __memx uint8_t *) (__uint24) addr++; + return 0; } int dump_mem(uint32_t address, uint32_t offset, uint32_t len, - void (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title) + int (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title) { uint8_t buf[16]; char *indent = NULL; @@ -41,7 +57,8 @@ int dump_mem(uint32_t address, uint32_t offset, uint32_t len, while (len) { if (len < 16) llen = len; - readfkt(buf, address, llen - pre); + if (readfkt(buf, address, llen - pre) != 0) + return -2; /* TODO: Error codes */ printf_P(PSTR("%s%.5lx:"),indent, offset); for (i = 0; i < llen; i++) { @@ -75,7 +92,7 @@ void dump_eep(uint32_t addr, unsigned int len, char *title) dump_mem(addr, addr, len, eeprom_read_buf, title); } -void dump_ram(uint32_t addr, uint32_t offset, unsigned int len, char *title) +void dump_ram(uint8_t *addr, size_t offset, unsigned int len, char *title) { - dump_mem(addr, offset, len, ram_read_buf, title); + dump_mem((uint32_t) (size_t) addr, offset, len, ram_read_buf, title); }