From 9abfd6d27a5bbef23e84aa70814c26682eb147f6 Mon Sep 17 00:00:00 2001 From: barthess Date: Fri, 28 Oct 2016 14:25:56 +0300 Subject: Added debug printf macros --- os/various/dbgtrace.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 os/various/dbgtrace.h (limited to 'os/various/dbgtrace.h') diff --git a/os/various/dbgtrace.h b/os/various/dbgtrace.h new file mode 100644 index 0000000..b1fc297 --- /dev/null +++ b/os/various/dbgtrace.h @@ -0,0 +1,41 @@ +#ifndef DBGTRACE_H_ +#define DBGTRACE_H_ + +#include "chprintf.h" + +#if !defined(DEBUG_TRACE_PRINT) +#define DEBUG_TRACE_PRINT FALSE +#endif + +#if !defined(DEBUG_TRACE_WARNING) +#define DEBUG_TRACE_WARNING FALSE +#endif + +#if !defined(DEBUG_TRACE_ERROR) +#define DEBUG_TRACE_ERROR FALSE +#endif + +/* user must provide correctly initialized pointer to print channel */ +#if DEBUG_TRACE_PRINT || DEBUG_TRACE_WARNING || DEBUG_TRACE_ERROR +extern BaseSequentialStream *GlobalDebugChannel; +#endif + +#if DEBUG_TRACE_PRINT +#define dbgprintf(fmt, ...) chprintf(GlobalDebugChannel, fmt, ##__VA_ARGS__) +#else +#define dbgprintf(fmt, ...) do {} while(0) +#endif + +#if DEBUG_TRACE_WARNING +#define warnprintf(fmt, ...) chprintf(GlobalDebugChannel, fmt, ##__VA_ARGS__) +#else +#define warnprintf(fmt, ...) do {} while(0) +#endif + +#if DEBUG_TRACE_ERROR +#define errprintf(fmt, ...) chprintf(GlobalDebugChannel, fmt, ##__VA_ARGS__) +#else +#define errprintf(fmt, ...) do {} while(0) +#endif + +#endif /* DBGTRACE_H_ */ -- cgit v1.2.3