]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/debug.h
Merge tag 'fatfs-0.10b'
[z180-stamp.git] / avr / debug.h
index 39ae55cd92f09e8a5c9d8a84ae6d40307a56b453..1815166195761d684eab5b1917308c1d10f2649d 100644 (file)
@@ -2,10 +2,33 @@
 #ifndef DEBUG_H_
 #define DEBUG_H_
 
+#include "common.h"
+#include <avr/pgmspace.h>
+
 #ifdef DEBUG
-#define DBG_P(lvl, ...) if (DEBUG>=lvl) fprintf_P( stderr,  __VA_ARGS__ )
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
+
+#define debug_cond(cond, fmt, args...)         \
+       do {                                    \
+               if (cond)                       \
+                       printf_P(PSTR(fmt), ##args);    \
+       } while (0)
+
+#define debug(fmt, args...)                    \
+       debug_cond(_DEBUG, fmt, ##args)
+
+
+#if 1
+#ifdef DEBUG
+#define DBG_P(lvl, format, ...) if (DEBUG>=lvl) \
+                               fprintf_P( stdout, PSTR(format), ##__VA_ARGS__ )
 #else
 #define DBG_P(lvl, ...)
 #endif
+#endif /* 0 */
 
 #endif /* DEBUG_H_ */
+