blob: 83f02ea34b5f1d2310c86869549605488bfbb932 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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();
}
|