-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugPrint.h
94 lines (71 loc) · 1.76 KB
/
DebugPrint.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* File: DebugPrint.h
* Author: nikos
*
* Created on December 26, 2018, 11:52 PM
*/
#ifndef DEBUGPRINT_H
#define DEBUGPRINT_H
#include <string.h>
#include "ByteDef.h"
#include "mcc_generated_files/uart2.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DEBUG
#ifdef DEBUG //Macros
// Exceed 16 bytes at your own peril
#define DEBUG_PRINTHEX_MAX 16
#define DebugPrint(x) _debug_print_str(x) //debug print, do not need to put text in between of double quotes
#define DebugPrintHexStrLn(x, l) _debug_println_hex(x, l)
#define DebugPrintHexStr(x, l) _debug_print_hex(x, l)
#define DebugPrintLn(x) _debug_println_str(x) //debug print with new line
#define DebugPrintInt(x) _debug_print_int(x)
#define DebugPrintUInt(x) _debug_print_uint(x)
extern unsigned int last_output;
/**
* Print a null-terminated string
* @param str
*/
void _debug_print_str(char* str);
/**
* Print a null-terminated string followed by a newline
* @param str
*/
void _debug_println_str(char* str);
/**
* Print a sequence of bytes in hex form (maximum length 256)
* @param buf
* @param len
*/
void _debug_print_hex(byte* buf, size_t len);
/**
* Print a sequence of bytes in hex, followed by a newline
* @param buf
* @param len
*/
void _debug_println_hex(byte* buf, size_t len);
/**
* Print an integer
* @param x
*/
void _debug_print_int(int x);
/**
* Print an unsigned integer
* @param x
*/
void _debug_print_uint(unsigned int x);
#else // DEBUG
#define DEBUG_PRINTHEX_MAX 1
#define DebugPrint(x)
#define DebugPrintHexStrLn(x, l)
#define DebugPrintHexStr(x, l)
#define DebugPrintLn(x)
#define DebugPrintInt(x)
#define DebugPrintUInt(x)
extern unsigned int last_output;
#endif // DEBUG
#ifdef __cplusplus
}
#endif
#endif /* DEBUGPRINT_H */