aboutsummaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2010-10-24 03:27:43 +0900
committertmk <nobody@nowhere>2010-10-24 03:33:08 +0900
commit4acc38751e9c8e90921773e6e5f5a100b0729d98 (patch)
treee8e650c6c0557871f55c39b6449a0cc2479fbf58 /print.c
parentbf92bdd7fa9938c162c29e565d245e5609e4a912 (diff)
downloadqmk_firmware-4acc38751e9c8e90921773e6e5f5a100b0729d98.tar.gz
qmk_firmware-4acc38751e9c8e90921773e6e5f5a100b0729d98.zip
switch debug on/off by pressing 4 keys on booting time
Diffstat (limited to 'print.c')
-rw-r--r--print.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/print.c b/print.c
index 5395fa348..59b4bca18 100644
--- a/print.c
+++ b/print.c
@@ -27,8 +27,12 @@
27#include <avr/pgmspace.h> 27#include <avr/pgmspace.h>
28#include "print.h" 28#include "print.h"
29 29
30
31bool print_enable = false;
32
30void print_P(const char *s) 33void print_P(const char *s)
31{ 34{
35 if (!print_enable) return;
32 char c; 36 char c;
33 37
34 while (1) { 38 while (1) {
@@ -41,17 +45,20 @@ void print_P(const char *s)
41 45
42void phex1(unsigned char c) 46void phex1(unsigned char c)
43{ 47{
48 if (!print_enable) return;
44 usb_debug_putchar(c + ((c < 10) ? '0' : 'A' - 10)); 49 usb_debug_putchar(c + ((c < 10) ? '0' : 'A' - 10));
45} 50}
46 51
47void phex(unsigned char c) 52void phex(unsigned char c)
48{ 53{
54 if (!print_enable) return;
49 phex1(c >> 4); 55 phex1(c >> 4);
50 phex1(c & 15); 56 phex1(c & 15);
51} 57}
52 58
53void phex16(unsigned int i) 59void phex16(unsigned int i)
54{ 60{
61 if (!print_enable) return;
55 phex(i >> 8); 62 phex(i >> 8);
56 phex(i); 63 phex(i);
57} 64}
@@ -59,6 +66,7 @@ void phex16(unsigned int i)
59 66
60void pbin(unsigned char c) 67void pbin(unsigned char c)
61{ 68{
69 if (!print_enable) return;
62 for (int i = 7; i >= 0; i--) { 70 for (int i = 7; i >= 0; i--) {
63 usb_debug_putchar((c & (1<<i)) ? '1' : '0'); 71 usb_debug_putchar((c & (1<<i)) ? '1' : '0');
64 } 72 }
@@ -66,6 +74,7 @@ void pbin(unsigned char c)
66 74
67void pbin_reverse(unsigned char c) 75void pbin_reverse(unsigned char c)
68{ 76{
77 if (!print_enable) return;
69 for (int i = 0; i < 8; i++) { 78 for (int i = 0; i < 8; i++) {
70 usb_debug_putchar((c & (1<<i)) ? '1' : '0'); 79 usb_debug_putchar((c & (1<<i)) ? '1' : '0');
71 } 80 }