-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.c
27 lines (24 loc) · 812 Bytes
/
debug.c
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
#include "debug.h"
/**
* @brief Display the contents of an array
* @param[in] stream Pointer to a FILE object that identifies an output stream
* @param[in] prepend String to prepend to the left of each line
* @param[in] data Pointer to the data array
* @param[in] length Number of bytes to display
**/
void debugDisplayArray(FILE *stream,
const char_t *prepend, const void *data, size_t length)
{
uint_t i;
for(i = 0; i < length; i++)
{
//Beginning of a new line?
if((i % 16) == 0)
fprintf(stream, "%s", prepend);
//Display current data byte
fprintf(stream, "%02" PRIX8 " ", *((uint8_t *) data + i));
//End of current line?
if((i % 16) == 15 || i == (length - 1))
fprintf(stream, "\r\n");
}
}