aboutsummaryrefslogtreecommitdiff
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 4054893b4..2ce4e32da 100644
--- a/common.mk
+++ b/common.mk
@@ -31,6 +31,9 @@ endif
31 31
32ifdef CONSOLE_ENABLE 32ifdef CONSOLE_ENABLE
33 OPT_DEFS += -DCONSOLE_ENABLE 33 OPT_DEFS += -DCONSOLE_ENABLE
34else
35 OPT_DEFS += -DNO_PRINT
36 OPT_DEFS += -DNO_DEBUG
34endif 37endif
35 38
36ifdef NKRO_ENABLE 39ifdef NKRO_ENABLE
diff --git a/common/command.c b/common/command.c
index 372ca291e..cb98e1d5f 100644
--- a/common/command.c
+++ b/common/command.c
@@ -98,7 +98,6 @@ bool command_extra(uint8_t code)
98 ***********************************************************/ 98 ***********************************************************/
99static void command_common_help(void) 99static void command_common_help(void)
100{ 100{
101 print_enable = true;
102 print("\n\n----- Command Help -----\n"); 101 print("\n\n----- Command Help -----\n");
103 print("c: enter console mode\n"); 102 print("c: enter console mode\n");
104 print("d: toggle debug enable\n"); 103 print("d: toggle debug enable\n");
@@ -137,7 +136,8 @@ static void print_eeprom_config(void)
137 eebyte = eeconfig_read_keyconf(); 136 eebyte = eeconfig_read_keyconf();
138 print("keyconf: "); print_hex8(eebyte); print("\n"); 137 print("keyconf: "); print_hex8(eebyte); print("\n");
139 138
140 keyconf kc = (keyconf){ .raw = eebyte }; 139 keyconf kc;
140 kc = (keyconf){ .raw = eebyte };
141 print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n"); 141 print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n");
142 print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n"); 142 print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n");
143 print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n"); 143 print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n");
@@ -173,7 +173,6 @@ static bool command_common(uint8_t code)
173 command_common_help(); 173 command_common_help();
174 break; 174 break;
175 case KC_C: 175 case KC_C:
176 print_enable = true;
177 debug_matrix = false; 176 debug_matrix = false;
178 debug_keyboard = false; 177 debug_keyboard = false;
179 debug_mouse = false; 178 debug_mouse = false;
@@ -239,15 +238,6 @@ static bool command_common(uint8_t code)
239 case KC_T: // print timer 238 case KC_T: // print timer
240 print_val_hex32(timer_count); 239 print_val_hex32(timer_count);
241 break; 240 break;
242 case KC_P: // print toggle
243 if (print_enable) {
244 print("print disabled.\n");
245 print_enable = false;
246 } else {
247 print_enable = true;
248 print("print enabled.\n");
249 }
250 break;
251 case KC_S: 241 case KC_S:
252 print("\n\n----- Status -----\n"); 242 print("\n\n----- Status -----\n");
253 print_val_hex8(host_keyboard_leds()); 243 print_val_hex8(host_keyboard_leds());
@@ -320,7 +310,6 @@ static bool command_common(uint8_t code)
320 ***********************************************************/ 310 ***********************************************************/
321static void command_console_help(void) 311static void command_console_help(void)
322{ 312{
323 print_enable = true;
324 print("\n\n----- Console Help -----\n"); 313 print("\n\n----- Console Help -----\n");
325 print("ESC/q: quit\n"); 314 print("ESC/q: quit\n");
326#ifdef MOUSEKEY_ENABLE 315#ifdef MOUSEKEY_ENABLE
diff --git a/common/debug.h b/common/debug.h
index e63d46f0e..e16ea14af 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/>.
22#include "print.h" 22#include "print.h"
23 23
24 24
25#ifndef NO_DEBUG
26
25#define debug(s) do { if (debug_enable) print(s); } while (0) 27#define debug(s) do { if (debug_enable) print(s); } while (0)
26#define debugln(s) do { if (debug_enable) println(s); } while (0) 28#define debugln(s) do { if (debug_enable) println(s); } while (0)
27#define debug_S(s) do { if (debug_enable) print_S(s); } while (0) 29#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/>.
31 print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ 33 print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \
32 } \ 34 } \
33} while (0) 35} while (0)
34
35
36
37#define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0) 36#define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0)
38#define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0) 37#define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0)
39#define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0) 38#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/>.
46#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0) 45#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0)
47#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0) 46#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0)
48#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0) 47#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)
49
50#define debug_hex(data) debug_hex8(data) 48#define debug_hex(data) debug_hex8(data)
51#define debug_bin(data) debug_bin8(data) 49#define debug_bin(data) debug_bin8(data)
52#define debug_bin_reverse(data) debug_bin8(data) 50#define debug_bin_reverse(data) debug_bin8(data)
53 51
52#else
53
54#define debug(s)
55#define debugln(s)
56#define debug_S(s)
57#define debug_P(s)
58#define debug_msg(s)
59#define debug_dec(data)
60#define debug_decs(data)
61#define debug_hex4(data)
62#define debug_hex8(data)
63#define debug_hex16(data)
64#define debug_hex32(data)
65#define debug_bin8(data)
66#define debug_bin16(data)
67#define debug_bin32(data)
68#define debug_bin_reverse8(data)
69#define debug_bin_reverse16(data)
70#define debug_bin_reverse32(data)
71#define debug_hex(data)
72#define debug_bin(data)
73#define debug_bin_reverse(data)
74
75#endif
76
54 77
55#ifdef __cplusplus 78#ifdef __cplusplus
56extern "C" { 79extern "C" {
diff --git a/common/keyboard.c b/common/keyboard.c
index 42c57ac96..cb0dc06e6 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -54,7 +54,7 @@ static bool has_ghost_in_row(uint8_t row)
54void keyboard_init(void) 54void keyboard_init(void)
55{ 55{
56 // TODO: configuration of sendchar impl 56 // TODO: configuration of sendchar impl
57 print_sendchar_func = sendchar; 57 print_set_sendchar(sendchar);
58 58
59 timer_init(); 59 timer_init();
60 matrix_init(); 60 matrix_init();
diff --git a/common/print.c b/common/print.c
index 08d211f20..329f83512 100644
--- a/common/print.c
+++ b/common/print.c
@@ -27,12 +27,17 @@
27#include "print.h" 27#include "print.h"
28 28
29 29
30#define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0) 30#ifndef NO_PRINT
31 31
32#define sendchar(c) do { if (print_sendchar_func) (print_sendchar_func)(c); } while (0)
32 33
33int8_t (*print_sendchar_func)(uint8_t) = 0;
34bool print_enable = true;
35 34
35static int8_t (*print_sendchar_func)(uint8_t) = 0;
36
37void print_set_sendchar(int8_t (*sendchar_func)(uint8_t))
38{
39 print_sendchar_func = sendchar_func;
40}
36 41
37/* print string stored in data memory(SRAM) 42/* print string stored in data memory(SRAM)
38 * print_P("hello world"); 43 * print_P("hello world");
@@ -184,3 +189,5 @@ void print_bin_reverse32(uint32_t data)
184 print_bin_reverse8(data>>16); 189 print_bin_reverse8(data>>16);
185 print_bin_reverse8(data>>24); 190 print_bin_reverse8(data>>24);
186} 191}
192
193#endif
diff --git a/common/print.h b/common/print.h
index b22509477..80858b3bc 100644
--- a/common/print.h
+++ b/common/print.h
@@ -30,13 +30,12 @@
30#include <avr/pgmspace.h> 30#include <avr/pgmspace.h>
31 31
32 32
33// avoid collision with arduino/Print.h
34#ifndef __cplusplus
35// this macro allows you to write print("some text") and 33// this macro allows you to write print("some text") and
36// the string is automatically placed into flash memory :) 34// the string is automatically placed into flash memory :)
35// TODO: avoid collision with arduino/Print.h
36#ifndef __cplusplus
37#define print(s) print_P(PSTR(s)) 37#define print(s) print_P(PSTR(s))
38#endif 38#endif
39
40#define println(s) print_P(PSTR(s "\n")) 39#define println(s) print_P(PSTR(s "\n"))
41 40
42/* for old name */ 41/* for old name */
@@ -49,15 +48,12 @@
49#define pbin_reverse(data) print_bin_reverse8(data) 48#define pbin_reverse(data) print_bin_reverse8(data)
50#define pbin_reverse16(data) print_bin_reverse16(data) 49#define pbin_reverse16(data) print_bin_reverse16(data)
51 50
52
53/* print value utility */ 51/* print value utility */
54#define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0) 52#define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0)
55#define print_val_decs(v) do { print_P(PSTR(#v ": ")); print_decs(v); print_P(PSTR("\n")); } while (0) 53#define print_val_decs(v) do { print_P(PSTR(#v ": ")); print_decs(v); print_P(PSTR("\n")); } while (0)
56
57#define print_val_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) 54#define print_val_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0)
58#define print_val_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) 55#define print_val_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0)
59#define print_val_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) 56#define print_val_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0)
60
61#define print_val_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) 57#define print_val_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0)
62#define print_val_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) 58#define print_val_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0)
63#define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) 59#define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0)
@@ -67,13 +63,13 @@
67 63
68 64
69 65
66#ifndef NO_PRINT
67
70#ifdef __cplusplus 68#ifdef __cplusplus
71extern "C" { 69extern "C" {
72#endif 70#endif
73
74/* function pointer of sendchar to be used by print utility */ 71/* function pointer of sendchar to be used by print utility */
75extern int8_t (*print_sendchar_func)(uint8_t); 72void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
76extern bool print_enable;
77 73
78/* print string stored in data memory(SRAM) */ 74/* print string stored in data memory(SRAM) */
79void print_S(const char *s); 75void print_S(const char *s);
@@ -100,9 +96,31 @@ void print_bin32(uint32_t data);
100void print_bin_reverse8(uint8_t data); 96void print_bin_reverse8(uint8_t data);
101void print_bin_reverse16(uint16_t data); 97void print_bin_reverse16(uint16_t data);
102void print_bin_reverse32(uint32_t data); 98void print_bin_reverse32(uint32_t data);
103
104#ifdef __cplusplus 99#ifdef __cplusplus
105} 100}
106#endif 101#endif
107 102
103#else
104
105#define print_set_sendchar(func)
106#define print_S(s)
107#define print_P(s)
108#define print_CRLF()
109#define print_dec(data)
110#define print_decs(data)
111#define print_hex4(data)
112#define print_hex8(data)
113#define print_hex16(data)
114#define print_hex32(data)
115#define print_bin4(data)
116#define print_bin8(data)
117#define print_bin16(data)
118#define print_bin32(data)
119#define print_bin_reverse8(data)
120#define print_bin_reverse16(data)
121#define print_bin_reverse32(data)
122
123#endif
124
125
108#endif 126#endif
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h
index 38d88eecc..64a080e1c 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/>.
56 */ 56 */
57#define BOOTLOADER_SIZE 4096 57#define BOOTLOADER_SIZE 4096
58 58
59/* disable debug print */
60//#define NO_DEBUG
61
62/* disable print */
63//#define NO_PRINT
59 64
60#endif 65#endif