From ad24858e4fec8bb9af9d89ebf42cda3fffcfdff5 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 23 Oct 2012 02:14:36 +0900 Subject: [PATCH 1/2] Add print utility --- common/command.c | 51 +++++++++--------- common/keyboard.c | 6 ++- common/print.c | 129 +++++++++++++++++++++++++++++++--------------- common/print.h | 50 ++++++++++++++++-- 4 files changed, 163 insertions(+), 73 deletions(-) diff --git a/common/command.c b/common/command.c index 8e2e21a7..85cc0573 100644 --- a/common/command.c +++ b/common/command.c @@ -205,7 +205,7 @@ static bool command_common(uint8_t code) print("VERSION: " STR(DEVICE_VER) "\n"); break; case KC_T: // print timer - print("timer: "); phex16(timer_count>>16); phex16(timer_count); print("\n"); + pv_hex32(timer_count); break; case KC_P: // print toggle if (print_enable) { @@ -218,20 +218,20 @@ static bool command_common(uint8_t code) break; case KC_S: print("\n\n----- Status -----\n"); - print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n"); + pv_hex8(host_keyboard_leds()); #ifdef HOST_PJRC - print("UDCON: "); phex(UDCON); print("\n"); - print("UDIEN: "); phex(UDIEN); print("\n"); - print("UDINT: "); phex(UDINT); print("\n"); - print("usb_keyboard_leds:"); phex(usb_keyboard_leds); print("\n"); - print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol); print("\n"); - print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n"); - print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n"); + pv_hex8(UDCON); + pv_hex8(UDIEN); + pv_hex8(UDINT); + pv_hex8(usb_keyboard_leds); + pv_hex8(usb_keyboard_protocol); + pv_hex8(usb_keyboard_idle_config); + pv_hex8(usb_keyboard_idle_count); #endif #ifdef HOST_VUSB # if USB_COUNT_SOF - print("usbSofCount: "); phex(usbSofCount); print("\n"); + pv_hex8(usbSofCount); # endif #endif break; @@ -350,6 +350,7 @@ static void mousekey_param_print(void) print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); } +#define PRINT_SET_VAL(v) print(#v " = "); print_dec8(v); print("\n"); static void mousekey_param_inc(uint8_t param, uint8_t inc) { switch (param) { @@ -358,42 +359,42 @@ static void mousekey_param_inc(uint8_t param, uint8_t inc) mk_delay += inc; else mk_delay = UINT8_MAX; - print("mk_delay = "); pdec(mk_delay); print("\n"); + PRINT_SET_VAL(mk_delay); break; case 2: if (mk_interval + inc < UINT8_MAX) mk_interval += inc; else mk_interval = UINT8_MAX; - print("mk_interval = "); pdec(mk_interval); print("\n"); + PRINT_SET_VAL(mk_interval); break; case 3: if (mk_max_speed + inc < UINT8_MAX) mk_max_speed += inc; else mk_max_speed = UINT8_MAX; - print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); + PRINT_SET_VAL(mk_max_speed); break; case 4: if (mk_time_to_max + inc < UINT8_MAX) mk_time_to_max += inc; else mk_time_to_max = UINT8_MAX; - print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); + PRINT_SET_VAL(mk_time_to_max); break; case 5: if (mk_wheel_max_speed + inc < UINT8_MAX) mk_wheel_max_speed += inc; else mk_wheel_max_speed = UINT8_MAX; - print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); + PRINT_SET_VAL(mk_wheel_max_speed); break; case 6: if (mk_wheel_time_to_max + inc < UINT8_MAX) mk_wheel_time_to_max += inc; else mk_wheel_time_to_max = UINT8_MAX; - print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); + PRINT_SET_VAL(mk_wheel_time_to_max); break; } } @@ -406,42 +407,42 @@ static void mousekey_param_dec(uint8_t param, uint8_t dec) mk_delay -= dec; else mk_delay = 0; - print("mk_delay = "); pdec(mk_delay); print("\n"); + PRINT_SET_VAL(mk_delay); break; case 2: if (mk_interval > dec) mk_interval -= dec; else mk_interval = 0; - print("mk_interval = "); pdec(mk_interval); print("\n"); + PRINT_SET_VAL(mk_interval); break; case 3: if (mk_max_speed > dec) mk_max_speed -= dec; else mk_max_speed = 0; - print("mk_max_speed = "); pdec(mk_max_speed); print("\n"); + PRINT_SET_VAL(mk_max_speed); break; case 4: if (mk_time_to_max > dec) mk_time_to_max -= dec; else mk_time_to_max = 0; - print("mk_time_to_max = "); pdec(mk_time_to_max); print("\n"); + PRINT_SET_VAL(mk_time_to_max); break; case 5: if (mk_wheel_max_speed > dec) mk_wheel_max_speed -= dec; else mk_wheel_max_speed = 0; - print("mk_wheel_max_speed = "); pdec(mk_wheel_max_speed); print("\n"); + PRINT_SET_VAL(mk_wheel_max_speed); break; case 6: if (mk_wheel_time_to_max > dec) mk_wheel_time_to_max -= dec; else mk_wheel_time_to_max = 0; - print("mk_wheel_time_to_max = "); pdec(mk_wheel_time_to_max); print("\n"); + PRINT_SET_VAL(mk_wheel_time_to_max); break; } } @@ -551,11 +552,11 @@ static uint8_t numkey2num(uint8_t code) static void switch_layer(uint8_t layer) { - print("current_layer: "); phex(current_layer); print("\n"); - print("default_layer: "); phex(default_layer); print("\n"); + pv_hex8(current_layer); + pv_hex8(default_layer); current_layer = layer; default_layer = layer; - print("switch to Layer: "); phex(layer); print("\n"); + print("switch to "); pv_hex8(layer); } static void clear_keyboard(void) diff --git a/common/keyboard.c b/common/keyboard.c index b0e0ed79..bda7c062 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -1,5 +1,5 @@ /* -Copyright 2011 Jun Wako +Copyright 2011,2012 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ along with this program. If not, see . #include "debug.h" #include "command.h" #include "util.h" +#include "sendchar.h" #ifdef MOUSEKEY_ENABLE #include "mousekey.h" #endif @@ -545,6 +546,9 @@ void keyboard_init(void) { debug_keyboard = true; + // TODO: configuration of sendchar impl + print_sendchar_func = sendchar; + timer_init(); matrix_init(); #ifdef PS2_MOUSE_ENABLE diff --git a/common/print.c b/common/print.c index 4e36d393..dd73ff59 100644 --- a/common/print.c +++ b/common/print.c @@ -1,3 +1,4 @@ +/* Copyright 2012 Jun Wako */ /* Very basic print functions, intended to be used with usb_debug_only.c * http://www.pjrc.com/teensy/ * Copyright (c) 2008 PJRC.COM, LLC @@ -21,81 +22,125 @@ * THE SOFTWARE. */ +#include #include #include #include "print.h" -#include "sendchar.h" +#define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0) +int8_t (*print_sendchar_func)(uint8_t) = NULL; bool print_enable = false; +/* print string stored in data memory(SRAM) + * print_P("hello world"); + * This consumes precious SRAM memory space for string. + */ void print_S(const char *s) { - if (!print_enable) return; - char c; - - while (1) { - c = *s++; - if (!c) break; - if (c == '\n') sendchar('\r'); - sendchar(c); - } + uint8_t c; + while (1) { + c = *s++; + if (!c) break; + if (c == '\n') sendchar('\r'); + sendchar(c); + } } +/* print string stored in program memory(FLASH) + * print_P(PSTR("hello world"); + * This consumes relatively abundant FLASH memory area not SRAM. + */ void print_P(const char *s) { - if (!print_enable) return; - char c; - - while (1) { - c = pgm_read_byte(s++); - if (!c) break; - if (c == '\n') sendchar('\r'); - sendchar(c); - } + uint8_t c; + while (1) { + c = pgm_read_byte(s++); + if (!c) break; + if (c == '\n') sendchar('\r'); + sendchar(c); + } } -void phex1(unsigned char c) +static inline +void print_hex4(uint8_t data) { - if (!print_enable) return; - sendchar(c + ((c < 10) ? '0' : 'A' - 10)); + sendchar(data + ((data < 10) ? '0' : 'A' - 10)); } -void phex(unsigned char c) +void print_hex8(uint8_t data) { - if (!print_enable) return; - phex1(c >> 4); - phex1(c & 15); + print_hex4(data>>4); + print_hex4(data&0x0F); } -void phex16(unsigned int i) +void print_hex16(uint16_t data) { - if (!print_enable) return; - phex(i >> 8); - phex(i); + print_hex8(data>>8); + print_hex8(data); } -void pdec(uint8_t i) +void print_hex32(uint32_t data) { - if (!print_enable) return; - if (i/100) sendchar('0' + (i/100)); - if (i/100 || i%100/10) sendchar('0' + (i%100/10)); - sendchar('0' + (i%10)); + print_hex16(data>>16); + print_hex16(data); } - -void pbin(unsigned char c) +void print_dec8(uint8_t data) +{ + if (data/100) sendchar('0' + (data/100)); + if (data/100 || data%100/10) sendchar('0' + (data%100/10)); + sendchar('0' + (data%10)); +} + +void print_dec16(uint16_t data) +{ + // TODO +} + +void print_dec32(uint32_t data) +{ + // TODO +} + +void print_bin(uint8_t data) { - if (!print_enable) return; for (int i = 7; i >= 0; i--) { - sendchar((c & (1<>8); + print_bin8(data); +} + +void print_bin32(uint32_t data) +{ + print_bin8(data>>24); + print_bin8(data>>16); + print_bin8(data>>8); + print_bin8(data); +} + +void print_bin_reverse8(uint8_t data) { - if (!print_enable) return; for (int i = 0; i < 8; i++) { - sendchar((c & (1<>8); +} + +void print_bin_reverse32(uint32_t data) +{ + print_bin_reverse8(data); + print_bin_reverse8(data>>8); + print_bin_reverse8(data>>16); + print_bin_reverse8(data>>24); +} diff --git a/common/print.h b/common/print.h index 1c456786..3a949ba0 100644 --- a/common/print.h +++ b/common/print.h @@ -1,3 +1,4 @@ +/* Copyright 2012 Jun Wako */ /* Very basic print functions, intended to be used with usb_debug_only.c * http://www.pjrc.com/teensy/ * Copyright (c) 2008 PJRC.COM, LLC @@ -36,18 +37,57 @@ #define print(s) print_P(PSTR(s)) #endif +#define println(s) print_P(PSTR(s "\n")) + +#define phex(data) print_hex8(data) +#define phex16(data) print_hex16(data) +#define pdec(data) print_dec8(data) +#define pdec16(data) print_dec16(data) +#define pbin(data) print_bin8(data) +#define pbin16(data) print_bin16(data) +#define pbin_reverse(data) print_bin_reverse8(data) +#define pbin_reverse16(data) print_bin_reverse16(data) + + +/* print value utility */ +#define pv_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) +#define pv_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) +#define pv_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) +#define pv_dec8(v) do { print_P(PSTR(#v ": ")); print_dec8(v); print_P(PSTR("\n")); } while (0) +#define pv_dec16(v) do { print_P(PSTR(#v ": ")); print_dec16(v); print_P(PSTR("\n")); } while (0) +#define pv_dec32(v) do { print_P(PSTR(#v ": ")); print_dec32(v); print_P(PSTR("\n")); } while (0) +#define pv_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) +#define pv_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) +#define pv_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) +#define pv_bin_reverse8(v) do { print_P(PSTR(#v ": ")); print_bin_reverse8(v); print_P(PSTR("\n")); } while (0) +#define pv_bin_reverse16(v) do { print_P(PSTR(#v ": ")); print_bin_reverse16(v); print_P(PSTR("\n")); } while (0) +#define pv_bin_reverse32(v) do { print_P(PSTR(#v ": ")); print_bin_reverse32(v); print_P(PSTR("\n")); } while (0) + + + #ifdef __cplusplus extern "C" { #endif + +/* function pointer of sendchar to be used by print utility */ +extern int8_t (*print_sendchar_func)(uint8_t); extern bool print_enable; +/* print string stored in data memory(SRAM) */ void print_S(const char *s); +/* print string stored in program memory(FLASH) */ void print_P(const char *s); -void phex(unsigned char c); -void phex16(unsigned int i); -void pdec(uint8_t i); -void pbin(unsigned char c); -void pbin_reverse(unsigned char c); + +void print_hex8(uint8_t data); +void print_hex16(uint16_t data); +void print_hex32(uint32_t data); +void print_dec8(uint8_t data); +void print_dec16(uint16_t data); +void print_bin8(uint8_t data); +void print_bin16(uint16_t data); +void print_bin_reverse8(uint8_t data); +void print_bin_reverse16(uint16_t data); + #ifdef __cplusplus } #endif From 220de27bed198c2ea27886986de7afd8013d5545 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 25 Oct 2012 03:28:25 +0900 Subject: [PATCH 2/2] Add print_dec() and debug_dec(). --- common/command.c | 31 ++++++++++----------- common/debug.c | 1 - common/debug.h | 35 ++++++++++++++++++----- common/mousekey.c | 12 ++++---- common/print.c | 71 +++++++++++++++++++++++++++++++++++------------ common/print.h | 47 +++++++++++++++++++------------ 6 files changed, 130 insertions(+), 67 deletions(-) diff --git a/common/command.c b/common/command.c index 85cc0573..a06e6a00 100644 --- a/common/command.c +++ b/common/command.c @@ -164,9 +164,6 @@ static bool command_common(uint8_t code) debug_enable = false; } else { print("\nDEBUG: enabled.\n"); - debug_matrix = true; - debug_keyboard = true; - debug_mouse = true; debug_enable = true; } break; @@ -205,7 +202,7 @@ static bool command_common(uint8_t code) print("VERSION: " STR(DEVICE_VER) "\n"); break; case KC_T: // print timer - pv_hex32(timer_count); + print_val_hex32(timer_count); break; case KC_P: // print toggle if (print_enable) { @@ -218,20 +215,20 @@ static bool command_common(uint8_t code) break; case KC_S: print("\n\n----- Status -----\n"); - pv_hex8(host_keyboard_leds()); + print_val_hex8(host_keyboard_leds()); #ifdef HOST_PJRC - pv_hex8(UDCON); - pv_hex8(UDIEN); - pv_hex8(UDINT); - pv_hex8(usb_keyboard_leds); - pv_hex8(usb_keyboard_protocol); - pv_hex8(usb_keyboard_idle_config); - pv_hex8(usb_keyboard_idle_count); + print_val_hex8(UDCON); + print_val_hex8(UDIEN); + print_val_hex8(UDINT); + print_val_hex8(usb_keyboard_leds); + print_val_hex8(usb_keyboard_protocol); + print_val_hex8(usb_keyboard_idle_config); + print_val_hex8(usb_keyboard_idle_count); #endif #ifdef HOST_VUSB # if USB_COUNT_SOF - pv_hex8(usbSofCount); + print_val_hex8(usbSofCount); # endif #endif break; @@ -350,7 +347,7 @@ static void mousekey_param_print(void) print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); } -#define PRINT_SET_VAL(v) print(#v " = "); print_dec8(v); print("\n"); +#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n"); static void mousekey_param_inc(uint8_t param, uint8_t inc) { switch (param) { @@ -552,11 +549,11 @@ static uint8_t numkey2num(uint8_t code) static void switch_layer(uint8_t layer) { - pv_hex8(current_layer); - pv_hex8(default_layer); + print_val_hex8(current_layer); + print_val_hex8(default_layer); current_layer = layer; default_layer = layer; - print("switch to "); pv_hex8(layer); + print("switch to "); print_val_hex8(layer); } static void clear_keyboard(void) diff --git a/common/debug.c b/common/debug.c index 41d566ee..e406d39b 100644 --- a/common/debug.c +++ b/common/debug.c @@ -6,4 +6,3 @@ bool debug_enable = false; bool debug_matrix = false; bool debug_keyboard = false; bool debug_mouse = false; - diff --git a/common/debug.h b/common/debug.h index 1d56e21f..c12f2cb0 100644 --- a/common/debug.h +++ b/common/debug.h @@ -22,13 +22,34 @@ along with this program. If not, see . #include "print.h" -#define debug(s) if(debug_enable) print_P(PSTR(s)) -#define debug_P(s) if(debug_enable) print_P(s) -#define debug_S(s) if(debug_enable) print_S(s) -#define debug_hex(c) if(debug_enable) phex(c) -#define debug_hex16(i) if(debug_enable) phex16(i) -#define debug_bin(c) if(debug_enable) pbin(c) -#define debug_bin_reverse(c) if(debug_enable) pbin_reverse(c) +#define debug(s) do { if (debug_enable) print(s); } while (0) +#define debugln(s) do { if (debug_enable) println(s); } while (0) +#define debug_S(s) do { if (debug_enable) print_S(s); } while (0) +#define debug_P(s) do { if (debug_enable) print_P(s); } while (0) +#define debug_msg(s) do { \ + if (debug_enable) { \ + print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ + } \ +} while (0) + + + +#define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0) +#define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0) +#define debug_hex8(data) do { if (debug_enable) print_hex8(data); } while (0) +#define debug_hex16(data) do { if (debug_enable) print_hex16(data); } while (0) +#define debug_hex32(data) do { if (debug_enable) print_hex32(data); } while (0) +#define debug_bin8(data) do { if (debug_enable) print_bin8(data); } while (0) +#define debug_bin16(data) do { if (debug_enable) print_bin16(data); } while (0) +#define debug_bin32(data) do { if (debug_enable) print_bin32(data); } while (0) +#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0) +#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0) +#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0) + +#define debug_dec(data) debug_dec(data) +#define debug_hex(data) debug_hex8(data) +#define debug_bin(data) debug_bin8(data) +#define debug_bin_reverse(data) debug_bin8(data) #ifdef __cplusplus diff --git a/common/mousekey.c b/common/mousekey.c index d26b2630..3068fc5e 100644 --- a/common/mousekey.c +++ b/common/mousekey.c @@ -187,10 +187,10 @@ static void mousekey_debug(void) if (!debug_mouse) return; print("mousekey [btn|x y v h](rep/acl): ["); phex(mouse_report.buttons); print("|"); - phex(mouse_report.x); print(" "); - phex(mouse_report.y); print(" "); - phex(mouse_report.v); print(" "); - phex(mouse_report.h); print("]("); - phex(mousekey_repeat); print("/"); - phex(mousekey_accel); print(")\n"); + print_decs(mouse_report.x); print(" "); + print_decs(mouse_report.y); print(" "); + print_decs(mouse_report.v); print(" "); + print_decs(mouse_report.h); print("]("); + print_dec(mousekey_repeat); print("/"); + print_dec(mousekey_accel); print(")\n"); } diff --git a/common/print.c b/common/print.c index dd73ff59..6a8a725b 100644 --- a/common/print.c +++ b/common/print.c @@ -22,16 +22,18 @@ * THE SOFTWARE. */ -#include #include #include #include "print.h" + + #define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0) -int8_t (*print_sendchar_func)(uint8_t) = NULL; +int8_t (*print_sendchar_func)(uint8_t) = 0; bool print_enable = false; + /* print string stored in data memory(SRAM) * print_P("hello world"); * This consumes precious SRAM memory space for string. @@ -62,6 +64,55 @@ void print_P(const char *s) } } +void print_CRLF(void) +{ + sendchar('\r'); sendchar('\n'); +} + + +#define SIGNED 0x80 +#define BIN 2 +#define OCT 8 +#define DEC 10 +#define HEX 16 + +static inline +char itoc(uint8_t i) +{ + return (i < 10 ? '0' + i : 'A' + i - 10); +} + +static inline +void print_int(uint16_t data, uint8_t base) +{ + char buf[7] = {'\0'}; + char *p = &buf[6]; + if ((base & SIGNED) && (data & 0x8000)) { + data = -data; + buf[0] = '-'; + } + base &= ~SIGNED; + uint16_t n; + do { + n = data; + data /= base; + *(--p) = itoc(n - data*base); + } while (data); + if (buf[0]) *(--p) = buf[0]; + print_S(p); +} + +void print_dec(uint16_t data) +{ + print_int(data, DEC); +} + +void print_decs(int16_t data) +{ + print_int(data, DEC|SIGNED); +} + + static inline void print_hex4(uint8_t data) { @@ -86,22 +137,6 @@ void print_hex32(uint32_t data) print_hex16(data); } -void print_dec8(uint8_t data) -{ - if (data/100) sendchar('0' + (data/100)); - if (data/100 || data%100/10) sendchar('0' + (data%100/10)); - sendchar('0' + (data%10)); -} - -void print_dec16(uint16_t data) -{ - // TODO -} - -void print_dec32(uint32_t data) -{ - // TODO -} void print_bin(uint8_t data) { diff --git a/common/print.h b/common/print.h index 3a949ba0..9c31b24a 100644 --- a/common/print.h +++ b/common/print.h @@ -34,15 +34,16 @@ #ifndef __cplusplus // this macro allows you to write print("some text") and // the string is automatically placed into flash memory :) -#define print(s) print_P(PSTR(s)) +#define print(s) print_P(PSTR(s)) #endif -#define println(s) print_P(PSTR(s "\n")) +#define println(s) print_P(PSTR(s "\n")) +/* for old name */ +#define pdec(data) print_dec(data) +#define pdec16(data) print_dec(data) #define phex(data) print_hex8(data) #define phex16(data) print_hex16(data) -#define pdec(data) print_dec8(data) -#define pdec16(data) print_dec16(data) #define pbin(data) print_bin8(data) #define pbin16(data) print_bin16(data) #define pbin_reverse(data) print_bin_reverse8(data) @@ -50,18 +51,19 @@ /* print value utility */ -#define pv_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) -#define pv_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) -#define pv_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) -#define pv_dec8(v) do { print_P(PSTR(#v ": ")); print_dec8(v); print_P(PSTR("\n")); } while (0) -#define pv_dec16(v) do { print_P(PSTR(#v ": ")); print_dec16(v); print_P(PSTR("\n")); } while (0) -#define pv_dec32(v) do { print_P(PSTR(#v ": ")); print_dec32(v); print_P(PSTR("\n")); } while (0) -#define pv_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) -#define pv_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) -#define pv_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) -#define pv_bin_reverse8(v) do { print_P(PSTR(#v ": ")); print_bin_reverse8(v); print_P(PSTR("\n")); } while (0) -#define pv_bin_reverse16(v) do { print_P(PSTR(#v ": ")); print_bin_reverse16(v); print_P(PSTR("\n")); } while (0) -#define pv_bin_reverse32(v) do { print_P(PSTR(#v ": ")); print_bin_reverse32(v); print_P(PSTR("\n")); } while (0) +#define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0) +#define print_val_decs(v) do { print_P(PSTR(#v ": ")); print_decs(v); print_P(PSTR("\n")); } while (0) + +#define print_val_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) +#define print_val_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) +#define print_val_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) + +#define print_val_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) +#define print_val_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) +#define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) +#define print_val_bin_reverse8(v) do { print_P(PSTR(#v ": ")); print_bin_reverse8(v); print_P(PSTR("\n")); } while (0) +#define print_val_bin_reverse16(v) do { print_P(PSTR(#v ": ")); print_bin_reverse16(v); print_P(PSTR("\n")); } while (0) +#define print_val_bin_reverse32(v) do { print_P(PSTR(#v ": ")); print_bin_reverse32(v); print_P(PSTR("\n")); } while (0) @@ -78,15 +80,24 @@ void print_S(const char *s); /* print string stored in program memory(FLASH) */ void print_P(const char *s); +void print_CRLF(void); + +/* decimal */ +void print_dec(uint16_t data); +void print_decs(int16_t data); + +/* hex */ void print_hex8(uint8_t data); void print_hex16(uint16_t data); void print_hex32(uint32_t data); -void print_dec8(uint8_t data); -void print_dec16(uint16_t data); + +/* binary */ void print_bin8(uint8_t data); void print_bin16(uint16_t data); +void print_bin32(uint32_t data); void print_bin_reverse8(uint8_t data); void print_bin_reverse16(uint16_t data); +void print_bin_reverse32(uint32_t data); #ifdef __cplusplus }