diff options
| -rw-r--r-- | common/command.c | 51 | ||||
| -rw-r--r-- | common/keyboard.c | 6 | ||||
| -rw-r--r-- | common/print.c | 127 | ||||
| -rw-r--r-- | common/print.h | 50 |
4 files changed, 162 insertions, 72 deletions
diff --git a/common/command.c b/common/command.c index 8e2e21a70..85cc05733 100644 --- a/common/command.c +++ b/common/command.c | |||
| @@ -205,7 +205,7 @@ static bool command_common(uint8_t code) | |||
| 205 | print("VERSION: " STR(DEVICE_VER) "\n"); | 205 | print("VERSION: " STR(DEVICE_VER) "\n"); |
| 206 | break; | 206 | break; |
| 207 | case KC_T: // print timer | 207 | case KC_T: // print timer |
| 208 | print("timer: "); phex16(timer_count>>16); phex16(timer_count); print("\n"); | 208 | pv_hex32(timer_count); |
| 209 | break; | 209 | break; |
| 210 | case KC_P: // print toggle | 210 | case KC_P: // print toggle |
| 211 | if (print_enable) { | 211 | if (print_enable) { |
| @@ -218,20 +218,20 @@ static bool command_common(uint8_t code) | |||
| 218 | break; | 218 | break; |
| 219 | case KC_S: | 219 | case KC_S: |
| 220 | print("\n\n----- Status -----\n"); | 220 | print("\n\n----- Status -----\n"); |
| 221 | print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n"); | 221 | pv_hex8(host_keyboard_leds()); |
| 222 | #ifdef HOST_PJRC | 222 | #ifdef HOST_PJRC |
| 223 | print("UDCON: "); phex(UDCON); print("\n"); | 223 | pv_hex8(UDCON); |
| 224 | print("UDIEN: "); phex(UDIEN); print("\n"); | 224 | pv_hex8(UDIEN); |
| 225 | print("UDINT: "); phex(UDINT); print("\n"); | 225 | pv_hex8(UDINT); |
| 226 | print("usb_keyboard_leds:"); phex(usb_keyboard_leds); print("\n"); | 226 | pv_hex8(usb_keyboard_leds); |
| 227 | print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol); print("\n"); | 227 | pv_hex8(usb_keyboard_protocol); |
| 228 | print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n"); | 228 | pv_hex8(usb_keyboard_idle_config); |
| 229 | print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n"); | 229 | pv_hex8(usb_keyboard_idle_count); |
| 230 | #endif | 230 | #endif |
| 231 | 231 | ||
| 232 | #ifdef HOST_VUSB | 232 | #ifdef HOST_VUSB |
| 233 | # if USB_COUNT_SOF | 233 | # if USB_COUNT_SOF |
| 234 | print("usbSofCount: "); phex(usbSofCount); print("\n"); | 234 | pv_hex8(usbSofCount); |
| 235 | # endif | 235 | # endif |
| 236 | #endif | 236 | #endif |
| 237 | break; | 237 | break; |
| @@ -350,6 +350,7 @@ static void mousekey_param_print(void) | |||
| 350 | print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); | 350 | print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | #define PRINT_SET_VAL(v) print(#v " = "); print_dec8(v); print("\n"); | ||
| 353 | static void mousekey_param_inc(uint8_t param, uint8_t inc) | 354 | static void mousekey_param_inc(uint8_t param, uint8_t inc) |
| 354 | { | 355 | { |
| 355 | switch (param) { | 356 | switch (param) { |
| @@ -358,42 +359,42 @@ static void mousekey_param_inc(uint8_t param, uint8_t inc) | |||
| 358 | mk_delay += inc; | 359 | mk_delay += inc; |
| 359 | else | 360 | else |
| 360 | mk_delay = UINT8_MAX; | 361 | mk_delay = UINT8_MAX; |
| 361 | print("mk_delay = "); pdec(mk_delay); print("\n"); | 362 | PRINT_SET_VAL(mk_delay); |
| 362 | break; | 363 | break; |
| 363 | case 2: | 364 | case 2: |
| 364 | if (mk_interval + inc < UINT8_MAX) | 365 | if (mk_interval + inc < UINT8_MAX) |
| 365 | mk_interval += inc; | 366 | mk_interval += inc; |
| 366 | else | 367 | else |
| 367 | mk_interval = UINT8_MAX; | 368 | mk_interval = UINT8_MAX; |
| 368 | print("mk_interval = "); pdec(mk_interval); print("\n"); | 369 | PRINT_SET_VAL(mk_interval); |
| 369 | break; | 370 | break; |
| 370 | case 3: | 371 | case 3: |
| 371 | if (mk_max_speed + inc < UINT8_MAX) | 372 | if (mk_max_speed + inc < UINT8_MAX) |
| 372 | mk_max_speed += inc; | 373 | mk_max_speed += inc; |
| 373 | else | 374 | else |
| 374 | mk_max_speed = UINT8_MAX; | 375 | mk_max_speed = UINT8_MAX; |
| 375 | print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); | 376 | PRINT_SET_VAL(mk_max_speed); |
| 376 | break; | 377 | break; |
| 377 | case 4: | 378 | case 4: |
| 378 | if (mk_time_to_max + inc < UINT8_MAX) | 379 | if (mk_time_to_max + inc < UINT8_MAX) |
| 379 | mk_time_to_max += inc; | 380 | mk_time_to_max += inc; |
| 380 | else | 381 | else |
| 381 | mk_time_to_max = UINT8_MAX; | 382 | mk_time_to_max = UINT8_MAX; |
| 382 | print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); | 383 | PRINT_SET_VAL(mk_time_to_max); |
| 383 | break; | 384 | break; |
| 384 | case 5: | 385 | case 5: |
| 385 | if (mk_wheel_max_speed + inc < UINT8_MAX) | 386 | if (mk_wheel_max_speed + inc < UINT8_MAX) |
| 386 | mk_wheel_max_speed += inc; | 387 | mk_wheel_max_speed += inc; |
| 387 | else | 388 | else |
| 388 | mk_wheel_max_speed = UINT8_MAX; | 389 | mk_wheel_max_speed = UINT8_MAX; |
| 389 | print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); | 390 | PRINT_SET_VAL(mk_wheel_max_speed); |
| 390 | break; | 391 | break; |
| 391 | case 6: | 392 | case 6: |
| 392 | if (mk_wheel_time_to_max + inc < UINT8_MAX) | 393 | if (mk_wheel_time_to_max + inc < UINT8_MAX) |
| 393 | mk_wheel_time_to_max += inc; | 394 | mk_wheel_time_to_max += inc; |
| 394 | else | 395 | else |
| 395 | mk_wheel_time_to_max = UINT8_MAX; | 396 | mk_wheel_time_to_max = UINT8_MAX; |
| 396 | print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); | 397 | PRINT_SET_VAL(mk_wheel_time_to_max); |
| 397 | break; | 398 | break; |
| 398 | } | 399 | } |
| 399 | } | 400 | } |
| @@ -406,42 +407,42 @@ static void mousekey_param_dec(uint8_t param, uint8_t dec) | |||
| 406 | mk_delay -= dec; | 407 | mk_delay -= dec; |
| 407 | else | 408 | else |
| 408 | mk_delay = 0; | 409 | mk_delay = 0; |
| 409 | print("mk_delay = "); pdec(mk_delay); print("\n"); | 410 | PRINT_SET_VAL(mk_delay); |
| 410 | break; | 411 | break; |
| 411 | case 2: | 412 | case 2: |
| 412 | if (mk_interval > dec) | 413 | if (mk_interval > dec) |
| 413 | mk_interval -= dec; | 414 | mk_interval -= dec; |
| 414 | else | 415 | else |
| 415 | mk_interval = 0; | 416 | mk_interval = 0; |
| 416 | print("mk_interval = "); pdec(mk_interval); print("\n"); | 417 | PRINT_SET_VAL(mk_interval); |
| 417 | break; | 418 | break; |
| 418 | case 3: | 419 | case 3: |
| 419 | if (mk_max_speed > dec) | 420 | if (mk_max_speed > dec) |
| 420 | mk_max_speed -= dec; | 421 | mk_max_speed -= dec; |
| 421 | else | 422 | else |
| 422 | mk_max_speed = 0; | 423 | mk_max_speed = 0; |
| 423 | print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); | 424 | PRINT_SET_VAL(mk_max_speed); |
| 424 | break; | 425 | break; |
| 425 | case 4: | 426 | case 4: |
| 426 | if (mk_time_to_max > dec) | 427 | if (mk_time_to_max > dec) |
| 427 | mk_time_to_max -= dec; | 428 | mk_time_to_max -= dec; |
| 428 | else | 429 | else |
| 429 | mk_time_to_max = 0; | 430 | mk_time_to_max = 0; |
| 430 | print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); | 431 | PRINT_SET_VAL(mk_time_to_max); |
| 431 | break; | 432 | break; |
| 432 | case 5: | 433 | case 5: |
| 433 | if (mk_wheel_max_speed > dec) | 434 | if (mk_wheel_max_speed > dec) |
| 434 | mk_wheel_max_speed -= dec; | 435 | mk_wheel_max_speed -= dec; |
| 435 | else | 436 | else |
| 436 | mk_wheel_max_speed = 0; | 437 | mk_wheel_max_speed = 0; |
| 437 | print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); | 438 | PRINT_SET_VAL(mk_wheel_max_speed); |
| 438 | break; | 439 | break; |
| 439 | case 6: | 440 | case 6: |
| 440 | if (mk_wheel_time_to_max > dec) | 441 | if (mk_wheel_time_to_max > dec) |
| 441 | mk_wheel_time_to_max -= dec; | 442 | mk_wheel_time_to_max -= dec; |
| 442 | else | 443 | else |
| 443 | mk_wheel_time_to_max = 0; | 444 | mk_wheel_time_to_max = 0; |
| 444 | print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); | 445 | PRINT_SET_VAL(mk_wheel_time_to_max); |
| 445 | break; | 446 | break; |
| 446 | } | 447 | } |
| 447 | } | 448 | } |
| @@ -551,11 +552,11 @@ static uint8_t numkey2num(uint8_t code) | |||
| 551 | 552 | ||
| 552 | static void switch_layer(uint8_t layer) | 553 | static void switch_layer(uint8_t layer) |
| 553 | { | 554 | { |
| 554 | print("current_layer: "); phex(current_layer); print("\n"); | 555 | pv_hex8(current_layer); |
| 555 | print("default_layer: "); phex(default_layer); print("\n"); | 556 | pv_hex8(default_layer); |
| 556 | current_layer = layer; | 557 | current_layer = layer; |
| 557 | default_layer = layer; | 558 | default_layer = layer; |
| 558 | print("switch to Layer: "); phex(layer); print("\n"); | 559 | print("switch to "); pv_hex8(layer); |
| 559 | } | 560 | } |
| 560 | 561 | ||
| 561 | static void clear_keyboard(void) | 562 | static void clear_keyboard(void) |
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 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | it 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/print.c b/common/print.c index 4e36d3935..dd73ff59d 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 |
| @@ -21,81 +22,125 @@ | |||
| 21 | * THE SOFTWARE. | 22 | * THE SOFTWARE. |
| 22 | */ | 23 | */ |
| 23 | 24 | ||
| 25 | #include <stdio.h> | ||
| 24 | #include <avr/io.h> | 26 | #include <avr/io.h> |
| 25 | #include <avr/pgmspace.h> | 27 | #include <avr/pgmspace.h> |
| 26 | #include "print.h" | 28 | #include "print.h" |
| 27 | #include "sendchar.h" | 29 | #define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0) |
| 28 | 30 | ||
| 29 | 31 | ||
| 32 | int8_t (*print_sendchar_func)(uint8_t) = NULL; | ||
| 30 | bool print_enable = false; | 33 | bool print_enable = false; |
| 31 | 34 | ||
| 35 | /* print string stored in data memory(SRAM) | ||
| 36 | * print_P("hello world"); | ||
| 37 | * This consumes precious SRAM memory space for string. | ||
| 38 | */ | ||
| 32 | void print_S(const char *s) | 39 | void print_S(const char *s) |
| 33 | { | 40 | { |
| 34 | if (!print_enable) return; | 41 | uint8_t c; |
| 35 | char c; | 42 | while (1) { |
| 36 | 43 | c = *s++; | |
| 37 | while (1) { | 44 | if (!c) break; |
| 38 | c = *s++; | 45 | if (c == '\n') sendchar('\r'); |
| 39 | if (!c) break; | 46 | sendchar(c); |
| 40 | if (c == '\n') sendchar('\r'); | 47 | } |
| 41 | sendchar(c); | ||
| 42 | } | ||
| 43 | } | 48 | } |
| 44 | 49 | ||
| 50 | /* print string stored in program memory(FLASH) | ||
| 51 | * print_P(PSTR("hello world"); | ||
| 52 | * This consumes relatively abundant FLASH memory area not SRAM. | ||
| 53 | */ | ||
| 45 | void print_P(const char *s) | 54 | void print_P(const char *s) |
| 46 | { | 55 | { |
| 47 | if (!print_enable) return; | 56 | uint8_t c; |
| 48 | char c; | 57 | while (1) { |
| 49 | 58 | c = pgm_read_byte(s++); | |
| 50 | while (1) { | 59 | if (!c) break; |
| 51 | c = pgm_read_byte(s++); | 60 | if (c == '\n') sendchar('\r'); |
| 52 | if (!c) break; | 61 | sendchar(c); |
| 53 | if (c == '\n') sendchar('\r'); | 62 | } |
| 54 | sendchar(c); | 63 | } |
| 55 | } | 64 | |
| 65 | static inline | ||
| 66 | void print_hex4(uint8_t data) | ||
| 67 | { | ||
| 68 | sendchar(data + ((data < 10) ? '0' : 'A' - 10)); | ||
| 69 | } | ||
| 70 | |||
| 71 | void print_hex8(uint8_t data) | ||
| 72 | { | ||
| 73 | print_hex4(data>>4); | ||
| 74 | print_hex4(data&0x0F); | ||
| 56 | } | 75 | } |
| 57 | 76 | ||
| 58 | void phex1(unsigned char c) | 77 | void print_hex16(uint16_t data) |
| 59 | { | 78 | { |
| 60 | if (!print_enable) return; | 79 | print_hex8(data>>8); |
| 61 | sendchar(c + ((c < 10) ? '0' : 'A' - 10)); | 80 | print_hex8(data); |
| 62 | } | 81 | } |
| 63 | 82 | ||
| 64 | void phex(unsigned char c) | 83 | void print_hex32(uint32_t data) |
| 65 | { | 84 | { |
| 66 | if (!print_enable) return; | 85 | print_hex16(data>>16); |
| 67 | phex1(c >> 4); | 86 | print_hex16(data); |
| 68 | phex1(c & 15); | ||
| 69 | } | 87 | } |
| 70 | 88 | ||
| 71 | void phex16(unsigned int i) | 89 | void print_dec8(uint8_t data) |
| 72 | { | 90 | { |
| 73 | if (!print_enable) return; | 91 | if (data/100) sendchar('0' + (data/100)); |
| 74 | phex(i >> 8); | 92 | if (data/100 || data%100/10) sendchar('0' + (data%100/10)); |
| 75 | phex(i); | 93 | sendchar('0' + (data%10)); |
| 76 | } | 94 | } |
| 77 | 95 | ||
| 78 | void pdec(uint8_t i) | 96 | void print_dec16(uint16_t data) |
| 79 | { | 97 | { |
| 80 | if (!print_enable) return; | 98 | // TODO |
| 81 | if (i/100) sendchar('0' + (i/100)); | ||
| 82 | if (i/100 || i%100/10) sendchar('0' + (i%100/10)); | ||
| 83 | sendchar('0' + (i%10)); | ||
| 84 | } | 99 | } |
| 85 | 100 | ||
| 101 | void print_dec32(uint32_t data) | ||
| 102 | { | ||
| 103 | // TODO | ||
| 104 | } | ||
| 86 | 105 | ||
| 87 | void pbin(unsigned char c) | 106 | void print_bin(uint8_t data) |
| 88 | { | 107 | { |
| 89 | if (!print_enable) return; | ||
| 90 | for (int i = 7; i >= 0; i--) { | 108 | for (int i = 7; i >= 0; i--) { |
| 91 | sendchar((c & (1<<i)) ? '1' : '0'); | 109 | sendchar((data & (1<<i)) ? '1' : '0'); |
| 92 | } | 110 | } |
| 93 | } | 111 | } |
| 94 | 112 | ||
| 95 | void pbin_reverse(unsigned char c) | 113 | void print_bin16(uint16_t data) |
| 114 | { | ||
| 115 | print_bin8(data>>8); | ||
| 116 | print_bin8(data); | ||
| 117 | } | ||
| 118 | |||
| 119 | void print_bin32(uint32_t data) | ||
| 120 | { | ||
| 121 | print_bin8(data>>24); | ||
| 122 | print_bin8(data>>16); | ||
| 123 | print_bin8(data>>8); | ||
| 124 | print_bin8(data); | ||
| 125 | } | ||
| 126 | |||
| 127 | void print_bin_reverse8(uint8_t data) | ||
| 96 | { | 128 | { |
| 97 | if (!print_enable) return; | ||
| 98 | for (int i = 0; i < 8; i++) { | 129 | for (int i = 0; i < 8; i++) { |
| 99 | sendchar((c & (1<<i)) ? '1' : '0'); | 130 | sendchar((data & (1<<i)) ? '1' : '0'); |
| 100 | } | 131 | } |
| 101 | } | 132 | } |
| 133 | |||
| 134 | void print_bin_reverse16(uint16_t data) | ||
| 135 | { | ||
| 136 | print_bin_reverse8(data); | ||
| 137 | print_bin_reverse8(data>>8); | ||
| 138 | } | ||
| 139 | |||
| 140 | void print_bin_reverse32(uint32_t data) | ||
| 141 | { | ||
| 142 | print_bin_reverse8(data); | ||
| 143 | print_bin_reverse8(data>>8); | ||
| 144 | print_bin_reverse8(data>>16); | ||
| 145 | print_bin_reverse8(data>>24); | ||
| 146 | } | ||
diff --git a/common/print.h b/common/print.h index 1c4567862..3a949ba05 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 |
| @@ -36,18 +37,57 @@ | |||
| 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 | #define phex(data) print_hex8(data) | ||
| 43 | #define phex16(data) print_hex16(data) | ||
| 44 | #define pdec(data) print_dec8(data) | ||
| 45 | #define pdec16(data) print_dec16(data) | ||
| 46 | #define pbin(data) print_bin8(data) | ||
| 47 | #define pbin16(data) print_bin16(data) | ||
| 48 | #define pbin_reverse(data) print_bin_reverse8(data) | ||
| 49 | #define pbin_reverse16(data) print_bin_reverse16(data) | ||
| 50 | |||
| 51 | |||
| 52 | /* print value utility */ | ||
| 53 | #define pv_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) | ||
| 54 | #define pv_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) | ||
| 55 | #define pv_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) | ||
| 56 | #define pv_dec8(v) do { print_P(PSTR(#v ": ")); print_dec8(v); print_P(PSTR("\n")); } while (0) | ||
| 57 | #define pv_dec16(v) do { print_P(PSTR(#v ": ")); print_dec16(v); print_P(PSTR("\n")); } while (0) | ||
| 58 | #define pv_dec32(v) do { print_P(PSTR(#v ": ")); print_dec32(v); print_P(PSTR("\n")); } while (0) | ||
| 59 | #define pv_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) | ||
| 60 | #define pv_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) | ||
| 61 | #define pv_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) | ||
| 62 | #define pv_bin_reverse8(v) do { print_P(PSTR(#v ": ")); print_bin_reverse8(v); print_P(PSTR("\n")); } while (0) | ||
| 63 | #define pv_bin_reverse16(v) do { print_P(PSTR(#v ": ")); print_bin_reverse16(v); print_P(PSTR("\n")); } while (0) | ||
| 64 | #define pv_bin_reverse32(v) do { print_P(PSTR(#v ": ")); print_bin_reverse32(v); print_P(PSTR("\n")); } while (0) | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 39 | #ifdef __cplusplus | 68 | #ifdef __cplusplus |
| 40 | extern "C" { | 69 | extern "C" { |
| 41 | #endif | 70 | #endif |
| 71 | |||
| 72 | /* function pointer of sendchar to be used by print utility */ | ||
| 73 | extern int8_t (*print_sendchar_func)(uint8_t); | ||
| 42 | extern bool print_enable; | 74 | extern bool print_enable; |
| 43 | 75 | ||
| 76 | /* print string stored in data memory(SRAM) */ | ||
| 44 | void print_S(const char *s); | 77 | void print_S(const char *s); |
| 78 | /* print string stored in program memory(FLASH) */ | ||
| 45 | void print_P(const char *s); | 79 | void print_P(const char *s); |
| 46 | void phex(unsigned char c); | 80 | |
| 47 | void phex16(unsigned int i); | 81 | void print_hex8(uint8_t data); |
| 48 | void pdec(uint8_t i); | 82 | void print_hex16(uint16_t data); |
| 49 | void pbin(unsigned char c); | 83 | void print_hex32(uint32_t data); |
| 50 | void pbin_reverse(unsigned char c); | 84 | void print_dec8(uint8_t data); |
| 85 | void print_dec16(uint16_t data); | ||
| 86 | void print_bin8(uint8_t data); | ||
| 87 | void print_bin16(uint16_t data); | ||
| 88 | void print_bin_reverse8(uint8_t data); | ||
| 89 | void print_bin_reverse16(uint16_t data); | ||
| 90 | |||
| 51 | #ifdef __cplusplus | 91 | #ifdef __cplusplus |
| 52 | } | 92 | } |
| 53 | #endif | 93 | #endif |
