]> cloudbase.mooo.com Git - z180-stamp.git/blob - avr/debug.h
1815166195761d684eab5b1917308c1d10f2649d
[z180-stamp.git] / avr / debug.h
1
2 #ifndef DEBUG_H_
3 #define DEBUG_H_
4
5 #include "common.h"
6 #include <avr/pgmspace.h>
7
8 #ifdef DEBUG
9 #define _DEBUG 1
10 #else
11 #define _DEBUG 0
12 #endif
13
14 #define debug_cond(cond, fmt, args...) \
15 do { \
16 if (cond) \
17 printf_P(PSTR(fmt), ##args); \
18 } while (0)
19
20 #define debug(fmt, args...) \
21 debug_cond(_DEBUG, fmt, ##args)
22
23
24 #if 1
25 #ifdef DEBUG
26 #define DBG_P(lvl, format, ...) if (DEBUG>=lvl) \
27 fprintf_P( stdout, PSTR(format), ##__VA_ARGS__ )
28 #else
29 #define DBG_P(lvl, ...)
30 #endif
31 #endif /* 0 */
32
33 #endif /* DEBUG_H_ */
34