aboutsummaryrefslogtreecommitdiff
path: root/common/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/debug.h')
-rw-r--r--common/debug.h63
1 files changed, 9 insertions, 54 deletions
diff --git a/common/debug.h b/common/debug.h
index cac682703..8aaa5ed91 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -18,14 +18,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18#ifndef DEBUG_H 18#ifndef DEBUG_H
19#define DEBUG_H 1 19#define DEBUG_H 1
20 20
21#include <stdbool.h>
22#include "print.h" 21#include "print.h"
22#include "debug_config.h"
23 23
24 24
25#ifndef NO_DEBUG 25#ifndef NO_DEBUG
26 26
27#define dprint(s) do { if (debug_enable) print(s); } while (0)
28#define dprintln() do { if (debug_enable) print_crlf(); } while (0)
29#define dprintf(fmt, ...) do { if (debug_enable) __xprintf(PSTR(fmt), ##__VA_ARGS__); } while (0)
30#define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s))
31
32/* DO NOT USE these anymore */
27#define debug(s) do { if (debug_enable) print(s); } while (0) 33#define debug(s) do { if (debug_enable) print(s); } while (0)
28#define debugln(s) do { if (debug_enable) println(s); } while (0) 34#define debugln(s) do { if (debug_enable) print_crlf(); } while (0)
29#define debug_S(s) do { if (debug_enable) print_S(s); } while (0) 35#define debug_S(s) do { if (debug_enable) print_S(s); } while (0)
30#define debug_P(s) do { if (debug_enable) print_P(s); } while (0) 36#define debug_P(s) do { if (debug_enable) print_P(s); } while (0)
31#define debug_msg(s) do { \ 37#define debug_msg(s) do { \
@@ -50,58 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
50#define debug_bin_reverse(data) debug_bin8(data) 56#define debug_bin_reverse(data) debug_bin8(data)
51 57
52#else 58#else
53 59#include "nodebug.h"
54#define debug(s)
55#define debugln(s)
56#define debug_S(s)
57#define debug_P(s)
58#define debug_msg(s)
59#define debug_dec(data)
60#define debug_decs(data)
61#define debug_hex4(data)
62#define debug_hex8(data)
63#define debug_hex16(data)
64#define debug_hex32(data)
65#define debug_bin8(data)
66#define debug_bin16(data)
67#define debug_bin32(data)
68#define debug_bin_reverse8(data)
69#define debug_bin_reverse16(data)
70#define debug_bin_reverse32(data)
71#define debug_hex(data)
72#define debug_bin(data)
73#define debug_bin_reverse(data)
74
75#endif
76
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82
83/* NOTE: Not portable. Bit field order depends on implementation */
84typedef union {
85 uint8_t raw;
86 struct {
87 bool enable:1;
88 bool matrix:1;
89 bool keyboard:1;
90 bool mouse:1;
91 uint8_t reserved:4;
92 };
93} debug_config_t;
94debug_config_t debug_config;
95
96/* for backward compatibility */
97#define debug_enable (debug_config.enable)
98#define debug_matrix (debug_config.matrix)
99#define debug_keyboard (debug_config.keyboard)
100#define debug_mouse (debug_config.mouse)
101
102
103#ifdef __cplusplus
104}
105#endif 60#endif
106 61
107#endif 62#endif