diff options
| author | tmk <nobody@nowhere> | 2010-10-24 03:27:43 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2010-10-24 03:33:08 +0900 |
| commit | 4acc38751e9c8e90921773e6e5f5a100b0729d98 (patch) | |
| tree | e8e650c6c0557871f55c39b6449a0cc2479fbf58 /print.c | |
| parent | bf92bdd7fa9938c162c29e565d245e5609e4a912 (diff) | |
| download | qmk_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.c | 9 |
1 files changed, 9 insertions, 0 deletions
| @@ -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 | |||
| 31 | bool print_enable = false; | ||
| 32 | |||
| 30 | void print_P(const char *s) | 33 | void 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 | ||
| 42 | void phex1(unsigned char c) | 46 | void 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 | ||
| 47 | void phex(unsigned char c) | 52 | void 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 | ||
| 53 | void phex16(unsigned int i) | 59 | void 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 | ||
| 60 | void pbin(unsigned char c) | 67 | void 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 | ||
| 67 | void pbin_reverse(unsigned char c) | 75 | void 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 | } |
