Skip to content

Commit

Permalink
tests/periph_flashpage: use od_hex_dump for memdump
Browse files Browse the repository at this point in the history
Replaces the custom `memdump` implementation with `od_hex_dump`, which provides a more common and especially more compact print format.
  • Loading branch information
gschorcht committed Jan 7, 2023
1 parent 7acb8e1 commit 65633a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
1 change: 1 addition & 0 deletions tests/periph_flashpage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FEATURES_OPTIONAL += periph_flashpage_pagewise
FEATURES_OPTIONAL += periph_flashpage_rwee

USEMODULE += od
USEMODULE += od_string
USEMODULE += shell

# avoid running Kconfig by default
Expand Down
1 change: 1 addition & 0 deletions tests/periph_flashpage/app.config.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# this file enables modules defined in Kconfig. Do not use this file for
# application configuration. This is only needed during migration.
CONFIG_MODULE_OD=y
CONFIG_MODULE_OD_STRING=y
CONFIG_MODULE_PERIPH_FLASHPAGE=y
CONFIG_MODULE_SHELL=y
24 changes: 1 addition & 23 deletions tests/periph_flashpage/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,9 @@ static int getpage(const char *str)
}

#ifdef MODULE_PERIPH_FLASHPAGE_PAGEWISE
static void dumpchar(uint8_t mem)
{
if (mem >= ' ' && mem <= '~') {
printf(" %c ", mem);
}
else {
printf(" ?? ");
}
}

static void memdump(void *addr, size_t len)
{
unsigned pos = 0;
uint8_t *mem = (uint8_t *)addr;

while (pos < (unsigned)len) {
for (unsigned i = 0; i < LINE_LEN; i++) {
printf("0x%02x ", mem[pos + i]);
}
puts("");
for (unsigned i = 0; i < LINE_LEN; i++) {
dumpchar(mem[pos++]);
}
puts("");
}
od_hex_dump (addr, len, LINE_LEN);
}

static void dump_local(void)
Expand Down

0 comments on commit 65633a2

Please sign in to comment.