-#ifdef DEBUG
-
-//uint8_t eeprom_read_byte (const uint8_t *__p)
-
-static void print_blanks(uint_fast8_t count)
-{
- while(count--)
- putchar(' ');
-}
-
-static uint8_t ram_read_byte(const uint8_t *p)
-{
- return *p;
-}
-
-void dump_mem(const uint8_t *startaddr, int len,
- uint8_t (*readfkt)(const uint8_t *), char *title)
-{
- uint8_t buf[16];
- uint8_t llen = 16;
- uint8_t pre = (size_t) startaddr % 16;
- const uint8_t *addr = (uint8_t *) ((size_t) startaddr & ~0x0f);
- len += pre;
- uint8_t i;
-
- if (title && *title)
- printf_P(PSTR("%s\n"),title);
-
- while (len) {
- if (len < 16)
- llen = len;
-
- for (i = pre; i < llen; i++)
- buf[i] = readfkt(addr + i);
-
- printf_P(PSTR("%04x:"), addr);
- for (i = 0; i < llen; i++) {
- if ((i % 8) == 0)
- putchar(' ');
- if (i < pre)
- printf_P(PSTR(".. "));
- else
- printf_P(PSTR("%.2x "), buf[i]);
- }
- /* fill line with whitespace for nice ASCII print */
- print_blanks(3 * (16u - i) + (16u-i)/8 + 1 + pre);
- /* Print data in ASCII characters */
- for (i = pre; i < llen; i++)
- printf_P(PSTR("%c"), isprint(buf[i]) ? buf[i] : '.');
- putchar('\n');
-
- pre = 0;
- addr += 16;
- len -= llen;
- }
-}
-
-#if 0
-void dump_ram(const uint8_t *startaddr, int len, char *title)
-{
- uint8_t llen = 16;
- uint8_t pre = (size_t) startaddr % 16;
- const uint8_t *addr = (uint8_t *) ((size_t) startaddr & ~0x0f);
- len += pre;
- uint8_t i;
-
- if (title && *title)
- printf_P(PSTR("%s\n"),title);
-
- while (len) {
- if (len < 16)
- llen = len;
-
- printf_P(PSTR(" %.4x:"), (size_t) addr);
- print_blanks(3 * pre);
- for (i = pre; i < llen; i++)
- printf_P(PSTR(" %.2x"), addr[i]);
- print_blanks(3 * (16 - i + 1) + pre);
- for (i = pre; i < llen; i++)
- printf_P(PSTR("%c"), isprint(addr[i]) ? addr[i] : '.');
- putchar('\n');
-
- pre = 0;
- addr += 16;
- len -= llen;
- }
-}
-#endif
-#if 0
-void dump_heap(void)
-{
- extern unsigned int __brkval;
-
- dump_ram((uint8_t *) __malloc_heap_start,
- __brkval - (unsigned int) __malloc_heap_start,
- "=== Heap:");
-}
-#endif
-
-#if 0
-/* TODO: combine with dump_ram() */
-void dump_eep(const uint8_t *addr, unsigned int len,
- uint8_t (*readfkt)(const uint8_t *))
-{
- uint_fast8_t i;
- uint8_t buf[16];
-
- printf_P(PSTR("eeprom dump:"));
- while (len) {
- printf_P(PSTR("\n 0x%.4x:"), (unsigned int) addr);
- for (i = 0; i<16; i++)
- buf[i] = readfkt(addr + i);
- for (i = 0; i<16; i++)
- printf_P(PSTR(" %.2x"), buf[i]);
- printf_P(PSTR(" "));
- for (i = 0; i<16; i++)
- printf_P(PSTR("%c"), isprint(buf[i]) ? buf[i] : '.');
-
- addr += 16;
- len -= len > 16 ? 16 : len;
- }
- putchar('\n');
-}
-#endif