diff options
| author | Joel Challis <git@zvecr.com> | 2021-08-03 18:49:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-03 18:49:33 +0100 |
| commit | 34de7ca224d613e1ae19a45860e27c15d40254dd (patch) | |
| tree | 3176aa05dd5175ae1a7a56b5b881fc89c1aa18ef /quantum | |
| parent | 3f419dc872d3ab61d129c644e114f62fd738e9d6 (diff) | |
| download | qmk_firmware-34de7ca224d613e1ae19a45860e27c15d40254dd.tar.gz qmk_firmware-34de7ca224d613e1ae19a45860e27c15d40254dd.zip | |
Move print/debug files to quantum (#12069)
* move print/debug files to quantum
* Update comments
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/logging/debug.c | 25 | ||||
| -rw-r--r-- | quantum/logging/debug.h | 169 | ||||
| -rw-r--r-- | quantum/logging/nodebug.h | 26 | ||||
| -rw-r--r-- | quantum/logging/print.c | 27 | ||||
| -rw-r--r-- | quantum/logging/print.h | 135 | ||||
| -rw-r--r-- | quantum/logging/print.mk | 9 | ||||
| -rw-r--r-- | quantum/logging/sendchar.c | 20 | ||||
| -rw-r--r-- | quantum/logging/sendchar.h | 33 |
8 files changed, 444 insertions, 0 deletions
diff --git a/quantum/logging/debug.c b/quantum/logging/debug.c new file mode 100644 index 000000000..ea62deaa8 --- /dev/null +++ b/quantum/logging/debug.c | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 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 | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include "debug.h" | ||
| 18 | |||
| 19 | debug_config_t debug_config = { | ||
| 20 | .enable = false, // | ||
| 21 | .matrix = false, // | ||
| 22 | .keyboard = false, // | ||
| 23 | .mouse = false, // | ||
| 24 | .reserved = 0 // | ||
| 25 | }; | ||
diff --git a/quantum/logging/debug.h b/quantum/logging/debug.h new file mode 100644 index 000000000..841531035 --- /dev/null +++ b/quantum/logging/debug.h | |||
| @@ -0,0 +1,169 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 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 | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include <stdbool.h> | ||
| 21 | #include "print.h" | ||
| 22 | |||
| 23 | #ifdef __cplusplus | ||
| 24 | extern "C" { | ||
| 25 | #endif | ||
| 26 | |||
| 27 | /* | ||
| 28 | * Debug output control | ||
| 29 | */ | ||
| 30 | typedef union { | ||
| 31 | struct { | ||
| 32 | bool enable : 1; | ||
| 33 | bool matrix : 1; | ||
| 34 | bool keyboard : 1; | ||
| 35 | bool mouse : 1; | ||
| 36 | uint8_t reserved : 4; | ||
| 37 | }; | ||
| 38 | uint8_t raw; | ||
| 39 | } debug_config_t; | ||
| 40 | |||
| 41 | extern debug_config_t debug_config; | ||
| 42 | |||
| 43 | #ifdef __cplusplus | ||
| 44 | } | ||
| 45 | #endif | ||
| 46 | |||
| 47 | /* for backward compatibility */ | ||
| 48 | #define debug_enable (debug_config.enable) | ||
| 49 | #define debug_matrix (debug_config.matrix) | ||
| 50 | #define debug_keyboard (debug_config.keyboard) | ||
| 51 | #define debug_mouse (debug_config.mouse) | ||
| 52 | |||
| 53 | /* | ||
| 54 | * Debug print utils | ||
| 55 | */ | ||
| 56 | #ifndef NO_DEBUG | ||
| 57 | |||
| 58 | # define dprint(s) \ | ||
| 59 | do { \ | ||
| 60 | if (debug_enable) print(s); \ | ||
| 61 | } while (0) | ||
| 62 | # define dprintln(s) \ | ||
| 63 | do { \ | ||
| 64 | if (debug_enable) println(s); \ | ||
| 65 | } while (0) | ||
| 66 | # define dprintf(fmt, ...) \ | ||
| 67 | do { \ | ||
| 68 | if (debug_enable) xprintf(fmt, ##__VA_ARGS__); \ | ||
| 69 | } while (0) | ||
| 70 | # define dmsg(s) dprintf("%s at %d: %s\n", __FILE__, __LINE__, s) | ||
| 71 | |||
| 72 | /* Deprecated. DO NOT USE these anymore, use dprintf instead. */ | ||
| 73 | # define debug(s) \ | ||
| 74 | do { \ | ||
| 75 | if (debug_enable) print(s); \ | ||
| 76 | } while (0) | ||
| 77 | # define debugln(s) \ | ||
| 78 | do { \ | ||
| 79 | if (debug_enable) println(s); \ | ||
| 80 | } while (0) | ||
| 81 | # define debug_msg(s) \ | ||
| 82 | do { \ | ||
| 83 | if (debug_enable) { \ | ||
| 84 | print(__FILE__); \ | ||
| 85 | print(" at "); \ | ||
| 86 | print_dec(__LINE__); \ | ||
| 87 | print(" in "); \ | ||
| 88 | print(": "); \ | ||
| 89 | print(s); \ | ||
| 90 | } \ | ||
| 91 | } while (0) | ||
| 92 | # define debug_dec(data) \ | ||
| 93 | do { \ | ||
| 94 | if (debug_enable) print_dec(data); \ | ||
| 95 | } while (0) | ||
| 96 | # define debug_decs(data) \ | ||
| 97 | do { \ | ||
| 98 | if (debug_enable) print_decs(data); \ | ||
| 99 | } while (0) | ||
| 100 | # define debug_hex4(data) \ | ||
| 101 | do { \ | ||
| 102 | if (debug_enable) print_hex4(data); \ | ||
| 103 | } while (0) | ||
| 104 | # define debug_hex8(data) \ | ||
| 105 | do { \ | ||
| 106 | if (debug_enable) print_hex8(data); \ | ||
| 107 | } while (0) | ||
| 108 | # define debug_hex16(data) \ | ||
| 109 | do { \ | ||
| 110 | if (debug_enable) print_hex16(data); \ | ||
| 111 | } while (0) | ||
| 112 | # define debug_hex32(data) \ | ||
| 113 | do { \ | ||
| 114 | if (debug_enable) print_hex32(data); \ | ||
| 115 | } while (0) | ||
| 116 | # define debug_bin8(data) \ | ||
| 117 | do { \ | ||
| 118 | if (debug_enable) print_bin8(data); \ | ||
| 119 | } while (0) | ||
| 120 | # define debug_bin16(data) \ | ||
| 121 | do { \ | ||
| 122 | if (debug_enable) print_bin16(data); \ | ||
| 123 | } while (0) | ||
| 124 | # define debug_bin32(data) \ | ||
| 125 | do { \ | ||
| 126 | if (debug_enable) print_bin32(data); \ | ||
| 127 | } while (0) | ||
| 128 | # define debug_bin_reverse8(data) \ | ||
| 129 | do { \ | ||
| 130 | if (debug_enable) print_bin_reverse8(data); \ | ||
| 131 | } while (0) | ||
| 132 | # define debug_bin_reverse16(data) \ | ||
| 133 | do { \ | ||
| 134 | if (debug_enable) print_bin_reverse16(data); \ | ||
| 135 | } while (0) | ||
| 136 | # define debug_bin_reverse32(data) \ | ||
| 137 | do { \ | ||
| 138 | if (debug_enable) print_bin_reverse32(data); \ | ||
| 139 | } while (0) | ||
| 140 | # define debug_hex(data) debug_hex8(data) | ||
| 141 | # define debug_bin(data) debug_bin8(data) | ||
| 142 | # define debug_bin_reverse(data) debug_bin8(data) | ||
| 143 | |||
| 144 | #else /* NO_DEBUG */ | ||
| 145 | |||
| 146 | # define dprint(s) | ||
| 147 | # define dprintln(s) | ||
| 148 | # define dprintf(fmt, ...) | ||
| 149 | # define dmsg(s) | ||
| 150 | # define debug(s) | ||
| 151 | # define debugln(s) | ||
| 152 | # define debug_msg(s) | ||
| 153 | # define debug_dec(data) | ||
| 154 | # define debug_decs(data) | ||
| 155 | # define debug_hex4(data) | ||
| 156 | # define debug_hex8(data) | ||
| 157 | # define debug_hex16(data) | ||
| 158 | # define debug_hex32(data) | ||
| 159 | # define debug_bin8(data) | ||
| 160 | # define debug_bin16(data) | ||
| 161 | # define debug_bin32(data) | ||
| 162 | # define debug_bin_reverse8(data) | ||
| 163 | # define debug_bin_reverse16(data) | ||
| 164 | # define debug_bin_reverse32(data) | ||
| 165 | # define debug_hex(data) | ||
| 166 | # define debug_bin(data) | ||
| 167 | # define debug_bin_reverse(data) | ||
| 168 | |||
| 169 | #endif /* NO_DEBUG */ | ||
diff --git a/quantum/logging/nodebug.h b/quantum/logging/nodebug.h new file mode 100644 index 000000000..0b176684b --- /dev/null +++ b/quantum/logging/nodebug.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 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 | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #ifndef NO_DEBUG | ||
| 21 | # define NO_DEBUG | ||
| 22 | # include "debug.h" | ||
| 23 | # undef NO_DEBUG | ||
| 24 | #else | ||
| 25 | # include "debug.h" | ||
| 26 | #endif | ||
diff --git a/quantum/logging/print.c b/quantum/logging/print.c new file mode 100644 index 000000000..e8440e55e --- /dev/null +++ b/quantum/logging/print.c | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 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 | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include <stddef.h> | ||
| 18 | #include "sendchar.h" | ||
| 19 | |||
| 20 | // bind lib/printf to console interface - sendchar | ||
| 21 | |||
| 22 | static int8_t null_sendchar_func(uint8_t c) { return 0; } | ||
| 23 | static sendchar_func_t func = null_sendchar_func; | ||
| 24 | |||
| 25 | void print_set_sendchar(sendchar_func_t send) { func = send; } | ||
| 26 | |||
| 27 | void _putchar(char character) { func(character); } | ||
diff --git a/quantum/logging/print.h b/quantum/logging/print.h new file mode 100644 index 000000000..8c055f549 --- /dev/null +++ b/quantum/logging/print.h | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | /* Copyright 2012 Jun Wako <wakojun@gmail.com> */ | ||
| 2 | /* Very basic print functions, intended to be used with usb_debug_only.c | ||
| 3 | * http://www.pjrc.com/teensy/ | ||
| 4 | * Copyright (c) 2008 PJRC.COM, LLC | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | * in the Software without restriction, including without limitation the rights | ||
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | * furnished to do so, subject to the following conditions: | ||
| 12 | * | ||
| 13 | * The above copyright notice and this permission notice shall be included in | ||
| 14 | * all copies or substantial portions of the Software. | ||
| 15 | * | ||
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 22 | * THE SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #pragma once | ||
| 26 | |||
| 27 | #include <stdint.h> | ||
| 28 | #include <stdbool.h> | ||
| 29 | #include "util.h" | ||
| 30 | #include "sendchar.h" | ||
| 31 | #include "progmem.h" | ||
| 32 | |||
| 33 | void print_set_sendchar(sendchar_func_t func); | ||
| 34 | |||
| 35 | #ifndef NO_PRINT | ||
| 36 | # if __has_include_next("_print.h") | ||
| 37 | # include_next "_print.h" /* Include the platforms print.h */ | ||
| 38 | # else | ||
| 39 | // Fall back to lib/printf | ||
| 40 | # include "printf.h" // lib/printf/printf.h | ||
| 41 | |||
| 42 | // Create user & normal print defines | ||
| 43 | # define print(s) printf(s) | ||
| 44 | # define println(s) printf(s "\r\n") | ||
| 45 | # define xprintf printf | ||
| 46 | # define uprint(s) printf(s) | ||
| 47 | # define uprintln(s) printf(s "\r\n") | ||
| 48 | # define uprintf printf | ||
| 49 | |||
| 50 | # endif /* __has_include_next("_print.h") */ | ||
| 51 | #else /* NO_PRINT */ | ||
| 52 | # undef xprintf | ||
| 53 | // Remove print defines | ||
| 54 | # define print(s) | ||
| 55 | # define println(s) | ||
| 56 | # define xprintf(fmt, ...) | ||
| 57 | # define uprintf(fmt, ...) | ||
| 58 | # define uprint(s) | ||
| 59 | # define uprintln(s) | ||
| 60 | |||
| 61 | #endif /* NO_PRINT */ | ||
| 62 | |||
| 63 | #ifdef USER_PRINT | ||
| 64 | // Remove normal print defines | ||
| 65 | # undef print | ||
| 66 | # undef println | ||
| 67 | # undef xprintf | ||
| 68 | # define print(s) | ||
| 69 | # define println(s) | ||
| 70 | # define xprintf(fmt, ...) | ||
| 71 | #endif | ||
| 72 | |||
| 73 | #define print_dec(i) xprintf("%u", i) | ||
| 74 | #define print_decs(i) xprintf("%d", i) | ||
| 75 | /* hex */ | ||
| 76 | #define print_hex4(i) xprintf("%X", i) | ||
| 77 | #define print_hex8(i) xprintf("%02X", i) | ||
| 78 | #define print_hex16(i) xprintf("%04X", i) | ||
| 79 | #define print_hex32(i) xprintf("%08lX", i) | ||
| 80 | /* binary */ | ||
| 81 | #define print_bin4(i) xprintf("%04b", i) | ||
| 82 | #define print_bin8(i) xprintf("%08b", i) | ||
| 83 | #define print_bin16(i) xprintf("%016b", i) | ||
| 84 | #define print_bin32(i) xprintf("%032lb", i) | ||
| 85 | #define print_bin_reverse8(i) xprintf("%08b", bitrev(i)) | ||
| 86 | #define print_bin_reverse16(i) xprintf("%016b", bitrev16(i)) | ||
| 87 | #define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i)) | ||
| 88 | /* print value utility */ | ||
| 89 | #define print_val_dec(v) xprintf(#v ": %u\n", v) | ||
| 90 | #define print_val_decs(v) xprintf(#v ": %d\n", v) | ||
| 91 | #define print_val_hex8(v) xprintf(#v ": %X\n", v) | ||
| 92 | #define print_val_hex16(v) xprintf(#v ": %02X\n", v) | ||
| 93 | #define print_val_hex32(v) xprintf(#v ": %04lX\n", v) | ||
| 94 | #define print_val_bin8(v) xprintf(#v ": %08b\n", v) | ||
| 95 | #define print_val_bin16(v) xprintf(#v ": %016b\n", v) | ||
| 96 | #define print_val_bin32(v) xprintf(#v ": %032lb\n", v) | ||
| 97 | #define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v)) | ||
| 98 | #define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v)) | ||
| 99 | #define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v)) | ||
| 100 | |||
| 101 | // User print disables the normal print messages in the body of QMK/TMK code and | ||
| 102 | // is meant as a lightweight alternative to NOPRINT. Use it when you only want to do | ||
| 103 | // a spot of debugging but lack flash resources for allowing all of the codebase to | ||
| 104 | // print (and store their wasteful strings). | ||
| 105 | // | ||
| 106 | // !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!! | ||
| 107 | |||
| 108 | /* decimal */ | ||
| 109 | #define uprint_dec(i) uprintf("%u", i) | ||
| 110 | #define uprint_decs(i) uprintf("%d", i) | ||
| 111 | /* hex */ | ||
| 112 | #define uprint_hex4(i) uprintf("%X", i) | ||
| 113 | #define uprint_hex8(i) uprintf("%02X", i) | ||
| 114 | #define uprint_hex16(i) uprintf("%04X", i) | ||
| 115 | #define uprint_hex32(i) uprintf("%08lX", i) | ||
| 116 | /* binary */ | ||
| 117 | #define uprint_bin4(i) uprintf("%04b", i) | ||
| 118 | #define uprint_bin8(i) uprintf("%08b", i) | ||
| 119 | #define uprint_bin16(i) uprintf("%016b", i) | ||
| 120 | #define uprint_bin32(i) uprintf("%032lb", i) | ||
| 121 | #define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i)) | ||
| 122 | #define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i)) | ||
| 123 | #define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i)) | ||
| 124 | /* print value utility */ | ||
| 125 | #define uprint_val_dec(v) uprintf(#v ": %u\n", v) | ||
| 126 | #define uprint_val_decs(v) uprintf(#v ": %d\n", v) | ||
| 127 | #define uprint_val_hex8(v) uprintf(#v ": %X\n", v) | ||
| 128 | #define uprint_val_hex16(v) uprintf(#v ": %02X\n", v) | ||
| 129 | #define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v) | ||
| 130 | #define uprint_val_bin8(v) uprintf(#v ": %08b\n", v) | ||
| 131 | #define uprint_val_bin16(v) uprintf(#v ": %016b\n", v) | ||
| 132 | #define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v) | ||
| 133 | #define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v)) | ||
| 134 | #define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v)) | ||
| 135 | #define uprint_val_bin_reverse32(v) uprintf(#v ": %032lb\n", bitrev32(v)) | ||
diff --git a/quantum/logging/print.mk b/quantum/logging/print.mk new file mode 100644 index 000000000..67c004192 --- /dev/null +++ b/quantum/logging/print.mk | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | PRINTF_PATH = $(LIB_PATH)/printf | ||
| 2 | |||
| 3 | VPATH += $(PRINTF_PATH) | ||
| 4 | SRC += $(PRINTF_PATH)/printf.c | ||
| 5 | QUANTUM_SRC +=$(QUANTUM_DIR)/logging/print.c | ||
| 6 | OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT | ||
| 7 | OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL | ||
| 8 | OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG | ||
| 9 | OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T | ||
diff --git a/quantum/logging/sendchar.c b/quantum/logging/sendchar.c new file mode 100644 index 000000000..9422382f6 --- /dev/null +++ b/quantum/logging/sendchar.c | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 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 | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include "sendchar.h" | ||
| 18 | |||
| 19 | /* default noop "null" implementation */ | ||
| 20 | __attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; } | ||
diff --git a/quantum/logging/sendchar.h b/quantum/logging/sendchar.h new file mode 100644 index 000000000..edcddaa6b --- /dev/null +++ b/quantum/logging/sendchar.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 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 | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include <stdint.h> | ||
| 21 | |||
| 22 | #ifdef __cplusplus | ||
| 23 | extern "C" { | ||
| 24 | #endif | ||
| 25 | |||
| 26 | typedef int8_t (*sendchar_func_t)(uint8_t c); | ||
| 27 | |||
| 28 | /* transmit a character. return 0 on success, -1 on error. */ | ||
| 29 | int8_t sendchar(uint8_t c); | ||
| 30 | |||
| 31 | #ifdef __cplusplus | ||
| 32 | } | ||
| 33 | #endif | ||
