From 34de7ca224d613e1ae19a45860e27c15d40254dd Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 3 Aug 2021 18:49:33 +0100 Subject: Move print/debug files to quantum (#12069) * move print/debug files to quantum * Update comments --- build_test.mk | 2 +- common_features.mk | 10 ++- quantum/logging/debug.c | 25 ++++++ quantum/logging/debug.h | 169 ++++++++++++++++++++++++++++++++++++++++ quantum/logging/nodebug.h | 26 +++++++ quantum/logging/print.c | 27 +++++++ quantum/logging/print.h | 135 ++++++++++++++++++++++++++++++++ quantum/logging/print.mk | 9 +++ quantum/logging/sendchar.c | 20 +++++ quantum/logging/sendchar.h | 33 ++++++++ tmk_core/common.mk | 13 +--- tmk_core/common/debug.c | 25 ------ tmk_core/common/debug.h | 169 ---------------------------------------- tmk_core/common/lib_printf.mk | 9 --- tmk_core/common/nodebug.h | 26 ------- tmk_core/common/print.h | 135 -------------------------------- tmk_core/common/printf.c | 27 ------- tmk_core/common/sendchar.h | 33 -------- tmk_core/common/sendchar_null.c | 19 ----- tmk_core/common/sendchar_uart.c | 23 ------ 20 files changed, 458 insertions(+), 477 deletions(-) create mode 100644 quantum/logging/debug.c create mode 100644 quantum/logging/debug.h create mode 100644 quantum/logging/nodebug.h create mode 100644 quantum/logging/print.c create mode 100644 quantum/logging/print.h create mode 100644 quantum/logging/print.mk create mode 100644 quantum/logging/sendchar.c create mode 100644 quantum/logging/sendchar.h delete mode 100644 tmk_core/common/debug.c delete mode 100644 tmk_core/common/debug.h delete mode 100644 tmk_core/common/lib_printf.mk delete mode 100644 tmk_core/common/nodebug.h delete mode 100644 tmk_core/common/print.h delete mode 100644 tmk_core/common/printf.c delete mode 100644 tmk_core/common/sendchar.h delete mode 100644 tmk_core/common/sendchar_null.c delete mode 100644 tmk_core/common/sendchar_uart.c diff --git a/build_test.mk b/build_test.mk index 4c09bf0278..b6b8782174 100644 --- a/build_test.mk +++ b/build_test.mk @@ -63,7 +63,7 @@ endif $(TEST)_SRC += \ tests/test_common/main.c \ $(LIB_PATH)/printf/printf.c \ - $(COMMON_DIR)/printf.c + $(QUANTUM_PATH)/logging/print.c $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC) $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC) diff --git a/common_features.mk b/common_features.mk index 75a9e1f2eb..15b7b464fd 100644 --- a/common_features.mk +++ b/common_features.mk @@ -21,7 +21,15 @@ QUANTUM_SRC += \ $(QUANTUM_DIR)/bitwise.c \ $(QUANTUM_DIR)/led.c \ $(QUANTUM_DIR)/keymap_common.c \ - $(QUANTUM_DIR)/keycode_config.c + $(QUANTUM_DIR)/keycode_config.c \ + $(QUANTUM_DIR)/logging/debug.c \ + $(QUANTUM_DIR)/logging/sendchar.c \ + +VPATH += $(QUANTUM_DIR)/logging +# Fall back to lib/printf if there is no platform provided print +ifeq ("$(wildcard $(TMK_PATH)/common/$(PLATFORM_KEY)/printf.mk)","") + include $(QUANTUM_PATH)/logging/print.mk +endif ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes) OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE diff --git a/quantum/logging/debug.c b/quantum/logging/debug.c new file mode 100644 index 0000000000..ea62deaa8c --- /dev/null +++ b/quantum/logging/debug.c @@ -0,0 +1,25 @@ +/* +Copyright 2011 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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "debug.h" + +debug_config_t debug_config = { + .enable = false, // + .matrix = false, // + .keyboard = false, // + .mouse = false, // + .reserved = 0 // +}; diff --git a/quantum/logging/debug.h b/quantum/logging/debug.h new file mode 100644 index 0000000000..8415310356 --- /dev/null +++ b/quantum/logging/debug.h @@ -0,0 +1,169 @@ +/* +Copyright 2011 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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#pragma once + +#include +#include "print.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Debug output control + */ +typedef union { + struct { + bool enable : 1; + bool matrix : 1; + bool keyboard : 1; + bool mouse : 1; + uint8_t reserved : 4; + }; + uint8_t raw; +} debug_config_t; + +extern debug_config_t debug_config; + +#ifdef __cplusplus +} +#endif + +/* for backward compatibility */ +#define debug_enable (debug_config.enable) +#define debug_matrix (debug_config.matrix) +#define debug_keyboard (debug_config.keyboard) +#define debug_mouse (debug_config.mouse) + +/* + * Debug print utils + */ +#ifndef NO_DEBUG + +# define dprint(s) \ + do { \ + if (debug_enable) print(s); \ + } while (0) +# define dprintln(s) \ + do { \ + if (debug_enable) println(s); \ + } while (0) +# define dprintf(fmt, ...) \ + do { \ + if (debug_enable) xprintf(fmt, ##__VA_ARGS__); \ + } while (0) +# define dmsg(s) dprintf("%s at %d: %s\n", __FILE__, __LINE__, s) + +/* Deprecated. DO NOT USE these anymore, use dprintf instead. */ +# define debug(s) \ + do { \ + if (debug_enable) print(s); \ + } while (0) +# define debugln(s) \ + do { \ + if (debug_enable) println(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_hex4(data) \ + do { \ + if (debug_enable) print_hex4(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_hex(data) debug_hex8(data) +# define debug_bin(data) debug_bin8(data) +# define debug_bin_reverse(data) debug_bin8(data) + +#else /* NO_DEBUG */ + +# define dprint(s) +# define dprintln(s) +# define dprintf(fmt, ...) +# define dmsg(s) +# define debug(s) +# define debugln(s) +# define debug_msg(s) +# define debug_dec(data) +# define debug_decs(data) +# define debug_hex4(data) +# define debug_hex8(data) +# define debug_hex16(data) +# define debug_hex32(data) +# define debug_bin8(data) +# define debug_bin16(data) +# define debug_bin32(data) +# define debug_bin_reverse8(data) +# define debug_bin_reverse16(data) +# define debug_bin_reverse32(data) +# define debug_hex(data) +# define debug_bin(data) +# define debug_bin_reverse(data) + +#endif /* NO_DEBUG */ diff --git a/quantum/logging/nodebug.h b/quantum/logging/nodebug.h new file mode 100644 index 0000000000..0b176684bd --- /dev/null +++ b/quantum/logging/nodebug.h @@ -0,0 +1,26 @@ +/* +Copyright 2013 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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#pragma once + +#ifndef NO_DEBUG +# define NO_DEBUG +# include "debug.h" +# undef NO_DEBUG +#else +# include "debug.h" +#endif diff --git a/quantum/logging/print.c b/quantum/logging/print.c new file mode 100644 index 0000000000..e8440e55ee --- /dev/null +++ b/quantum/logging/print.c @@ -0,0 +1,27 @@ +/* +Copyright 2011 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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include +#include "sendchar.h" + +// bind lib/printf to console interface - sendchar + +static int8_t null_sendchar_func(uint8_t c) { return 0; } +static sendchar_func_t func = null_sendchar_func; + +void print_set_sendchar(sendchar_func_t send) { func = send; } + +void _putchar(char character) { func(character); } diff --git a/quantum/logging/print.h b/quantum/logging/print.h new file mode 100644 index 0000000000..8c055f549e --- /dev/null +++ b/quantum/logging/print.h @@ -0,0 +1,135 @@ +/* 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 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include +#include +#include "util.h" +#include "sendchar.h" +#include "progmem.h" + +void print_set_sendchar(sendchar_func_t func); + +#ifndef NO_PRINT +# if __has_include_next("_print.h") +# include_next "_print.h" /* Include the platforms print.h */ +# else +// Fall back to lib/printf +# include "printf.h" // lib/printf/printf.h + +// Create user & normal print defines +# define print(s) printf(s) +# define println(s) printf(s "\r\n") +# define xprintf printf +# define uprint(s) printf(s) +# define uprintln(s) printf(s "\r\n") +# define uprintf printf + +# endif /* __has_include_next("_print.h") */ +#else /* NO_PRINT */ +# undef xprintf +// Remove print defines +# define print(s) +# define println(s) +# define xprintf(fmt, ...) +# define uprintf(fmt, ...) +# define uprint(s) +# define uprintln(s) + +#endif /* NO_PRINT */ + +#ifdef USER_PRINT +// Remove normal print defines +# undef print +# undef println +# undef xprintf +# define print(s) +# define println(s) +# define xprintf(fmt, ...) +#endif + +#define print_dec(i) xprintf("%u", i) +#define print_decs(i) xprintf("%d", i) +/* hex */ +#define print_hex4(i) xprintf("%X", i) +#define print_hex8(i) xprintf("%02X", i) +#define print_hex16(i) xprintf("%04X", i) +#define print_hex32(i) xprintf("%08lX", i) +/* binary */ +#define print_bin4(i) xprintf("%04b", i) +#define print_bin8(i) xprintf("%08b", i) +#define print_bin16(i) xprintf("%016b", i) +#define print_bin32(i) xprintf("%032lb", i) +#define print_bin_reverse8(i) xprintf("%08b", bitrev(i)) +#define print_bin_reverse16(i) xprintf("%016b", bitrev16(i)) +#define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i)) +/* print value utility */ +#define print_val_dec(v) xprintf(#v ": %u\n", v) +#define print_val_decs(v) xprintf(#v ": %d\n", v) +#define print_val_hex8(v) xprintf(#v ": %X\n", v) +#define print_val_hex16(v) xprintf(#v ": %02X\n", v) +#define print_val_hex32(v) xprintf(#v ": %04lX\n", v) +#define print_val_bin8(v) xprintf(#v ": %08b\n", v) +#define print_val_bin16(v) xprintf(#v ": %016b\n", v) +#define print_val_bin32(v) xprintf(#v ": %032lb\n", v) +#define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v)) +#define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v)) +#define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v)) + +// User print disables the normal print messages in the body of QMK/TMK code and +// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do +// a spot of debugging but lack flash resources for allowing all of the codebase to +// print (and store their wasteful strings). +// +// !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!! + +/* decimal */ +#define uprint_dec(i) uprintf("%u", i) +#define uprint_decs(i) uprintf("%d", i) +/* hex */ +#define uprint_hex4(i) uprintf("%X", i) +#define uprint_hex8(i) uprintf("%02X", i) +#define uprint_hex16(i) uprintf("%04X", i) +#define uprint_hex32(i) uprintf("%08lX", i) +/* binary */ +#define uprint_bin4(i) uprintf("%04b", i) +#define uprint_bin8(i) uprintf("%08b", i) +#define uprint_bin16(i) uprintf("%016b", i) +#define uprint_bin32(i) uprintf("%032lb", i) +#define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i)) +#define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i)) +#define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i)) +/* print value utility */ +#define uprint_val_dec(v) uprintf(#v ": %u\n", v) +#define uprint_val_decs(v) uprintf(#v ": %d\n", v) +#define uprint_val_hex8(v) uprintf(#v ": %X\n", v) +#define uprint_val_hex16(v) uprintf(#v ": %02X\n", v) +#define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v) +#define uprint_val_bin8(v) uprintf(#v ": %08b\n", v) +#define uprint_val_bin16(v) uprintf(#v ": %016b\n", v) +#define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v) +#define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v)) +#define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v)) +#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 0000000000..67c004192d --- /dev/null +++ b/quantum/logging/print.mk @@ -0,0 +1,9 @@ +PRINTF_PATH = $(LIB_PATH)/printf + +VPATH += $(PRINTF_PATH) +SRC += $(PRINTF_PATH)/printf.c +QUANTUM_SRC +=$(QUANTUM_DIR)/logging/print.c +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T diff --git a/quantum/logging/sendchar.c b/quantum/logging/sendchar.c new file mode 100644 index 0000000000..9422382f6f --- /dev/null +++ b/quantum/logging/sendchar.c @@ -0,0 +1,20 @@ +/* +Copyright 2011 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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "sendchar.h" + +/* default noop "null" implementation */ +__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 0000000000..edcddaa6bb --- /dev/null +++ b/quantum/logging/sendchar.h @@ -0,0 +1,33 @@ +/* +Copyright 2011 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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int8_t (*sendchar_func_t)(uint8_t c); + +/* transmit a character. return 0 on success, -1 on error. */ +int8_t sendchar(uint8_t c); + +#ifdef __cplusplus +} +#endif diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 2f8f81126a..bd4142364c 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -8,22 +8,16 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/action_macro.c \ $(COMMON_DIR)/action_layer.c \ $(COMMON_DIR)/action_util.c \ - $(COMMON_DIR)/debug.c \ - $(COMMON_DIR)/sendchar_null.c \ $(COMMON_DIR)/eeconfig.c \ $(COMMON_DIR)/report.c \ + $(COMMON_DIR)/sync_timer.c \ $(COMMON_DIR)/usb_util.c \ $(PLATFORM_COMMON_DIR)/suspend.c \ $(PLATFORM_COMMON_DIR)/timer.c \ - $(COMMON_DIR)/sync_timer.c \ $(PLATFORM_COMMON_DIR)/bootloader.c \ -# Use platform provided print - fall back to lib/printf -ifneq ("$(wildcard $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk)","") - include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk -else - include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk -endif +# Use platform provided print if it exists +-include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk SHARED_EP_ENABLE = no MOUSE_SHARED_EP ?= yes @@ -55,6 +49,7 @@ endif ifeq ($(strip $(CONSOLE_ENABLE)), yes) TMK_COMMON_DEFS += -DCONSOLE_ENABLE else + # TODO: decouple this so other print backends can exist TMK_COMMON_DEFS += -DNO_PRINT TMK_COMMON_DEFS += -DNO_DEBUG endif diff --git a/tmk_core/common/debug.c b/tmk_core/common/debug.c deleted file mode 100644 index ea62deaa8c..0000000000 --- a/tmk_core/common/debug.c +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright 2011 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "debug.h" - -debug_config_t debug_config = { - .enable = false, // - .matrix = false, // - .keyboard = false, // - .mouse = false, // - .reserved = 0 // -}; diff --git a/tmk_core/common/debug.h b/tmk_core/common/debug.h deleted file mode 100644 index 3d2e2315ef..0000000000 --- a/tmk_core/common/debug.h +++ /dev/null @@ -1,169 +0,0 @@ -/* -Copyright 2011 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#pragma once - -#include -#include "print.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Debug output control - */ -typedef union { - struct { - bool enable : 1; - bool matrix : 1; - bool keyboard : 1; - bool mouse : 1; - uint8_t reserved : 4; - }; - uint8_t raw; -} debug_config_t; - -extern debug_config_t debug_config; - -#ifdef __cplusplus -} -#endif - -/* for backward compatibility */ -#define debug_enable (debug_config.enable) -#define debug_matrix (debug_config.matrix) -#define debug_keyboard (debug_config.keyboard) -#define debug_mouse (debug_config.mouse) - -/* - * Debug print utils - */ -#ifndef NO_DEBUG - -# define dprint(s) \ - do { \ - if (debug_enable) print(s); \ - } while (0) -# define dprintln(s) \ - do { \ - if (debug_enable) println(s); \ - } while (0) -# define dprintf(fmt, ...) \ - do { \ - if (debug_enable) xprintf(fmt, ##__VA_ARGS__); \ - } while (0) -# define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s)) - -/* Deprecated. DO NOT USE these anymore, use dprintf instead. */ -# define debug(s) \ - do { \ - if (debug_enable) print(s); \ - } while (0) -# define debugln(s) \ - do { \ - if (debug_enable) println(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_hex4(data) \ - do { \ - if (debug_enable) print_hex4(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_hex(data) debug_hex8(data) -# define debug_bin(data) debug_bin8(data) -# define debug_bin_reverse(data) debug_bin8(data) - -#else /* NO_DEBUG */ - -# define dprint(s) -# define dprintln(s) -# define dprintf(fmt, ...) -# define dmsg(s) -# define debug(s) -# define debugln(s) -# define debug_msg(s) -# define debug_dec(data) -# define debug_decs(data) -# define debug_hex4(data) -# define debug_hex8(data) -# define debug_hex16(data) -# define debug_hex32(data) -# define debug_bin8(data) -# define debug_bin16(data) -# define debug_bin32(data) -# define debug_bin_reverse8(data) -# define debug_bin_reverse16(data) -# define debug_bin_reverse32(data) -# define debug_hex(data) -# define debug_bin(data) -# define debug_bin_reverse(data) - -#endif /* NO_DEBUG */ diff --git a/tmk_core/common/lib_printf.mk b/tmk_core/common/lib_printf.mk deleted file mode 100644 index 10d2d8468d..0000000000 --- a/tmk_core/common/lib_printf.mk +++ /dev/null @@ -1,9 +0,0 @@ -PRINTF_PATH = $(LIB_PATH)/printf - -TMK_COMMON_SRC += $(PRINTF_PATH)/printf.c -TMK_COMMON_SRC += $(COMMON_DIR)/printf.c -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T -VPATH += $(PRINTF_PATH) diff --git a/tmk_core/common/nodebug.h b/tmk_core/common/nodebug.h deleted file mode 100644 index 0b176684bd..0000000000 --- a/tmk_core/common/nodebug.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2013 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#pragma once - -#ifndef NO_DEBUG -# define NO_DEBUG -# include "debug.h" -# undef NO_DEBUG -#else -# include "debug.h" -#endif diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h deleted file mode 100644 index 8c055f549e..0000000000 --- a/tmk_core/common/print.h +++ /dev/null @@ -1,135 +0,0 @@ -/* 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 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#pragma once - -#include -#include -#include "util.h" -#include "sendchar.h" -#include "progmem.h" - -void print_set_sendchar(sendchar_func_t func); - -#ifndef NO_PRINT -# if __has_include_next("_print.h") -# include_next "_print.h" /* Include the platforms print.h */ -# else -// Fall back to lib/printf -# include "printf.h" // lib/printf/printf.h - -// Create user & normal print defines -# define print(s) printf(s) -# define println(s) printf(s "\r\n") -# define xprintf printf -# define uprint(s) printf(s) -# define uprintln(s) printf(s "\r\n") -# define uprintf printf - -# endif /* __has_include_next("_print.h") */ -#else /* NO_PRINT */ -# undef xprintf -// Remove print defines -# define print(s) -# define println(s) -# define xprintf(fmt, ...) -# define uprintf(fmt, ...) -# define uprint(s) -# define uprintln(s) - -#endif /* NO_PRINT */ - -#ifdef USER_PRINT -// Remove normal print defines -# undef print -# undef println -# undef xprintf -# define print(s) -# define println(s) -# define xprintf(fmt, ...) -#endif - -#define print_dec(i) xprintf("%u", i) -#define print_decs(i) xprintf("%d", i) -/* hex */ -#define print_hex4(i) xprintf("%X", i) -#define print_hex8(i) xprintf("%02X", i) -#define print_hex16(i) xprintf("%04X", i) -#define print_hex32(i) xprintf("%08lX", i) -/* binary */ -#define print_bin4(i) xprintf("%04b", i) -#define print_bin8(i) xprintf("%08b", i) -#define print_bin16(i) xprintf("%016b", i) -#define print_bin32(i) xprintf("%032lb", i) -#define print_bin_reverse8(i) xprintf("%08b", bitrev(i)) -#define print_bin_reverse16(i) xprintf("%016b", bitrev16(i)) -#define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i)) -/* print value utility */ -#define print_val_dec(v) xprintf(#v ": %u\n", v) -#define print_val_decs(v) xprintf(#v ": %d\n", v) -#define print_val_hex8(v) xprintf(#v ": %X\n", v) -#define print_val_hex16(v) xprintf(#v ": %02X\n", v) -#define print_val_hex32(v) xprintf(#v ": %04lX\n", v) -#define print_val_bin8(v) xprintf(#v ": %08b\n", v) -#define print_val_bin16(v) xprintf(#v ": %016b\n", v) -#define print_val_bin32(v) xprintf(#v ": %032lb\n", v) -#define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v)) -#define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v)) -#define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v)) - -// User print disables the normal print messages in the body of QMK/TMK code and -// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do -// a spot of debugging but lack flash resources for allowing all of the codebase to -// print (and store their wasteful strings). -// -// !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!! - -/* decimal */ -#define uprint_dec(i) uprintf("%u", i) -#define uprint_decs(i) uprintf("%d", i) -/* hex */ -#define uprint_hex4(i) uprintf("%X", i) -#define uprint_hex8(i) uprintf("%02X", i) -#define uprint_hex16(i) uprintf("%04X", i) -#define uprint_hex32(i) uprintf("%08lX", i) -/* binary */ -#define uprint_bin4(i) uprintf("%04b", i) -#define uprint_bin8(i) uprintf("%08b", i) -#define uprint_bin16(i) uprintf("%016b", i) -#define uprint_bin32(i) uprintf("%032lb", i) -#define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i)) -#define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i)) -#define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i)) -/* print value utility */ -#define uprint_val_dec(v) uprintf(#v ": %u\n", v) -#define uprint_val_decs(v) uprintf(#v ": %d\n", v) -#define uprint_val_hex8(v) uprintf(#v ": %X\n", v) -#define uprint_val_hex16(v) uprintf(#v ": %02X\n", v) -#define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v) -#define uprint_val_bin8(v) uprintf(#v ": %08b\n", v) -#define uprint_val_bin16(v) uprintf(#v ": %016b\n", v) -#define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v) -#define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v)) -#define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v)) -#define uprint_val_bin_reverse32(v) uprintf(#v ": %032lb\n", bitrev32(v)) diff --git a/tmk_core/common/printf.c b/tmk_core/common/printf.c deleted file mode 100644 index e8440e55ee..0000000000 --- a/tmk_core/common/printf.c +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2011 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include -#include "sendchar.h" - -// bind lib/printf to console interface - sendchar - -static int8_t null_sendchar_func(uint8_t c) { return 0; } -static sendchar_func_t func = null_sendchar_func; - -void print_set_sendchar(sendchar_func_t send) { func = send; } - -void _putchar(char character) { func(character); } diff --git a/tmk_core/common/sendchar.h b/tmk_core/common/sendchar.h deleted file mode 100644 index edcddaa6bb..0000000000 --- a/tmk_core/common/sendchar.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2011 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int8_t (*sendchar_func_t)(uint8_t c); - -/* transmit a character. return 0 on success, -1 on error. */ -int8_t sendchar(uint8_t c); - -#ifdef __cplusplus -} -#endif diff --git a/tmk_core/common/sendchar_null.c b/tmk_core/common/sendchar_null.c deleted file mode 100644 index fb67f70866..0000000000 --- a/tmk_core/common/sendchar_null.c +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2011 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "sendchar.h" - -__attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; } diff --git a/tmk_core/common/sendchar_uart.c b/tmk_core/common/sendchar_uart.c deleted file mode 100644 index 2fc48bafff..0000000000 --- a/tmk_core/common/sendchar_uart.c +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2011 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 -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "uart.h" -#include "sendchar.h" - -int8_t sendchar(uint8_t c) { - uart_putchar(c); - return 0; -} -- cgit v1.2.3