summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-03-19 14:08:40 +0900
committertmk <nobody@nowhere>2013-03-19 14:08:40 +0900
commit9a106537f64fe61af6048b41262f002ce6a716d9 (patch)
tree9df736d957945b5d3377b8cb5005946acd99bd61
parent8580c8d291a432d5004c46321aa3c1b1626cdadd (diff)
downloadqmk_firmware-9a106537f64fe61af6048b41262f002ce6a716d9.tar.gz
qmk_firmware-9a106537f64fe61af6048b41262f002ce6a716d9.zip
Add NO_PRINT and NO_DEBUG config options.
- NO_PRINT: disable print.h API(also disable debug.h) - NO_DEBUG: disable debug.h API
-rw-r--r--common.mk3
-rw-r--r--common/command.c15
-rw-r--r--common/debug.h31
-rw-r--r--common/keyboard.c2
-rw-r--r--common/print.c13
-rw-r--r--common/print.h40
-rw-r--r--keyboard/gh60/config.h5
7 files changed, 77 insertions, 32 deletions
diff --git a/common.mk b/common.mk
index 4054893b44..2ce4e32da5 100644
--- a/common.mk
+++ b/common.mk
@@ -31,6 +31,9 @@ endif
ifdef CONSOLE_ENABLE
OPT_DEFS += -DCONSOLE_ENABLE
+else
+ OPT_DEFS += -DNO_PRINT
+ OPT_DEFS += -DNO_DEBUG
endif
ifdef NKRO_ENABLE
diff --git a/common/command.c b/common/command.c
index 372ca291e2..cb98e1d5f2 100644
--- a/common/command.c
+++ b/common/command.c
@@ -98,7 +98,6 @@ bool command_extra(uint8_t code)
***********************************************************/
static void command_common_help(void)
{
- print_enable = true;
print("\n\n----- Command Help -----\n");
print("c: enter console mode\n");
print("d: toggle debug enable\n");
@@ -137,7 +136,8 @@ static void print_eeprom_config(void)
eebyte = eeconfig_read_keyconf();
print("keyconf: "); print_hex8(eebyte); print("\n");
- keyconf kc = (keyconf){ .raw = eebyte };
+ keyconf kc;
+ kc = (keyconf){ .raw = eebyte };
print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n");
print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n");
print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n");
@@ -173,7 +173,6 @@ static bool command_common(uint8_t code)
command_common_help();
break;
case KC_C:
- print_enable = true;
debug_matrix = false;
debug_keyboard = false;
debug_mouse = false;
@@ -239,15 +238,6 @@ static bool command_common(uint8_t code)
case KC_T: // print timer
print_val_hex32(timer_count);
break;
- case KC_P: // print toggle
- if (print_enable) {
- print("print disabled.\n");
- print_enable = false;
- } else {
- print_enable = true;
- print("print enabled.\n");
- }
- break;
case KC_S:
print("\n\n----- Status -----\n");
print_val_hex8(host_keyboard_leds());
@@ -320,7 +310,6 @@ static bool command_common(uint8_t code)
***********************************************************/
static void command_console_help(void)
{
- print_enable = true;
print("\n\n----- Console Help -----\n");
print("ESC/q: quit\n");
#ifdef MOUSEKEY_ENABLE
diff --git a/common/debug.h b/common/debug.h
index e63d46f0e9..e16ea14af4 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "print.h"
+#ifndef NO_DEBUG
+
#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)
@@ -31,9 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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)
@@ -46,11 +45,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
+
+#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)
+
+#endif
+
#ifdef __cplusplus
extern "C" {
diff --git a/common/keyboard.c b/common/keyboard.c
index 42c57ac96f..cb0dc06e60 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -54,7 +54,7 @@ static bool has_ghost_in_row(uint8_t row)
void keyboard_init(void)
{
// TODO: configuration of sendchar impl
- print_sendchar_func = sendchar;
+ print_set_sendchar(sendchar);
timer_init();
matrix_init();
diff --git a/common/print.c b/common/print.c
index 08d211f206..329f835125 100644
--- a/common/print.c
+++ b/common/print.c
@@ -27,12 +27,17 @@
#include "print.h"
-#define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0)
+#ifndef NO_PRINT
+#define sendchar(c) do { if (print_sendchar_func) (print_sendchar_func)(c); } while (0)
-int8_t (*print_sendchar_func)(uint8_t) = 0;
-bool print_enable = true;
+static int8_t (*print_sendchar_func)(uint8_t) = 0;
+
+void print_set_sendchar(int8_t (*sendchar_func)(uint8_t))
+{
+ print_sendchar_func = sendchar_func;
+}
/* print string stored in data memory(SRAM)
* print_P("hello world");
@@ -184,3 +189,5 @@ void print_bin_reverse32(uint32_t data)
print_bin_reverse8(data>>16);
print_bin_reverse8(data>>24);
}
+
+#endif
diff --git a/common/print.h b/common/print.h
index b22509477f..80858b3bc5 100644
--- a/common/print.h
+++ b/common/print.h
@@ -30,13 +30,12 @@
#include <avr/pgmspace.h>
-// avoid collision with arduino/Print.h
-#ifndef __cplusplus
// this macro allows you to write print("some text") and
// the string is automatically placed into flash memory :)
+// TODO: avoid collision with arduino/Print.h
+#ifndef __cplusplus
#define print(s) print_P(PSTR(s))
#endif
-
#define println(s) print_P(PSTR(s "\n"))
/* for old name */
@@ -49,15 +48,12 @@
#define pbin_reverse(data) print_bin_reverse8(data)
#define pbin_reverse16(data) print_bin_reverse16(data)
-
/* print value utility */
-#define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0)
+#define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0)
#define print_val_decs(v) do { print_P(PSTR(#v ": ")); print_decs(v); print_P(PSTR("\n")); } while (0)
-
#define print_val_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0)
#define print_val_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0)
#define print_val_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0)
-
#define print_val_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0)
#define print_val_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0)
#define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0)
@@ -67,13 +63,13 @@
+#ifndef NO_PRINT
+
#ifdef __cplusplus
extern "C" {
#endif
-
/* function pointer of sendchar to be used by print utility */
-extern int8_t (*print_sendchar_func)(uint8_t);
-extern bool print_enable;
+void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
/* print string stored in data memory(SRAM) */
void print_S(const char *s);
@@ -100,9 +96,31 @@ void print_bin32(uint32_t data);
void print_bin_reverse8(uint8_t data);
void print_bin_reverse16(uint16_t data);
void print_bin_reverse32(uint32_t data);
-
#ifdef __cplusplus
}
#endif
+#else
+
+#define print_set_sendchar(func)
+#define print_S(s)
+#define print_P(s)
+#define print_CRLF()
+#define print_dec(data)
+#define print_decs(data)
+#define print_hex4(data)
+#define print_hex8(data)
+#define print_hex16(data)
+#define print_hex32(data)
+#define print_bin4(data)
+#define print_bin8(data)
+#define print_bin16(data)
+#define print_bin32(data)
+#define print_bin_reverse8(data)
+#define print_bin_reverse16(data)
+#define print_bin_reverse32(data)
+
+#endif
+
+
#endif
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h
index 38d88eecc4..64a080e1c2 100644
--- a/keyboard/gh60/config.h
+++ b/keyboard/gh60/config.h
@@ -56,5 +56,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOTLOADER_SIZE 4096
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
#endif