aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/command.c54
-rw-r--r--common/debug.c1
-rw-r--r--common/debug.h35
-rw-r--r--common/keyboard.c6
-rw-r--r--common/mousekey.c12
-rw-r--r--common/print.c160
-rw-r--r--common/print.h63
7 files changed, 242 insertions, 89 deletions
diff --git a/common/command.c b/common/command.c
index 8e2e21a70..a06e6a00d 100644
--- a/common/command.c
+++ b/common/command.c
@@ -164,9 +164,6 @@ static bool command_common(uint8_t code)
164 debug_enable = false; 164 debug_enable = false;
165 } else { 165 } else {
166 print("\nDEBUG: enabled.\n"); 166 print("\nDEBUG: enabled.\n");
167 debug_matrix = true;
168 debug_keyboard = true;
169 debug_mouse = true;
170 debug_enable = true; 167 debug_enable = true;
171 } 168 }
172 break; 169 break;
@@ -205,7 +202,7 @@ static bool command_common(uint8_t code)
205 print("VERSION: " STR(DEVICE_VER) "\n"); 202 print("VERSION: " STR(DEVICE_VER) "\n");
206 break; 203 break;
207 case KC_T: // print timer 204 case KC_T: // print timer
208 print("timer: "); phex16(timer_count>>16); phex16(timer_count); print("\n"); 205 print_val_hex32(timer_count);
209 break; 206 break;
210 case KC_P: // print toggle 207 case KC_P: // print toggle
211 if (print_enable) { 208 if (print_enable) {
@@ -218,20 +215,20 @@ static bool command_common(uint8_t code)
218 break; 215 break;
219 case KC_S: 216 case KC_S:
220 print("\n\n----- Status -----\n"); 217 print("\n\n----- Status -----\n");
221 print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n"); 218 print_val_hex8(host_keyboard_leds());
222#ifdef HOST_PJRC 219#ifdef HOST_PJRC
223 print("UDCON: "); phex(UDCON); print("\n"); 220 print_val_hex8(UDCON);
224 print("UDIEN: "); phex(UDIEN); print("\n"); 221 print_val_hex8(UDIEN);
225 print("UDINT: "); phex(UDINT); print("\n"); 222 print_val_hex8(UDINT);
226 print("usb_keyboard_leds:"); phex(usb_keyboard_leds); print("\n"); 223 print_val_hex8(usb_keyboard_leds);
227 print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol); print("\n"); 224 print_val_hex8(usb_keyboard_protocol);
228 print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n"); 225 print_val_hex8(usb_keyboard_idle_config);
229 print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n"); 226 print_val_hex8(usb_keyboard_idle_count);
230#endif 227#endif
231 228
232#ifdef HOST_VUSB 229#ifdef HOST_VUSB
233# if USB_COUNT_SOF 230# if USB_COUNT_SOF
234 print("usbSofCount: "); phex(usbSofCount); print("\n"); 231 print_val_hex8(usbSofCount);
235# endif 232# endif
236#endif 233#endif
237 break; 234 break;
@@ -350,6 +347,7 @@ static void mousekey_param_print(void)
350 print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); 347 print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
351} 348}
352 349
350#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
353static void mousekey_param_inc(uint8_t param, uint8_t inc) 351static void mousekey_param_inc(uint8_t param, uint8_t inc)
354{ 352{
355 switch (param) { 353 switch (param) {
@@ -358,42 +356,42 @@ static void mousekey_param_inc(uint8_t param, uint8_t inc)
358 mk_delay += inc; 356 mk_delay += inc;
359 else 357 else
360 mk_delay = UINT8_MAX; 358 mk_delay = UINT8_MAX;
361 print("mk_delay = "); pdec(mk_delay); print("\n"); 359 PRINT_SET_VAL(mk_delay);
362 break; 360 break;
363 case 2: 361 case 2:
364 if (mk_interval + inc < UINT8_MAX) 362 if (mk_interval + inc < UINT8_MAX)
365 mk_interval += inc; 363 mk_interval += inc;
366 else 364 else
367 mk_interval = UINT8_MAX; 365 mk_interval = UINT8_MAX;
368 print("mk_interval = "); pdec(mk_interval); print("\n"); 366 PRINT_SET_VAL(mk_interval);
369 break; 367 break;
370 case 3: 368 case 3:
371 if (mk_max_speed + inc < UINT8_MAX) 369 if (mk_max_speed + inc < UINT8_MAX)
372 mk_max_speed += inc; 370 mk_max_speed += inc;
373 else 371 else
374 mk_max_speed = UINT8_MAX; 372 mk_max_speed = UINT8_MAX;
375 print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); 373 PRINT_SET_VAL(mk_max_speed);
376 break; 374 break;
377 case 4: 375 case 4:
378 if (mk_time_to_max + inc < UINT8_MAX) 376 if (mk_time_to_max + inc < UINT8_MAX)
379 mk_time_to_max += inc; 377 mk_time_to_max += inc;
380 else 378 else
381 mk_time_to_max = UINT8_MAX; 379 mk_time_to_max = UINT8_MAX;
382 print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); 380 PRINT_SET_VAL(mk_time_to_max);
383 break; 381 break;
384 case 5: 382 case 5:
385 if (mk_wheel_max_speed + inc < UINT8_MAX) 383 if (mk_wheel_max_speed + inc < UINT8_MAX)
386 mk_wheel_max_speed += inc; 384 mk_wheel_max_speed += inc;
387 else 385 else
388 mk_wheel_max_speed = UINT8_MAX; 386 mk_wheel_max_speed = UINT8_MAX;
389 print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); 387 PRINT_SET_VAL(mk_wheel_max_speed);
390 break; 388 break;
391 case 6: 389 case 6:
392 if (mk_wheel_time_to_max + inc < UINT8_MAX) 390 if (mk_wheel_time_to_max + inc < UINT8_MAX)
393 mk_wheel_time_to_max += inc; 391 mk_wheel_time_to_max += inc;
394 else 392 else
395 mk_wheel_time_to_max = UINT8_MAX; 393 mk_wheel_time_to_max = UINT8_MAX;
396 print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); 394 PRINT_SET_VAL(mk_wheel_time_to_max);
397 break; 395 break;
398 } 396 }
399} 397}
@@ -406,42 +404,42 @@ static void mousekey_param_dec(uint8_t param, uint8_t dec)
406 mk_delay -= dec; 404 mk_delay -= dec;
407 else 405 else
408 mk_delay = 0; 406 mk_delay = 0;
409 print("mk_delay = "); pdec(mk_delay); print("\n"); 407 PRINT_SET_VAL(mk_delay);
410 break; 408 break;
411 case 2: 409 case 2:
412 if (mk_interval > dec) 410 if (mk_interval > dec)
413 mk_interval -= dec; 411 mk_interval -= dec;
414 else 412 else
415 mk_interval = 0; 413 mk_interval = 0;
416 print("mk_interval = "); pdec(mk_interval); print("\n"); 414 PRINT_SET_VAL(mk_interval);
417 break; 415 break;
418 case 3: 416 case 3:
419 if (mk_max_speed > dec) 417 if (mk_max_speed > dec)
420 mk_max_speed -= dec; 418 mk_max_speed -= dec;
421 else 419 else
422 mk_max_speed = 0; 420 mk_max_speed = 0;
423 print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); 421 PRINT_SET_VAL(mk_max_speed);
424 break; 422 break;
425 case 4: 423 case 4:
426 if (mk_time_to_max > dec) 424 if (mk_time_to_max > dec)
427 mk_time_to_max -= dec; 425 mk_time_to_max -= dec;
428 else 426 else
429 mk_time_to_max = 0; 427 mk_time_to_max = 0;
430 print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); 428 PRINT_SET_VAL(mk_time_to_max);
431 break; 429 break;
432 case 5: 430 case 5:
433 if (mk_wheel_max_speed > dec) 431 if (mk_wheel_max_speed > dec)
434 mk_wheel_max_speed -= dec; 432 mk_wheel_max_speed -= dec;
435 else 433 else
436 mk_wheel_max_speed = 0; 434 mk_wheel_max_speed = 0;
437 print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); 435 PRINT_SET_VAL(mk_wheel_max_speed);
438 break; 436 break;
439 case 6: 437 case 6:
440 if (mk_wheel_time_to_max > dec) 438 if (mk_wheel_time_to_max > dec)
441 mk_wheel_time_to_max -= dec; 439 mk_wheel_time_to_max -= dec;
442 else 440 else
443 mk_wheel_time_to_max = 0; 441 mk_wheel_time_to_max = 0;
444 print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); 442 PRINT_SET_VAL(mk_wheel_time_to_max);
445 break; 443 break;
446 } 444 }
447} 445}
@@ -551,11 +549,11 @@ static uint8_t numkey2num(uint8_t code)
551 549
552static void switch_layer(uint8_t layer) 550static void switch_layer(uint8_t layer)
553{ 551{
554 print("current_layer: "); phex(current_layer); print("\n"); 552 print_val_hex8(current_layer);
555 print("default_layer: "); phex(default_layer); print("\n"); 553 print_val_hex8(default_layer);
556 current_layer = layer; 554 current_layer = layer;
557 default_layer = layer; 555 default_layer = layer;
558 print("switch to Layer: "); phex(layer); print("\n"); 556 print("switch to "); print_val_hex8(layer);
559} 557}
560 558
561static void clear_keyboard(void) 559static void clear_keyboard(void)
diff --git a/common/debug.c b/common/debug.c
index 41d566ee3..e406d39b0 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -6,4 +6,3 @@ bool debug_enable = false;
6bool debug_matrix = false; 6bool debug_matrix = false;
7bool debug_keyboard = false; 7bool debug_keyboard = false;
8bool debug_mouse = false; 8bool debug_mouse = false;
9
diff --git a/common/debug.h b/common/debug.h
index 1d56e21f7..c12f2cb00 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -22,13 +22,34 @@ 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#define debug(s) if(debug_enable) print_P(PSTR(s)) 25#define debug(s) do { if (debug_enable) print(s); } while (0)
26#define debug_P(s) if(debug_enable) print_P(s) 26#define debugln(s) do { if (debug_enable) println(s); } while (0)
27#define debug_S(s) if(debug_enable) print_S(s) 27#define debug_S(s) do { if (debug_enable) print_S(s); } while (0)
28#define debug_hex(c) if(debug_enable) phex(c) 28#define debug_P(s) do { if (debug_enable) print_P(s); } while (0)
29#define debug_hex16(i) if(debug_enable) phex16(i) 29#define debug_msg(s) do { \
30#define debug_bin(c) if(debug_enable) pbin(c) 30 if (debug_enable) { \
31#define debug_bin_reverse(c) if(debug_enable) pbin_reverse(c) 31 print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \
32 } \
33} while (0)
34
35
36
37#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)
39#define debug_hex8(data) do { if (debug_enable) print_hex8(data); } while (0)
40#define debug_hex16(data) do { if (debug_enable) print_hex16(data); } while (0)
41#define debug_hex32(data) do { if (debug_enable) print_hex32(data); } while (0)
42#define debug_bin8(data) do { if (debug_enable) print_bin8(data); } while (0)
43#define debug_bin16(data) do { if (debug_enable) print_bin16(data); } while (0)
44#define debug_bin32(data) do { if (debug_enable) print_bin32(data); } while (0)
45#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0)
46#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0)
47#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)
48
49#define debug_dec(data) debug_dec(data)
50#define debug_hex(data) debug_hex8(data)
51#define debug_bin(data) debug_bin8(data)
52#define debug_bin_reverse(data) debug_bin8(data)
32 53
33 54
34#ifdef __cplusplus 55#ifdef __cplusplus
diff --git a/common/keyboard.c b/common/keyboard.c
index b0e0ed793..bda7c0625 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -1,5 +1,5 @@
1/* 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
3 3
4This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
25#include "debug.h" 25#include "debug.h"
26#include "command.h" 26#include "command.h"
27#include "util.h" 27#include "util.h"
28#include "sendchar.h"
28#ifdef MOUSEKEY_ENABLE 29#ifdef MOUSEKEY_ENABLE
29#include "mousekey.h" 30#include "mousekey.h"
30#endif 31#endif
@@ -545,6 +546,9 @@ void keyboard_init(void)
545{ 546{
546 debug_keyboard = true; 547 debug_keyboard = true;
547 548
549 // TODO: configuration of sendchar impl
550 print_sendchar_func = sendchar;
551
548 timer_init(); 552 timer_init();
549 matrix_init(); 553 matrix_init();
550#ifdef PS2_MOUSE_ENABLE 554#ifdef PS2_MOUSE_ENABLE
diff --git a/common/mousekey.c b/common/mousekey.c
index d26b26306..3068fc5e3 100644
--- a/common/mousekey.c
+++ b/common/mousekey.c
@@ -187,10 +187,10 @@ static void mousekey_debug(void)
187 if (!debug_mouse) return; 187 if (!debug_mouse) return;
188 print("mousekey [btn|x y v h](rep/acl): ["); 188 print("mousekey [btn|x y v h](rep/acl): [");
189 phex(mouse_report.buttons); print("|"); 189 phex(mouse_report.buttons); print("|");
190 phex(mouse_report.x); print(" "); 190 print_decs(mouse_report.x); print(" ");
191 phex(mouse_report.y); print(" "); 191 print_decs(mouse_report.y); print(" ");
192 phex(mouse_report.v); print(" "); 192 print_decs(mouse_report.v); print(" ");
193 phex(mouse_report.h); print("]("); 193 print_decs(mouse_report.h); print("](");
194 phex(mousekey_repeat); print("/"); 194 print_dec(mousekey_repeat); print("/");
195 phex(mousekey_accel); print(")\n"); 195 print_dec(mousekey_accel); print(")\n");
196} 196}
diff --git a/common/print.c b/common/print.c
index 4e36d3935..6a8a725bc 100644
--- a/common/print.c
+++ b/common/print.c
@@ -1,3 +1,4 @@
1/* Copyright 2012 Jun Wako <wakojun@gmail.com> */
1/* Very basic print functions, intended to be used with usb_debug_only.c 2/* Very basic print functions, intended to be used with usb_debug_only.c
2 * http://www.pjrc.com/teensy/ 3 * http://www.pjrc.com/teensy/
3 * Copyright (c) 2008 PJRC.COM, LLC 4 * Copyright (c) 2008 PJRC.COM, LLC
@@ -24,78 +25,157 @@
24#include <avr/io.h> 25#include <avr/io.h>
25#include <avr/pgmspace.h> 26#include <avr/pgmspace.h>
26#include "print.h" 27#include "print.h"
27#include "sendchar.h"
28 28
29 29
30#define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0)
31
32
33int8_t (*print_sendchar_func)(uint8_t) = 0;
30bool print_enable = false; 34bool print_enable = false;
31 35
36
37/* print string stored in data memory(SRAM)
38 * print_P("hello world");
39 * This consumes precious SRAM memory space for string.
40 */
32void print_S(const char *s) 41void print_S(const char *s)
33{ 42{
34 if (!print_enable) return; 43 uint8_t c;
35 char c; 44 while (1) {
36 45 c = *s++;
37 while (1) { 46 if (!c) break;
38 c = *s++; 47 if (c == '\n') sendchar('\r');
39 if (!c) break; 48 sendchar(c);
40 if (c == '\n') sendchar('\r'); 49 }
41 sendchar(c);
42 }
43} 50}
44 51
52/* print string stored in program memory(FLASH)
53 * print_P(PSTR("hello world");
54 * This consumes relatively abundant FLASH memory area not SRAM.
55 */
45void print_P(const char *s) 56void print_P(const char *s)
46{ 57{
47 if (!print_enable) return; 58 uint8_t c;
48 char c; 59 while (1) {
60 c = pgm_read_byte(s++);
61 if (!c) break;
62 if (c == '\n') sendchar('\r');
63 sendchar(c);
64 }
65}
66
67void print_CRLF(void)
68{
69 sendchar('\r'); sendchar('\n');
70}
71
72
73#define SIGNED 0x80
74#define BIN 2
75#define OCT 8
76#define DEC 10
77#define HEX 16
78
79static inline
80char itoc(uint8_t i)
81{
82 return (i < 10 ? '0' + i : 'A' + i - 10);
83}
84
85static inline
86void print_int(uint16_t data, uint8_t base)
87{
88 char buf[7] = {'\0'};
89 char *p = &buf[6];
90 if ((base & SIGNED) && (data & 0x8000)) {
91 data = -data;
92 buf[0] = '-';
93 }
94 base &= ~SIGNED;
95 uint16_t n;
96 do {
97 n = data;
98 data /= base;
99 *(--p) = itoc(n - data*base);
100 } while (data);
101 if (buf[0]) *(--p) = buf[0];
102 print_S(p);
103}
104
105void print_dec(uint16_t data)
106{
107 print_int(data, DEC);
108}
49 109
50 while (1) { 110void print_decs(int16_t data)
51 c = pgm_read_byte(s++); 111{
52 if (!c) break; 112 print_int(data, DEC|SIGNED);
53 if (c == '\n') sendchar('\r');
54 sendchar(c);
55 }
56} 113}
57 114
58void phex1(unsigned char c) 115
116static inline
117void print_hex4(uint8_t data)
59{ 118{
60 if (!print_enable) return; 119 sendchar(data + ((data < 10) ? '0' : 'A' - 10));
61 sendchar(c + ((c < 10) ? '0' : 'A' - 10));
62} 120}
63 121
64void phex(unsigned char c) 122void print_hex8(uint8_t data)
65{ 123{
66 if (!print_enable) return; 124 print_hex4(data>>4);
67 phex1(c >> 4); 125 print_hex4(data&0x0F);
68 phex1(c & 15);
69} 126}
70 127
71void phex16(unsigned int i) 128void print_hex16(uint16_t data)
72{ 129{
73 if (!print_enable) return; 130 print_hex8(data>>8);
74 phex(i >> 8); 131 print_hex8(data);
75 phex(i);
76} 132}
77 133
78void pdec(uint8_t i) 134void print_hex32(uint32_t data)
79{ 135{
80 if (!print_enable) return; 136 print_hex16(data>>16);
81 if (i/100) sendchar('0' + (i/100)); 137 print_hex16(data);
82 if (i/100 || i%100/10) sendchar('0' + (i%100/10));
83 sendchar('0' + (i%10));
84} 138}
85 139
86 140
87void pbin(unsigned char c) 141void print_bin(uint8_t data)
88{ 142{
89 if (!print_enable) return;
90 for (int i = 7; i >= 0; i--) { 143 for (int i = 7; i >= 0; i--) {
91 sendchar((c & (1<<i)) ? '1' : '0'); 144 sendchar((data & (1<<i)) ? '1' : '0');
92 } 145 }
93} 146}
94 147
95void pbin_reverse(unsigned char c) 148void print_bin16(uint16_t data)
149{
150 print_bin8(data>>8);
151 print_bin8(data);
152}
153
154void print_bin32(uint32_t data)
155{
156 print_bin8(data>>24);
157 print_bin8(data>>16);
158 print_bin8(data>>8);
159 print_bin8(data);
160}
161
162void print_bin_reverse8(uint8_t data)
96{ 163{
97 if (!print_enable) return;
98 for (int i = 0; i < 8; i++) { 164 for (int i = 0; i < 8; i++) {
99 sendchar((c & (1<<i)) ? '1' : '0'); 165 sendchar((data & (1<<i)) ? '1' : '0');
100 } 166 }
101} 167}
168
169void print_bin_reverse16(uint16_t data)
170{
171 print_bin_reverse8(data);
172 print_bin_reverse8(data>>8);
173}
174
175void print_bin_reverse32(uint32_t data)
176{
177 print_bin_reverse8(data);
178 print_bin_reverse8(data>>8);
179 print_bin_reverse8(data>>16);
180 print_bin_reverse8(data>>24);
181}
diff --git a/common/print.h b/common/print.h
index 1c4567862..9c31b24a2 100644
--- a/common/print.h
+++ b/common/print.h
@@ -1,3 +1,4 @@
1/* Copyright 2012 Jun Wako <wakojun@gmail.com> */
1/* Very basic print functions, intended to be used with usb_debug_only.c 2/* Very basic print functions, intended to be used with usb_debug_only.c
2 * http://www.pjrc.com/teensy/ 3 * http://www.pjrc.com/teensy/
3 * Copyright (c) 2008 PJRC.COM, LLC 4 * Copyright (c) 2008 PJRC.COM, LLC
@@ -33,21 +34,71 @@
33#ifndef __cplusplus 34#ifndef __cplusplus
34// this macro allows you to write print("some text") and 35// this macro allows you to write print("some text") and
35// the string is automatically placed into flash memory :) 36// the string is automatically placed into flash memory :)
36#define print(s) print_P(PSTR(s)) 37#define print(s) print_P(PSTR(s))
37#endif 38#endif
38 39
40#define println(s) print_P(PSTR(s "\n"))
41
42/* for old name */
43#define pdec(data) print_dec(data)
44#define pdec16(data) print_dec(data)
45#define phex(data) print_hex8(data)
46#define phex16(data) print_hex16(data)
47#define pbin(data) print_bin8(data)
48#define pbin16(data) print_bin16(data)
49#define pbin_reverse(data) print_bin_reverse8(data)
50#define pbin_reverse16(data) print_bin_reverse16(data)
51
52
53/* print value utility */
54#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)
56
57#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)
59#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)
62#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)
64#define print_val_bin_reverse8(v) do { print_P(PSTR(#v ": ")); print_bin_reverse8(v); print_P(PSTR("\n")); } while (0)
65#define print_val_bin_reverse16(v) do { print_P(PSTR(#v ": ")); print_bin_reverse16(v); print_P(PSTR("\n")); } while (0)
66#define print_val_bin_reverse32(v) do { print_P(PSTR(#v ": ")); print_bin_reverse32(v); print_P(PSTR("\n")); } while (0)
67
68
69
39#ifdef __cplusplus 70#ifdef __cplusplus
40extern "C" { 71extern "C" {
41#endif 72#endif
73
74/* function pointer of sendchar to be used by print utility */
75extern int8_t (*print_sendchar_func)(uint8_t);
42extern bool print_enable; 76extern bool print_enable;
43 77
78/* print string stored in data memory(SRAM) */
44void print_S(const char *s); 79void print_S(const char *s);
80/* print string stored in program memory(FLASH) */
45void print_P(const char *s); 81void print_P(const char *s);
46void phex(unsigned char c); 82
47void phex16(unsigned int i); 83void print_CRLF(void);
48void pdec(uint8_t i); 84
49void pbin(unsigned char c); 85/* decimal */
50void pbin_reverse(unsigned char c); 86void print_dec(uint16_t data);
87void print_decs(int16_t data);
88
89/* hex */
90void print_hex8(uint8_t data);
91void print_hex16(uint16_t data);
92void print_hex32(uint32_t data);
93
94/* binary */
95void print_bin8(uint8_t data);
96void print_bin16(uint16_t data);
97void print_bin32(uint32_t data);
98void print_bin_reverse8(uint8_t data);
99void print_bin_reverse16(uint16_t data);
100void print_bin_reverse32(uint32_t data);
101
51#ifdef __cplusplus 102#ifdef __cplusplus
52} 103}
53#endif 104#endif