summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-17 07:03:13 +0200
committertmk <nobody@nowhere>2014-07-30 07:07:43 +0200
commitee70fe59ee8ebc6dcbf55171b1a2dd72e1744ae6 (patch)
tree29e08175246a736aaf7195d0612325278bc92f81 /common
parentc67ae2a6b546c822759352586c14cd9dccbbe0ff (diff)
downloadqmk_firmware-ee70fe59ee8ebc6dcbf55171b1a2dd72e1744ae6.tar.gz
qmk_firmware-ee70fe59ee8ebc6dcbf55171b1a2dd72e1744ae6.tar.xz
Fix debug.h and remove debug_config.h
Diffstat (limited to 'common')
-rw-r--r--common/debug.h112
-rw-r--r--common/debug_config.h52
-rw-r--r--common/nodebug.h28
3 files changed, 87 insertions, 105 deletions
diff --git a/common/debug.h b/common/debug.h
index 8ca2569a4..26472c8fa 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -19,44 +19,100 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEBUG_H 1
#include "print.h"
-#include "debug_config.h"
+/*
+ * Debug output control
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef union {
+ uint8_t raw;
+ struct {
+ bool enable:1;
+ bool matrix:1;
+ bool keyboard:1;
+ bool mouse:1;
+ uint8_t reserved:4;
+ };
+} debug_config_t;
+
+extern debug_config_t debug_config;
+debug_config_t debug_config __attribute__ ((weak)) = {};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define debug_enable (debug_config.enable)
+#define debug_matrix (debug_config.matrix)
+#define debug_keyboard (debug_config.keyboard)
+#define debug_mouse (debug_config.mouse)
+
+
+
+/*
+ * Debug print utils
+ */
#ifndef NO_DEBUG
-#define dprint(s) do { if (debug_enable) print(s); } while (0)
-#define dprintln(s) do { if (debug_enable) println(s); } while (0)
-#define dprintf(fmt, ...) do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0)
-#define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s))
-
-/* DO NOT USE these anymore */
-#define debug(s) do { if (debug_enable) print(s); } while (0)
-#define debugln(s) do { if (debug_enable) println(s); } while (0)
-#define debug_S(s) do { if (debug_enable) print_S(s); } while (0)
-#define debug_P(s) do { if (debug_enable) print_P(s); } while (0)
-#define debug_msg(s) do { \
+#define dprint(s) do { if (debug_enable) print(s); } while (0)
+#define dprintln(s) do { if (debug_enable) println(s); } while (0)
+#define dprintf(fmt, ...) do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0)
+#define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s))
+
+/* Deprecated. DO NOT USE these anymore, use dprintf instead. */
+#define debug(s) do { if (debug_enable) print(s); } while (0)
+#define debugln(s) do { if (debug_enable) println(s); } while (0)
+#define debug_msg(s) do { \
if (debug_enable) { \
print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \
} \
} while (0)
-#define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0)
-#define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0)
-#define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0)
-#define debug_hex8(data) do { if (debug_enable) print_hex8(data); } while (0)
-#define debug_hex16(data) do { if (debug_enable) print_hex16(data); } while (0)
-#define debug_hex32(data) do { if (debug_enable) print_hex32(data); } while (0)
-#define debug_bin8(data) do { if (debug_enable) print_bin8(data); } while (0)
-#define debug_bin16(data) do { if (debug_enable) print_bin16(data); } while (0)
-#define debug_bin32(data) do { if (debug_enable) print_bin32(data); } while (0)
-#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0)
-#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0)
-#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)
-#define debug_hex(data) debug_hex8(data)
-#define debug_bin(data) debug_bin8(data)
-#define debug_bin_reverse(data) debug_bin8(data)
+#define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0)
+#define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0)
+#define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0)
+#define debug_hex8(data) do { if (debug_enable) print_hex8(data); } while (0)
+#define debug_hex16(data) do { if (debug_enable) print_hex16(data); } while (0)
+#define debug_hex32(data) do { if (debug_enable) print_hex32(data); } while (0)
+#define debug_bin8(data) do { if (debug_enable) print_bin8(data); } while (0)
+#define debug_bin16(data) do { if (debug_enable) print_bin16(data); } while (0)
+#define debug_bin32(data) do { if (debug_enable) print_bin32(data); } while (0)
+#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0)
+#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0)
+#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)
+#define debug_hex(data) debug_hex8(data)
+#define debug_bin(data) debug_bin8(data)
+#define debug_bin_reverse(data) debug_bin8(data)
#else
-#include "nodebug.h"
+
+/* NO_DEBUG */
+#define dprint(s)
+#define dprintln(s)
+#define dprintf(fmt, ...)
+#define dmsg(s)
+#define debug(s)
+#define debugln(s)
+#define debug_msg(s)
+#define debug_dec(data)
+#define debug_decs(data)
+#define debug_hex4(data)
+#define debug_hex8(data)
+#define debug_hex16(data)
+#define debug_hex32(data)
+#define debug_bin8(data)
+#define debug_bin16(data)
+#define debug_bin32(data)
+#define debug_bin_reverse8(data)
+#define debug_bin_reverse16(data)
+#define debug_bin_reverse32(data)
+#define debug_hex(data)
+#define debug_bin(data)
+#define debug_bin_reverse(data)
+
#endif
#endif
diff --git a/common/debug_config.h b/common/debug_config.h
deleted file mode 100644
index 0e67ee49f..000000000
--- a/common/debug_config.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-Copyright 2013 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef DEBUG_CONFIG_H
-#define DEBUG_CONFIG_H 1
-
-#include <stdbool.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* NOTE: Not portable. Bit field order depends on implementation */
-typedef union {
- uint8_t raw;
- struct {
- bool enable:1;
- bool matrix:1;
- bool keyboard:1;
- bool mouse:1;
- uint8_t reserved:4;
- };
-} debug_config_t;
-debug_config_t debug_config;
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* for backward compatibility */
-#define debug_enable (debug_config.enable)
-#define debug_matrix (debug_config.matrix)
-#define debug_keyboard (debug_config.keyboard)
-#define debug_mouse (debug_config.mouse)
-
-#endif
diff --git a/common/nodebug.h b/common/nodebug.h
index 8ef123f9f..93309ada4 100644
--- a/common/nodebug.h
+++ b/common/nodebug.h
@@ -18,30 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NODEBUG_H
#define NODEBUG_H 1
-#define dprint(s)
-#define dprintln(s)
-#define dprintf(fmt, ...)
-#define dmsg(s)
-
-#define debug(s)
-#define debugln(s)
-#define debug_S(s)
-#define debug_P(s)
-#define debug_msg(s)
-#define debug_dec(data)
-#define debug_decs(data)
-#define debug_hex4(data)
-#define debug_hex8(data)
-#define debug_hex16(data)
-#define debug_hex32(data)
-#define debug_bin8(data)
-#define debug_bin16(data)
-#define debug_bin32(data)
-#define debug_bin_reverse8(data)
-#define debug_bin_reverse16(data)
-#define debug_bin_reverse32(data)
-#define debug_hex(data)
-#define debug_bin(data)
-#define debug_bin_reverse(data)
+#define NO_DEBUG
+#include "debug.h"
+#undef NO_DEBUG
#endif