From b3c6320899d6b27899ab3c67c745e8d3b29af3a2 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Feb 2019 13:46:18 +0000 Subject: working ethernet --- app/hexdump.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/hexdump.c (limited to 'app/hexdump.c') diff --git a/app/hexdump.c b/app/hexdump.c new file mode 100644 index 0000000..83f02ea --- /dev/null +++ b/app/hexdump.c @@ -0,0 +1,57 @@ +#include "project.h" + +void +hexdump (void *_d, int len) +{ + uint8_t *d = (uint8_t *) _d; + int i, j, k; + int e; + + if (!d || len < 0) + return; + + e = len + 15; + e &= ~15; + + for (i = 0; i < e; i += 16) { + usart1_drain(); + printf (" %05x:", i); + + for (j = 0; j < 16; ++j) { + k = i + j; + + if (k < len) + printf (" %02x", d[k]); + else + printf (" "); + + if (j == 7) + printf (" "); + } + + printf (" "); + + for (j = 0; j < 16; ++j) { + k = i + j; + + if (k < len) { + uint8_t c = d[k]; + + if (c < 33) + c = '.'; + + if (c > 126) + c = '.'; + + printf ("%c", c); + } + + if (j == 7) + printf (" "); + } + + printf ("\r\n"); + } + + usart1_drain(); +} -- cgit v1.2.3