diff options
Diffstat (limited to 'common/print.h')
| -rw-r--r-- | common/print.h | 50 |
1 files changed, 45 insertions, 5 deletions
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 |
