From 30f22d450da19c65584e6deb8515a1fa5b074e07 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 20:21:28 +0300 Subject: Add basic infrastrucure for building full tests --- Makefile | 2 +- build_full_test.mk | 14 ++++++++++++++ build_test.mk | 3 +++ testlist.mk | 4 ++++ tests/basic/config.h | 22 ++++++++++++++++++++++ tests/basic/rules.mk | 14 ++++++++++++++ tests/basic/test.c | 17 +++++++++++++++++ 7 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 build_full_test.mk create mode 100644 tests/basic/config.h create mode 100644 tests/basic/rules.mk create mode 100644 tests/basic/test.c diff --git a/Makefile b/Makefile index 6a93692bf6..f789409b7e 100644 --- a/Makefile +++ b/Makefile @@ -419,7 +419,7 @@ define BUILD_TEST MAKE_TARGET := $2 COMMAND := $1 MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET) - MAKE_VARS := TEST=$$(TEST_NAME) + MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS=$$(FULL_TESTS) MAKE_MSG := $$(MSG_MAKE_TEST) $$(eval $$(call BUILD)) ifneq ($$(MAKE_TARGET),clean) diff --git a/build_full_test.mk b/build_full_test.mk new file mode 100644 index 0000000000..0405b9d0f8 --- /dev/null +++ b/build_full_test.mk @@ -0,0 +1,14 @@ +# Copyright 2017 Fred Sundvik +# +# 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 . \ No newline at end of file diff --git a/build_test.mk b/build_test.mk index ee15a45726..32bb4d8078 100644 --- a/build_test.mk +++ b/build_test.mk @@ -43,6 +43,9 @@ VPATH += $(COMMON_VPATH) include $(TMK_PATH)/common.mk include $(QUANTUM_PATH)/serial_link/tests/rules.mk +ifneq ($(filter $(FULL_TESTS),$(TEST)),) +include build_full_test.mk +endif $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC) $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC) diff --git a/testlist.mk b/testlist.mk index 1884d6d3f6..d949fb3eae 100644 --- a/testlist.mk +++ b/testlist.mk @@ -1,3 +1,6 @@ +TEST_LIST = $(notdir $(patsubst %/rules.mk,%,$(wildcard $(ROOT_DIR)/tests/*/rules.mk))) +FULL_TESTS := $(TEST_LIST) + include $(ROOT_DIR)/quantum/serial_link/tests/testlist.mk define VALIDATE_TEST_LIST @@ -10,4 +13,5 @@ define VALIDATE_TEST_LIST endif endef + $(eval $(call VALIDATE_TEST_LIST,$(firstword $(TEST_LIST)),$(wordlist 2,9999,$(TEST_LIST)))) \ No newline at end of file diff --git a/tests/basic/config.h b/tests/basic/config.h new file mode 100644 index 0000000000..c24fdcf3fd --- /dev/null +++ b/tests/basic/config.h @@ -0,0 +1,22 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#ifndef TESTS_BASIC_CONFIG_H_ +#define TESTS_BASIC_CONFIG_H_ + + + +#endif /* TESTS_BASIC_CONFIG_H_ */ diff --git a/tests/basic/rules.mk b/tests/basic/rules.mk new file mode 100644 index 0000000000..0405b9d0f8 --- /dev/null +++ b/tests/basic/rules.mk @@ -0,0 +1,14 @@ +# Copyright 2017 Fred Sundvik +# +# 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 . \ No newline at end of file diff --git a/tests/basic/test.c b/tests/basic/test.c new file mode 100644 index 0000000000..01d1930ea5 --- /dev/null +++ b/tests/basic/test.c @@ -0,0 +1,17 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + + -- cgit v1.2.3 From 7424261dae180d1cc0e4e46b4ee2d51ef5524e0a Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:34:01 +0300 Subject: Try to build tmk_common --- build_full_test.mk | 10 ++++- build_keyboard.mk | 122 ---------------------------------------------------- common.mk | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 132 insertions(+), 124 deletions(-) diff --git a/build_full_test.mk b/build_full_test.mk index 0405b9d0f8..5b4685a91a 100644 --- a/build_full_test.mk +++ b/build_full_test.mk @@ -11,4 +11,12 @@ # 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 . \ No newline at end of file +# along with this program. If not, see . + +include tests/$(TEST)/rules.mk +#include $(TMK_PATH)/protocol.mk + +TEST_PATH=tests/$(TEST) + +$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) +$(TEST)_DEFS=$(TMK_COMMON_DEFS) diff --git a/build_keyboard.mk b/build_keyboard.mk index 36eab3a9e5..f13d5b6d69 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -131,128 +131,6 @@ ifndef CUSTOM_MATRIX SRC += $(QUANTUM_DIR)/matrix.c endif -ifeq ($(strip $(API_SYSEX_ENABLE)), yes) - OPT_DEFS += -DAPI_SYSEX_ENABLE - SRC += $(QUANTUM_DIR)/api/api_sysex.c - OPT_DEFS += -DAPI_ENABLE - SRC += $(QUANTUM_DIR)/api.c - MIDI_ENABLE=yes -endif - -MUSIC_ENABLE := 0 - -ifeq ($(strip $(AUDIO_ENABLE)), yes) - OPT_DEFS += -DAUDIO_ENABLE - MUSIC_ENABLE := 1 - SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c - SRC += $(QUANTUM_DIR)/audio/audio.c - SRC += $(QUANTUM_DIR)/audio/voices.c - SRC += $(QUANTUM_DIR)/audio/luts.c -endif - -ifeq ($(strip $(MIDI_ENABLE)), yes) - OPT_DEFS += -DMIDI_ENABLE - MUSIC_ENABLE := 1 - SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c -endif - -ifeq ($(MUSIC_ENABLE), 1) - SRC += $(QUANTUM_DIR)/process_keycode/process_music.c -endif - -ifeq ($(strip $(COMBO_ENABLE)), yes) - OPT_DEFS += -DCOMBO_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c -endif - -ifeq ($(strip $(VIRTSER_ENABLE)), yes) - OPT_DEFS += -DVIRTSER_ENABLE -endif - -ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) - OPT_DEFS += -DFAUXCLICKY_ENABLE - SRC += $(QUANTUM_DIR)/fauxclicky.c -endif - -ifeq ($(strip $(UCIS_ENABLE)), yes) - OPT_DEFS += -DUCIS_ENABLE - UNICODE_COMMON = yes - SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c -endif - -ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) - OPT_DEFS += -DUNICODEMAP_ENABLE - UNICODE_COMMON = yes - SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c -endif - -ifeq ($(strip $(UNICODE_ENABLE)), yes) - OPT_DEFS += -DUNICODE_ENABLE - UNICODE_COMMON = yes - SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c -endif - -ifeq ($(strip $(UNICODE_COMMON)), yes) - SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c -endif - -ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) - OPT_DEFS += -DRGBLIGHT_ENABLE - SRC += $(QUANTUM_DIR)/light_ws2812.c - SRC += $(QUANTUM_DIR)/rgblight.c - CIE1931_CURVE = yes - LED_BREATHING_TABLE = yes -endif - -ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) - OPT_DEFS += -DTAP_DANCE_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c -endif - -ifeq ($(strip $(PRINTING_ENABLE)), yes) - OPT_DEFS += -DPRINTING_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c - SRC += $(TMK_DIR)/protocol/serial_uart.c -endif - -ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) - SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) - OPT_DEFS += $(SERIAL_DEFS) - VAPTH += $(SERIAL_PATH) -endif - -ifneq ($(strip $(VARIABLE_TRACE)),) - SRC += $(QUANTUM_DIR)/variable_trace.c - OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE)) -ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),) - OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE)) -endif -endif - -ifeq ($(strip $(LCD_ENABLE)), yes) - CIE1931_CURVE = yes -endif - -ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) - ifeq ($(strip $(VISUALIZER_ENABLE)), yes) - CIE1931_CURVE = yes - endif -endif - -ifeq ($(strip $(CIE1931_CURVE)), yes) - OPT_DEFS += -DUSE_CIE1931_CURVE - LED_TABLES = yes -endif - -ifeq ($(strip $(LED_BREATHING_TABLE)), yes) - OPT_DEFS += -DUSE_LED_BREATHING_TABLE - LED_TABLES = yes -endif - -ifeq ($(strip $(LED_TABLES)), yes) - SRC += $(QUANTUM_DIR)/led_tables.c -endif - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/common.mk b/common.mk index c4b9394a24..51e4283ba7 100644 --- a/common.mk +++ b/common.mk @@ -24,4 +24,126 @@ COMMON_VPATH += $(QUANTUM_PATH)/keymap_extras COMMON_VPATH += $(QUANTUM_PATH)/audio COMMON_VPATH += $(QUANTUM_PATH)/process_keycode COMMON_VPATH += $(QUANTUM_PATH)/api -COMMON_VPATH += $(SERIAL_PATH) \ No newline at end of file +COMMON_VPATH += $(SERIAL_PATH) + +ifeq ($(strip $(API_SYSEX_ENABLE)), yes) + OPT_DEFS += -DAPI_SYSEX_ENABLE + SRC += $(QUANTUM_DIR)/api/api_sysex.c + OPT_DEFS += -DAPI_ENABLE + SRC += $(QUANTUM_DIR)/api.c + MIDI_ENABLE=yes +endif + +MUSIC_ENABLE := 0 + +ifeq ($(strip $(AUDIO_ENABLE)), yes) + OPT_DEFS += -DAUDIO_ENABLE + MUSIC_ENABLE := 1 + SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c + SRC += $(QUANTUM_DIR)/audio/audio.c + SRC += $(QUANTUM_DIR)/audio/voices.c + SRC += $(QUANTUM_DIR)/audio/luts.c +endif + +ifeq ($(strip $(MIDI_ENABLE)), yes) + OPT_DEFS += -DMIDI_ENABLE + MUSIC_ENABLE := 1 + SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c +endif + +ifeq ($(MUSIC_ENABLE), 1) + SRC += $(QUANTUM_DIR)/process_keycode/process_music.c +endif + +ifeq ($(strip $(COMBO_ENABLE)), yes) + OPT_DEFS += -DCOMBO_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c +endif + +ifeq ($(strip $(VIRTSER_ENABLE)), yes) + OPT_DEFS += -DVIRTSER_ENABLE +endif + +ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) + OPT_DEFS += -DFAUXCLICKY_ENABLE + SRC += $(QUANTUM_DIR)/fauxclicky.c +endif + +ifeq ($(strip $(UCIS_ENABLE)), yes) + OPT_DEFS += -DUCIS_ENABLE + UNICODE_COMMON = yes + SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c +endif + +ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) + OPT_DEFS += -DUNICODEMAP_ENABLE + UNICODE_COMMON = yes + SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c +endif + +ifeq ($(strip $(UNICODE_ENABLE)), yes) + OPT_DEFS += -DUNICODE_ENABLE + UNICODE_COMMON = yes + SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c +endif + +ifeq ($(strip $(UNICODE_COMMON)), yes) + SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c +endif + +ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) + OPT_DEFS += -DRGBLIGHT_ENABLE + SRC += $(QUANTUM_DIR)/light_ws2812.c + SRC += $(QUANTUM_DIR)/rgblight.c + CIE1931_CURVE = yes + LED_BREATHING_TABLE = yes +endif + +ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) + OPT_DEFS += -DTAP_DANCE_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c +endif + +ifeq ($(strip $(PRINTING_ENABLE)), yes) + OPT_DEFS += -DPRINTING_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c + SRC += $(TMK_DIR)/protocol/serial_uart.c +endif + +ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) + SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) + OPT_DEFS += $(SERIAL_DEFS) + VAPTH += $(SERIAL_PATH) +endif + +ifneq ($(strip $(VARIABLE_TRACE)),) + SRC += $(QUANTUM_DIR)/variable_trace.c + OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE)) +ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),) + OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE)) +endif +endif + +ifeq ($(strip $(LCD_ENABLE)), yes) + CIE1931_CURVE = yes +endif + +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) + ifeq ($(strip $(VISUALIZER_ENABLE)), yes) + CIE1931_CURVE = yes + endif +endif + +ifeq ($(strip $(CIE1931_CURVE)), yes) + OPT_DEFS += -DUSE_CIE1931_CURVE + LED_TABLES = yes +endif + +ifeq ($(strip $(LED_BREATHING_TABLE)), yes) + OPT_DEFS += -DUSE_LED_BREATHING_TABLE + LED_TABLES = yes +endif + +ifeq ($(strip $(LED_TABLES)), yes) + SRC += $(QUANTUM_DIR)/led_tables.c +endif -- cgit v1.2.3 From 8674f9c466906c18349490f954c84e501fe3ccb6 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:38:34 +0300 Subject: Make sure config.h is included --- build_full_test.mk | 1 + build_test.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/build_full_test.mk b/build_full_test.mk index 5b4685a91a..8b04cc3a4f 100644 --- a/build_full_test.mk +++ b/build_full_test.mk @@ -20,3 +20,4 @@ TEST_PATH=tests/$(TEST) $(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) $(TEST)_DEFS=$(TMK_COMMON_DEFS) +$(TEST)_CONFIG=$(TEST_PATH)/config.h diff --git a/build_test.mk b/build_test.mk index 32bb4d8078..4d532e5bd1 100644 --- a/build_test.mk +++ b/build_test.mk @@ -50,6 +50,7 @@ endif $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC) $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC) $(TEST_OBJ)/$(TEST)_DEFS := $($(TEST)_DEFS) +$(TEST_OBJ)/$(TEST)_CONFIG := $($(TEST)_CONFIG) include $(TMK_PATH)/native.mk include $(TMK_PATH)/rules.mk -- cgit v1.2.3 From 585d64612811a61f8476380dac77199c04246085 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:39:00 +0300 Subject: Define MATRIX_COLS and MATRIX_ROWS --- tests/basic/config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/basic/config.h b/tests/basic/config.h index c24fdcf3fd..c5578b83f4 100644 --- a/tests/basic/config.h +++ b/tests/basic/config.h @@ -17,6 +17,8 @@ #ifndef TESTS_BASIC_CONFIG_H_ #define TESTS_BASIC_CONFIG_H_ +#define MATRIX_ROWS 1 +#define MATRIX_COLS 2 #endif /* TESTS_BASIC_CONFIG_H_ */ -- cgit v1.2.3 From efaf0e830b48bd5a8a62c4963e67fda3582e747c Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:41:34 +0300 Subject: Empty implementation of wait --- tmk_core/common/wait.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index 82727be012..911c9ddb5d 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h @@ -9,13 +9,16 @@ extern "C" { # include # define wait_ms(ms) _delay_ms(ms) # define wait_us(us) _delay_us(us) -#elif defined(PROTOCOL_CHIBIOS) /* __AVR__ */ +#elif defined(PROTOCOL_CHIBIOS) # include "ch.h" # define wait_ms(ms) chThdSleepMilliseconds(ms) # define wait_us(us) chThdSleepMicroseconds(us) -#elif defined(__arm__) /* __AVR__ */ +#elif defined(__arm__) # include "wait_api.h" -#endif /* __AVR__ */ +#else // Unit tests +#define wait_ms(ms) +#define wait_us(us) +#endif #ifdef __cplusplus } -- cgit v1.2.3 From fdfd48e8c8a4c713be0d2d978bbe40c5f083abc5 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:43:36 +0300 Subject: Fix program mem functionality --- tmk_core/common/progmem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h index 5b27656250..a09f91be86 100644 --- a/tmk_core/common/progmem.h +++ b/tmk_core/common/progmem.h @@ -3,7 +3,7 @@ #if defined(__AVR__) # include -#elif defined(__arm__) +#else # define PROGMEM # define pgm_read_byte(p) *((unsigned char*)p) # define pgm_read_word(p) *((uint16_t*)p) -- cgit v1.2.3 From 26eb97a4a8c260a9b5613d425bcdd175a4c67761 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:47:59 +0300 Subject: Empty implementation of bootloader, suspend and timer --- tmk_core/common.mk | 2 ++ tmk_core/common/native/bootloader.c | 17 +++++++++++++++++ tmk_core/common/native/suspend.c | 17 +++++++++++++++++ tmk_core/common/native/timer.c | 17 +++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 tmk_core/common/native/bootloader.c create mode 100644 tmk_core/common/native/suspend.c create mode 100644 tmk_core/common/native/timer.c diff --git a/tmk_core/common.mk b/tmk_core/common.mk index edec2acb4a..c69e7e2d55 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -3,6 +3,8 @@ ifeq ($(PLATFORM),AVR) PLATFORM_COMMON_DIR = $(COMMON_DIR)/avr else ifeq ($(PLATFORM),CHIBIOS) PLATFORM_COMMON_DIR = $(COMMON_DIR)/chibios +else + PLATFORM_COMMON_DIR = $(COMMON_DIR)/native endif TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ diff --git a/tmk_core/common/native/bootloader.c b/tmk_core/common/native/bootloader.c new file mode 100644 index 0000000000..01d1930ea5 --- /dev/null +++ b/tmk_core/common/native/bootloader.c @@ -0,0 +1,17 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + + diff --git a/tmk_core/common/native/suspend.c b/tmk_core/common/native/suspend.c new file mode 100644 index 0000000000..01d1930ea5 --- /dev/null +++ b/tmk_core/common/native/suspend.c @@ -0,0 +1,17 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + + diff --git a/tmk_core/common/native/timer.c b/tmk_core/common/native/timer.c new file mode 100644 index 0000000000..01d1930ea5 --- /dev/null +++ b/tmk_core/common/native/timer.c @@ -0,0 +1,17 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + + -- cgit v1.2.3 From 83509adc3a6ac71db7c7be32026a351fe08dc13a Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:51:40 +0300 Subject: Add empty timer functions --- tmk_core/common/native/timer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tmk_core/common/native/timer.c b/tmk_core/common/native/timer.c index 01d1930ea5..e21cd7d555 100644 --- a/tmk_core/common/native/timer.c +++ b/tmk_core/common/native/timer.c @@ -14,4 +14,14 @@ * along with this program. If not, see . */ +#include "timer.h" + +void timer_init(void) {} + +void timer_clear(void) {} + +uint16_t timer_read(void) { return 0; } +uint32_t timer_read32(void) { return 0; } +uint16_t timer_elapsed(uint16_t last) { return 0; } +uint32_t timer_elapsed32(uint32_t last) { return 0; } -- cgit v1.2.3 From f646f00b93b0caeb045d4aabd3b3b985f0f06402 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 21:53:21 +0300 Subject: Rename native to test --- tmk_core/common.mk | 2 +- tmk_core/common/native/bootloader.c | 17 ----------------- tmk_core/common/native/suspend.c | 17 ----------------- tmk_core/common/native/timer.c | 27 --------------------------- tmk_core/common/test/bootloader.c | 17 +++++++++++++++++ tmk_core/common/test/suspend.c | 17 +++++++++++++++++ tmk_core/common/test/timer.c | 27 +++++++++++++++++++++++++++ 7 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 tmk_core/common/native/bootloader.c delete mode 100644 tmk_core/common/native/suspend.c delete mode 100644 tmk_core/common/native/timer.c create mode 100644 tmk_core/common/test/bootloader.c create mode 100644 tmk_core/common/test/suspend.c create mode 100644 tmk_core/common/test/timer.c diff --git a/tmk_core/common.mk b/tmk_core/common.mk index c69e7e2d55..9b3002cc90 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -4,7 +4,7 @@ ifeq ($(PLATFORM),AVR) else ifeq ($(PLATFORM),CHIBIOS) PLATFORM_COMMON_DIR = $(COMMON_DIR)/chibios else - PLATFORM_COMMON_DIR = $(COMMON_DIR)/native + PLATFORM_COMMON_DIR = $(COMMON_DIR)/test endif TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ diff --git a/tmk_core/common/native/bootloader.c b/tmk_core/common/native/bootloader.c deleted file mode 100644 index 01d1930ea5..0000000000 --- a/tmk_core/common/native/bootloader.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * 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 . - */ - - diff --git a/tmk_core/common/native/suspend.c b/tmk_core/common/native/suspend.c deleted file mode 100644 index 01d1930ea5..0000000000 --- a/tmk_core/common/native/suspend.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * 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 . - */ - - diff --git a/tmk_core/common/native/timer.c b/tmk_core/common/native/timer.c deleted file mode 100644 index e21cd7d555..0000000000 --- a/tmk_core/common/native/timer.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * 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 "timer.h" - -void timer_init(void) {} - -void timer_clear(void) {} - -uint16_t timer_read(void) { return 0; } -uint32_t timer_read32(void) { return 0; } -uint16_t timer_elapsed(uint16_t last) { return 0; } -uint32_t timer_elapsed32(uint32_t last) { return 0; } - diff --git a/tmk_core/common/test/bootloader.c b/tmk_core/common/test/bootloader.c new file mode 100644 index 0000000000..01d1930ea5 --- /dev/null +++ b/tmk_core/common/test/bootloader.c @@ -0,0 +1,17 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + + diff --git a/tmk_core/common/test/suspend.c b/tmk_core/common/test/suspend.c new file mode 100644 index 0000000000..01d1930ea5 --- /dev/null +++ b/tmk_core/common/test/suspend.c @@ -0,0 +1,17 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + + diff --git a/tmk_core/common/test/timer.c b/tmk_core/common/test/timer.c new file mode 100644 index 0000000000..e21cd7d555 --- /dev/null +++ b/tmk_core/common/test/timer.c @@ -0,0 +1,27 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 "timer.h" + +void timer_init(void) {} + +void timer_clear(void) {} + +uint16_t timer_read(void) { return 0; } +uint32_t timer_read32(void) { return 0; } +uint16_t timer_elapsed(uint16_t last) { return 0; } +uint32_t timer_elapsed32(uint32_t last) { return 0; } + -- cgit v1.2.3 From d29906cb64f3c49da43c209ce341e577278e5fad Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 22:01:21 +0300 Subject: Emulate eeprom --- build_test.mk | 1 + tmk_core/common.mk | 4 ++ tmk_core/common/eeprom.h | 2 + tmk_core/common/test/eeprom.c | 98 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 tmk_core/common/test/eeprom.c diff --git a/build_test.mk b/build_test.mk index 4d532e5bd1..609b094aff 100644 --- a/build_test.mk +++ b/build_test.mk @@ -40,6 +40,7 @@ VPATH +=\ all: elf VPATH += $(COMMON_VPATH) +PLATFORM:=TEST include $(TMK_PATH)/common.mk include $(QUANTUM_PATH)/serial_link/tests/rules.mk diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 9b3002cc90..4f80e0fa9b 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -31,6 +31,10 @@ ifeq ($(PLATFORM),CHIBIOS) TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom.c endif +ifeq ($(PLATFORM),TEST) + TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom.c +endif + # Option modules diff --git a/tmk_core/common/eeprom.h b/tmk_core/common/eeprom.h index 2cc2ccee3f..3696d0df3f 100644 --- a/tmk_core/common/eeprom.h +++ b/tmk_core/common/eeprom.h @@ -4,6 +4,8 @@ #if defined(__AVR__) #include #else +#include + uint8_t eeprom_read_byte (const uint8_t *__p); uint16_t eeprom_read_word (const uint16_t *__p); uint32_t eeprom_read_dword (const uint32_t *__p); diff --git a/tmk_core/common/test/eeprom.c b/tmk_core/common/test/eeprom.c new file mode 100644 index 0000000000..61cc039efa --- /dev/null +++ b/tmk_core/common/test/eeprom.c @@ -0,0 +1,98 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 "eeprom.h" + +#define EEPROM_SIZE 32 + +static uint8_t buffer[EEPROM_SIZE]; + +uint8_t eeprom_read_byte(const uint8_t *addr) { + uintptr_t offset = (uintptr_t)addr; + return buffer[offset]; +} + +void eeprom_write_byte(uint8_t *addr, uint8_t value) { + uintptr_t offset = (uintptr_t)addr; + buffer[offset] = value; +} + +uint16_t eeprom_read_word(const uint16_t *addr) { + const uint8_t *p = (const uint8_t *)addr; + return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8); +} + +uint32_t eeprom_read_dword(const uint32_t *addr) { + const uint8_t *p = (const uint8_t *)addr; + return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8) + | (eeprom_read_byte(p+2) << 16) | (eeprom_read_byte(p+3) << 24); +} + +void eeprom_read_block(void *buf, const void *addr, uint32_t len) { + const uint8_t *p = (const uint8_t *)addr; + uint8_t *dest = (uint8_t *)buf; + while (len--) { + *dest++ = eeprom_read_byte(p++); + } +} + +void eeprom_write_word(uint16_t *addr, uint16_t value) { + uint8_t *p = (uint8_t *)addr; + eeprom_write_byte(p++, value); + eeprom_write_byte(p, value >> 8); +} + +void eeprom_write_dword(uint32_t *addr, uint32_t value) { + uint8_t *p = (uint8_t *)addr; + eeprom_write_byte(p++, value); + eeprom_write_byte(p++, value >> 8); + eeprom_write_byte(p++, value >> 16); + eeprom_write_byte(p, value >> 24); +} + +void eeprom_write_block(const void *buf, void *addr, uint32_t len) { + uint8_t *p = (uint8_t *)addr; + const uint8_t *src = (const uint8_t *)buf; + while (len--) { + eeprom_write_byte(p++, *src++); + } +} + +void eeprom_update_byte(uint8_t *addr, uint8_t value) { + eeprom_write_byte(addr, value); +} + +void eeprom_update_word(uint16_t *addr, uint16_t value) { + uint8_t *p = (uint8_t *)addr; + eeprom_write_byte(p++, value); + eeprom_write_byte(p, value >> 8); +} + +void eeprom_update_dword(uint32_t *addr, uint32_t value) { + uint8_t *p = (uint8_t *)addr; + eeprom_write_byte(p++, value); + eeprom_write_byte(p++, value >> 8); + eeprom_write_byte(p++, value >> 16); + eeprom_write_byte(p, value >> 24); +} + +void eeprom_update_block(const void *buf, void *addr, uint32_t len) { + uint8_t *p = (uint8_t *)addr; + const uint8_t *src = (const uint8_t *)buf; + while (len--) { + eeprom_write_byte(p++, *src++); + } +} -- cgit v1.2.3 From 1c0fe956ac242b1c85a9b024b9b3966020b862ed Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 22:14:47 +0300 Subject: Split common.mk into common.mk and common_features.mk To support including keyboard/keymap specific rules before it --- build_full_test.mk | 2 +- build_keyboard.mk | 15 +---- build_test.mk | 5 ++ common.mk | 128 ------------------------------------------- common_features.mk | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/basic/rules.mk | 4 +- 6 files changed, 164 insertions(+), 142 deletions(-) create mode 100644 common_features.mk diff --git a/build_full_test.mk b/build_full_test.mk index 8b04cc3a4f..a4fc8d8201 100644 --- a/build_full_test.mk +++ b/build_full_test.mk @@ -18,6 +18,6 @@ include tests/$(TEST)/rules.mk TEST_PATH=tests/$(TEST) -$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) +$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) $(QUANTUM_SRC) $(TEST)_DEFS=$(TMK_COMMON_DEFS) $(TEST)_CONFIG=$(TEST_PATH)/config.h diff --git a/build_keyboard.mk b/build_keyboard.mk index f13d5b6d69..3ec389ac9f 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -31,8 +31,6 @@ $(error MASTER does not have a valid value(left/right)) endif endif - - KEYBOARD_PATH := keyboards/$(KEYBOARD) KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c @@ -42,7 +40,6 @@ else $(error "$(KEYBOARD_C)" does not exist) endif - ifneq ($(SUBPROJECT),) SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT) SUBPROJECT_C := $(SUBPROJECT_PATH)/$(SUBPROJECT).c @@ -118,19 +115,12 @@ endif # # project specific files SRC += $(KEYBOARD_C) \ $(KEYMAP_C) \ - $(QUANTUM_DIR)/quantum.c \ - $(QUANTUM_DIR)/keymap_common.c \ - $(QUANTUM_DIR)/keycode_config.c \ - $(QUANTUM_DIR)/process_keycode/process_leader.c + $(QUANTUM_SRC) ifneq ($(SUBPROJECT),) SRC += $(SUBPROJECT_C) endif -ifndef CUSTOM_MATRIX - SRC += $(QUANTUM_DIR)/matrix.c -endif - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax @@ -142,9 +132,10 @@ endif VPATH += $(KEYBOARD_PATH) VPATH += $(COMMON_VPATH) +include common_features.mk include $(TMK_PATH)/protocol.mk - include $(TMK_PATH)/common.mk + SRC += $(TMK_COMMON_SRC) OPT_DEFS += $(TMK_COMMON_DEFS) EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS) diff --git a/build_test.mk b/build_test.mk index 609b094aff..cac2cba509 100644 --- a/build_test.mk +++ b/build_test.mk @@ -42,6 +42,11 @@ all: elf VPATH += $(COMMON_VPATH) PLATFORM:=TEST +ifneq ($(filter $(FULL_TESTS),$(TEST)),) +include tests/$(TEST)/rules.mk +endif + +include common_features.mk include $(TMK_PATH)/common.mk include $(QUANTUM_PATH)/serial_link/tests/rules.mk ifneq ($(filter $(FULL_TESTS),$(TEST)),) diff --git a/common.mk b/common.mk index 51e4283ba7..70f7ae0995 100644 --- a/common.mk +++ b/common.mk @@ -11,12 +11,6 @@ QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR) BUILD_DIR := $(TOP_DIR)/.build -SERIAL_DIR := $(QUANTUM_DIR)/serial_link -SERIAL_PATH := $(QUANTUM_PATH)/serial_link -SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c) -SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) -SERIAL_DEFS += -DSERIAL_LINK_ENABLE - COMMON_VPATH := $(TOP_DIR) COMMON_VPATH += $(TMK_PATH) COMMON_VPATH += $(QUANTUM_PATH) @@ -25,125 +19,3 @@ COMMON_VPATH += $(QUANTUM_PATH)/audio COMMON_VPATH += $(QUANTUM_PATH)/process_keycode COMMON_VPATH += $(QUANTUM_PATH)/api COMMON_VPATH += $(SERIAL_PATH) - -ifeq ($(strip $(API_SYSEX_ENABLE)), yes) - OPT_DEFS += -DAPI_SYSEX_ENABLE - SRC += $(QUANTUM_DIR)/api/api_sysex.c - OPT_DEFS += -DAPI_ENABLE - SRC += $(QUANTUM_DIR)/api.c - MIDI_ENABLE=yes -endif - -MUSIC_ENABLE := 0 - -ifeq ($(strip $(AUDIO_ENABLE)), yes) - OPT_DEFS += -DAUDIO_ENABLE - MUSIC_ENABLE := 1 - SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c - SRC += $(QUANTUM_DIR)/audio/audio.c - SRC += $(QUANTUM_DIR)/audio/voices.c - SRC += $(QUANTUM_DIR)/audio/luts.c -endif - -ifeq ($(strip $(MIDI_ENABLE)), yes) - OPT_DEFS += -DMIDI_ENABLE - MUSIC_ENABLE := 1 - SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c -endif - -ifeq ($(MUSIC_ENABLE), 1) - SRC += $(QUANTUM_DIR)/process_keycode/process_music.c -endif - -ifeq ($(strip $(COMBO_ENABLE)), yes) - OPT_DEFS += -DCOMBO_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c -endif - -ifeq ($(strip $(VIRTSER_ENABLE)), yes) - OPT_DEFS += -DVIRTSER_ENABLE -endif - -ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) - OPT_DEFS += -DFAUXCLICKY_ENABLE - SRC += $(QUANTUM_DIR)/fauxclicky.c -endif - -ifeq ($(strip $(UCIS_ENABLE)), yes) - OPT_DEFS += -DUCIS_ENABLE - UNICODE_COMMON = yes - SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c -endif - -ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) - OPT_DEFS += -DUNICODEMAP_ENABLE - UNICODE_COMMON = yes - SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c -endif - -ifeq ($(strip $(UNICODE_ENABLE)), yes) - OPT_DEFS += -DUNICODE_ENABLE - UNICODE_COMMON = yes - SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c -endif - -ifeq ($(strip $(UNICODE_COMMON)), yes) - SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c -endif - -ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) - OPT_DEFS += -DRGBLIGHT_ENABLE - SRC += $(QUANTUM_DIR)/light_ws2812.c - SRC += $(QUANTUM_DIR)/rgblight.c - CIE1931_CURVE = yes - LED_BREATHING_TABLE = yes -endif - -ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) - OPT_DEFS += -DTAP_DANCE_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c -endif - -ifeq ($(strip $(PRINTING_ENABLE)), yes) - OPT_DEFS += -DPRINTING_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c - SRC += $(TMK_DIR)/protocol/serial_uart.c -endif - -ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) - SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) - OPT_DEFS += $(SERIAL_DEFS) - VAPTH += $(SERIAL_PATH) -endif - -ifneq ($(strip $(VARIABLE_TRACE)),) - SRC += $(QUANTUM_DIR)/variable_trace.c - OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE)) -ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),) - OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE)) -endif -endif - -ifeq ($(strip $(LCD_ENABLE)), yes) - CIE1931_CURVE = yes -endif - -ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) - ifeq ($(strip $(VISUALIZER_ENABLE)), yes) - CIE1931_CURVE = yes - endif -endif - -ifeq ($(strip $(CIE1931_CURVE)), yes) - OPT_DEFS += -DUSE_CIE1931_CURVE - LED_TABLES = yes -endif - -ifeq ($(strip $(LED_BREATHING_TABLE)), yes) - OPT_DEFS += -DUSE_LED_BREATHING_TABLE - LED_TABLES = yes -endif - -ifeq ($(strip $(LED_TABLES)), yes) - SRC += $(QUANTUM_DIR)/led_tables.c -endif diff --git a/common_features.mk b/common_features.mk new file mode 100644 index 0000000000..a8a52afb97 --- /dev/null +++ b/common_features.mk @@ -0,0 +1,152 @@ +# Copyright 2017 Fred Sundvik +# +# 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 . + +SERIAL_DIR := $(QUANTUM_DIR)/serial_link +SERIAL_PATH := $(QUANTUM_PATH)/serial_link +SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c) +SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) +SERIAL_DEFS += -DSERIAL_LINK_ENABLE + +ifeq ($(strip $(API_SYSEX_ENABLE)), yes) + OPT_DEFS += -DAPI_SYSEX_ENABLE + SRC += $(QUANTUM_DIR)/api/api_sysex.c + OPT_DEFS += -DAPI_ENABLE + SRC += $(QUANTUM_DIR)/api.c + MIDI_ENABLE=yes +endif + +MUSIC_ENABLE := 0 + +ifeq ($(strip $(AUDIO_ENABLE)), yes) + OPT_DEFS += -DAUDIO_ENABLE + MUSIC_ENABLE := 1 + SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c + SRC += $(QUANTUM_DIR)/audio/audio.c + SRC += $(QUANTUM_DIR)/audio/voices.c + SRC += $(QUANTUM_DIR)/audio/luts.c +endif + +ifeq ($(strip $(MIDI_ENABLE)), yes) + OPT_DEFS += -DMIDI_ENABLE + MUSIC_ENABLE := 1 + SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c +endif + +ifeq ($(MUSIC_ENABLE), 1) + SRC += $(QUANTUM_DIR)/process_keycode/process_music.c +endif + +ifeq ($(strip $(COMBO_ENABLE)), yes) + OPT_DEFS += -DCOMBO_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c +endif + +ifeq ($(strip $(VIRTSER_ENABLE)), yes) + OPT_DEFS += -DVIRTSER_ENABLE +endif + +ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) + OPT_DEFS += -DFAUXCLICKY_ENABLE + SRC += $(QUANTUM_DIR)/fauxclicky.c +endif + +ifeq ($(strip $(UCIS_ENABLE)), yes) + OPT_DEFS += -DUCIS_ENABLE + UNICODE_COMMON = yes + SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c +endif + +ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) + OPT_DEFS += -DUNICODEMAP_ENABLE + UNICODE_COMMON = yes + SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c +endif + +ifeq ($(strip $(UNICODE_ENABLE)), yes) + OPT_DEFS += -DUNICODE_ENABLE + UNICODE_COMMON = yes + SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c +endif + +ifeq ($(strip $(UNICODE_COMMON)), yes) + SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c +endif + +ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) + OPT_DEFS += -DRGBLIGHT_ENABLE + SRC += $(QUANTUM_DIR)/light_ws2812.c + SRC += $(QUANTUM_DIR)/rgblight.c + CIE1931_CURVE = yes + LED_BREATHING_TABLE = yes +endif + +ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) + OPT_DEFS += -DTAP_DANCE_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c +endif + +ifeq ($(strip $(PRINTING_ENABLE)), yes) + OPT_DEFS += -DPRINTING_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c + SRC += $(TMK_DIR)/protocol/serial_uart.c +endif + +ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) + SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) + OPT_DEFS += $(SERIAL_DEFS) + VAPTH += $(SERIAL_PATH) +endif + +ifneq ($(strip $(VARIABLE_TRACE)),) + SRC += $(QUANTUM_DIR)/variable_trace.c + OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE)) +ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),) + OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE)) +endif +endif + +ifeq ($(strip $(LCD_ENABLE)), yes) + CIE1931_CURVE = yes +endif + +ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) + ifeq ($(strip $(VISUALIZER_ENABLE)), yes) + CIE1931_CURVE = yes + endif +endif + +ifeq ($(strip $(CIE1931_CURVE)), yes) + OPT_DEFS += -DUSE_CIE1931_CURVE + LED_TABLES = yes +endif + +ifeq ($(strip $(LED_BREATHING_TABLE)), yes) + OPT_DEFS += -DUSE_LED_BREATHING_TABLE + LED_TABLES = yes +endif + +ifeq ($(strip $(LED_TABLES)), yes) + SRC += $(QUANTUM_DIR)/led_tables.c +endif + +QUANTUM_SRC:= \ + $(QUANTUM_DIR)/quantum.c \ + $(QUANTUM_DIR)/keymap_common.c \ + $(QUANTUM_DIR)/keycode_config.c \ + $(QUANTUM_DIR)/process_keycode/process_leader.c + +ifndef CUSTOM_MATRIX + QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c +endif \ No newline at end of file diff --git a/tests/basic/rules.mk b/tests/basic/rules.mk index 0405b9d0f8..8a906807cf 100644 --- a/tests/basic/rules.mk +++ b/tests/basic/rules.mk @@ -11,4 +11,6 @@ # 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 . \ No newline at end of file +# along with this program. If not, see . + +CUSTOM_MATRIX=yes \ No newline at end of file -- cgit v1.2.3 From a72e8f0865e54777a152652c5d46280ceb58efbc Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 22:30:07 +0300 Subject: Dummy test matrix implementation --- build_full_test.mk | 4 ++-- tests/test_common/matrix.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/test_common/matrix.c diff --git a/build_full_test.mk b/build_full_test.mk index a4fc8d8201..43e2a20a7d 100644 --- a/build_full_test.mk +++ b/build_full_test.mk @@ -13,11 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -include tests/$(TEST)/rules.mk #include $(TMK_PATH)/protocol.mk TEST_PATH=tests/$(TEST) -$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) $(QUANTUM_SRC) +$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) $(QUANTUM_SRC) tests/test_common/matrix.c $(TEST)_DEFS=$(TMK_COMMON_DEFS) $(TEST)_CONFIG=$(TEST_PATH)/config.h +VPATH+=$(TOP_DIR)/tests/test_common diff --git a/tests/test_common/matrix.c b/tests/test_common/matrix.c new file mode 100644 index 0000000000..940f28f35b --- /dev/null +++ b/tests/test_common/matrix.c @@ -0,0 +1,43 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 "matrix.h" + +void matrix_init(void) { + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) { + matrix_scan_quantum(); + return 1; +} + +matrix_row_t matrix_get_row(uint8_t row) { + return 0; +} + +void matrix_print(void) { + +} + +void matrix_init_kb(void) { + +} + +void matrix_scan_kb(void) { + +} -- cgit v1.2.3 From c588fca06cd63c440678d04806042b52ff8a5610 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 22:32:04 +0300 Subject: Empty bootloader_jump --- tmk_core/common/test/bootloader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tmk_core/common/test/bootloader.c b/tmk_core/common/test/bootloader.c index 01d1930ea5..5155d9ff04 100644 --- a/tmk_core/common/test/bootloader.c +++ b/tmk_core/common/test/bootloader.c @@ -14,4 +14,6 @@ * along with this program. If not, see . */ +#include "bootloader.h" +void bootloader_jump(void) {} -- cgit v1.2.3 From 617578399cf1a0fff70ceeb21d63a06524c801a3 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 22:39:56 +0300 Subject: Add keymap --- tests/basic/config.h | 2 +- tests/basic/test.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/basic/config.h b/tests/basic/config.h index c5578b83f4..4da8d04253 100644 --- a/tests/basic/config.h +++ b/tests/basic/config.h @@ -17,7 +17,7 @@ #ifndef TESTS_BASIC_CONFIG_H_ #define TESTS_BASIC_CONFIG_H_ -#define MATRIX_ROWS 1 +#define MATRIX_ROWS 2 #define MATRIX_COLS 2 diff --git a/tests/basic/test.c b/tests/basic/test.c index 01d1930ea5..2afb4d6a96 100644 --- a/tests/basic/test.c +++ b/tests/basic/test.c @@ -14,4 +14,11 @@ * along with this program. If not, see . */ +#include "quantum.h" +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = { + {KC_A, KC_B}, + {KC_C, KC_D} + }, +}; -- cgit v1.2.3 From 3bb0586acc6472380365d78ee81a332aca468239 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Fri, 16 Jun 2017 23:50:44 +0300 Subject: Add a couple of basic tests and implement driver mock --- build_full_test.mk | 7 ++++- tests/basic/test.c | 24 ---------------- tests/basic/test.cpp | 50 +++++++++++++++++++++++++++++++++ tests/test_common/matrix.c | 13 ++++++++- tests/test_common/test_driver.cpp | 58 +++++++++++++++++++++++++++++++++++++++ tests/test_common/test_driver.h | 45 ++++++++++++++++++++++++++++++ tests/test_common/test_matrix.h | 31 +++++++++++++++++++++ 7 files changed, 202 insertions(+), 26 deletions(-) delete mode 100644 tests/basic/test.c create mode 100644 tests/basic/test.cpp create mode 100644 tests/test_common/test_driver.cpp create mode 100644 tests/test_common/test_driver.h create mode 100644 tests/test_common/test_matrix.h diff --git a/build_full_test.mk b/build_full_test.mk index 43e2a20a7d..5f9bbe5e64 100644 --- a/build_full_test.mk +++ b/build_full_test.mk @@ -17,7 +17,12 @@ TEST_PATH=tests/$(TEST) -$(TEST)_SRC=$(TEST_PATH)/test.c $(TMK_COMMON_SRC) $(QUANTUM_SRC) tests/test_common/matrix.c +$(TEST)_SRC= \ + $(TEST_PATH)/test.cpp \ + $(TMK_COMMON_SRC) \ + $(QUANTUM_SRC) \ + tests/test_common/matrix.c \ + tests/test_common/test_driver.cpp $(TEST)_DEFS=$(TMK_COMMON_DEFS) $(TEST)_CONFIG=$(TEST_PATH)/config.h VPATH+=$(TOP_DIR)/tests/test_common diff --git a/tests/basic/test.c b/tests/basic/test.c deleted file mode 100644 index 2afb4d6a96..0000000000 --- a/tests/basic/test.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2017 Fred Sundvik - * - * 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 "quantum.h" - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = { - {KC_A, KC_B}, - {KC_C, KC_D} - }, -}; diff --git a/tests/basic/test.cpp b/tests/basic/test.cpp new file mode 100644 index 0000000000..ce9a0cd726 --- /dev/null +++ b/tests/basic/test.cpp @@ -0,0 +1,50 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 "gtest/gtest.h" +#include "gmock/gmock.h" + +#include "quantum.h" +#include "keyboard.h" +#include "test_driver.h" +#include "test_matrix.h" + +using testing::_; +using testing::Return; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = { + {KC_A, KC_B}, + {KC_C, KC_D} + }, +}; + +TEST(Basic, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { + keyboard_init(); + TestDriver driver; + EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); + EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); + keyboard_task(); +} + +TEST(Basic, SendKeyboardIsCalledWhenAKeyIsPressed) { + keyboard_init(); + TestDriver driver; + press_key(0, 0); + EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); + EXPECT_CALL(driver, send_keyboard_mock(_)); + keyboard_task(); +} diff --git a/tests/test_common/matrix.c b/tests/test_common/matrix.c index 940f28f35b..85556e2c48 100644 --- a/tests/test_common/matrix.c +++ b/tests/test_common/matrix.c @@ -16,6 +16,9 @@ #include "matrix.h" +#include "test_matrix.h" + +static matrix_row_t matrix[MATRIX_ROWS] = {}; void matrix_init(void) { matrix_init_quantum(); @@ -27,7 +30,7 @@ uint8_t matrix_scan(void) { } matrix_row_t matrix_get_row(uint8_t row) { - return 0; + return matrix[row]; } void matrix_print(void) { @@ -41,3 +44,11 @@ void matrix_init_kb(void) { void matrix_scan_kb(void) { } + +void press_key(uint8_t col, uint8_t row) { + matrix[row] |= 1 << col; +} + +void release_key(uint8_t col, uint8_t row) { + matrix[row] &= ~(1 << col); +} diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp new file mode 100644 index 0000000000..7c67f57763 --- /dev/null +++ b/tests/test_common/test_driver.cpp @@ -0,0 +1,58 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 "test_driver.h" + +TestDriver* TestDriver::m_this = nullptr; + +TestDriver::TestDriver() + : m_driver{ + &TestDriver::keyboard_leds, + &TestDriver::send_keyboard, + &TestDriver::send_mouse, + &TestDriver::send_system, + &TestDriver::send_consumer + } +{ + + host_set_driver(&m_driver); + m_this = this; +} + +TestDriver::~TestDriver() { + m_this = nullptr; +} + +uint8_t TestDriver::keyboard_leds(void) { + return m_this->keyboard_leds_mock(); +} + +void TestDriver::send_keyboard(report_keyboard_t* report) { + m_this->send_keyboard_mock(report); + +} + +void TestDriver::send_mouse(report_mouse_t* report) { + m_this->send_mouse_mock(report); +} + +void TestDriver::send_system(uint16_t data) { + m_this->send_system_mock(data); +} + +void TestDriver::send_consumer(uint16_t data) { + m_this->send_consumer_mock(data); +} diff --git a/tests/test_common/test_driver.h b/tests/test_common/test_driver.h new file mode 100644 index 0000000000..d5b8318847 --- /dev/null +++ b/tests/test_common/test_driver.h @@ -0,0 +1,45 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#ifndef TESTS_TEST_COMMON_TEST_DRIVER_H_ +#define TESTS_TEST_COMMON_TEST_DRIVER_H_ + +#include "gmock/gmock.h" +#include +#include "host.h" + + +class TestDriver { +public: + TestDriver(); + ~TestDriver(); + MOCK_METHOD0(keyboard_leds_mock, uint8_t ()); + MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t*)); + MOCK_METHOD1(send_mouse_mock, void (report_mouse_t*)); + MOCK_METHOD1(send_system_mock, void (uint16_t)); + MOCK_METHOD1(send_consumer_mock, void (uint16_t)); +private: + static uint8_t keyboard_leds(void); + static void send_keyboard(report_keyboard_t *report); + static void send_mouse(report_mouse_t* report); + static void send_system(uint16_t data); + static void send_consumer(uint16_t data); + host_driver_t m_driver; + static TestDriver* m_this; +}; + + +#endif /* TESTS_TEST_COMMON_TEST_DRIVER_H_ */ diff --git a/tests/test_common/test_matrix.h b/tests/test_common/test_matrix.h new file mode 100644 index 0000000000..afc65c556b --- /dev/null +++ b/tests/test_common/test_matrix.h @@ -0,0 +1,31 @@ +/* Copyright 2017 Fred Sundvik + * + * 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 . + */ + +#ifndef TESTS_TEST_COMMON_TEST_MATRIX_H_ +#define TESTS_TEST_COMMON_TEST_MATRIX_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +void press_key(uint8_t col, uint8_t row); +void release_key(uint8_t col, uint8_t row); + +#ifdef __cplusplus +} +#endif + +#endif /* TESTS_TEST_COMMON_TEST_MATRIX_H_ */ -- cgit v1.2.3 From c38589d8615ba3ff93736cb02d12b3c8ceb68094 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 17 Jun 2017 15:18:30 +0300 Subject: Fix the order of init and driver creation --- tests/basic/test.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/basic/test.cpp b/tests/basic/test.cpp index ce9a0cd726..e3190085d6 100644 --- a/tests/basic/test.cpp +++ b/tests/basic/test.cpp @@ -33,16 +33,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; TEST(Basic, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { - keyboard_init(); TestDriver driver; + EXPECT_CALL(driver, send_keyboard_mock(_)); + keyboard_init(); EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); keyboard_task(); } TEST(Basic, SendKeyboardIsCalledWhenAKeyIsPressed) { - keyboard_init(); TestDriver driver; + EXPECT_CALL(driver, send_keyboard_mock(_)); + keyboard_init(); press_key(0, 0); EXPECT_CALL(driver, keyboard_leds_mock()).WillRepeatedly(Return(0)); EXPECT_CALL(driver, send_keyboard_mock(_)); -- cgit v1.2.3 From 017458a07bda3f4b2604d079ec65ef607a1a1e57 Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sat, 17 Jun 2017 15:19:15 +0300 Subject: Move functionality from action_util to report The functions also takes report_kebyoard_t parameters, so that they can be used elsewhere. --- tmk_core/common.mk | 1 + tmk_core/common/action_util.c | 176 ++--------------------------------------- tmk_core/common/action_util.h | 2 - tmk_core/common/report.c | 177 ++++++++++++++++++++++++++++++++++++++++++ tmk_core/common/report.h | 10 +++ 5 files changed, 193 insertions(+), 173 deletions(-) create mode 100644 tmk_core/common/report.c diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 4f80e0fa9b..75b810d985 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -18,6 +18,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/debug.c \ $(COMMON_DIR)/util.c \ $(COMMON_DIR)/eeconfig.c \ + $(COMMON_DIR)/report.c \ $(PLATFORM_COMMON_DIR)/suspend.c \ $(PLATFORM_COMMON_DIR)/timer.c \ $(PLATFORM_COMMON_DIR)/bootloader.c \ diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 77848c0923..511649676f 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c @@ -25,13 +25,6 @@ along with this program. If not, see . extern keymap_config_t keymap_config; -static inline void add_key_byte(uint8_t code); -static inline void del_key_byte(uint8_t code); -#ifdef NKRO_ENABLE -static inline void add_key_bit(uint8_t code); -static inline void del_key_bit(uint8_t code); -#endif - static uint8_t real_mods = 0; static uint8_t weak_mods = 0; static uint8_t macro_mods = 0; @@ -134,7 +127,7 @@ void send_keyboard_report(void) { } #endif keyboard_report->mods |= oneshot_mods; - if (has_anykey()) { + if (has_anykey(keyboard_report)) { clear_oneshot_mods(); } } @@ -148,22 +141,22 @@ void add_key(uint8_t key) { #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - add_key_bit(key); + add_key_bit(keyboard_report, key); return; } #endif - add_key_byte(key); + add_key_byte(keyboard_report, key); } void del_key(uint8_t key) { #ifdef NKRO_ENABLE if (keyboard_protocol && keymap_config.nkro) { - del_key_bit(key); + del_key_bit(keyboard_report, key); return; } #endif - del_key_byte(key); + del_key_byte(keyboard_report, key); } void clear_keys(void) @@ -221,166 +214,7 @@ uint8_t get_oneshot_mods(void) /* * inspect keyboard state */ -uint8_t has_anykey(void) -{ - uint8_t cnt = 0; - for (uint8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { - if (keyboard_report->raw[i]) - cnt++; - } - return cnt; -} - uint8_t has_anymod(void) { return bitpop(real_mods); } - -uint8_t get_first_key(void) -{ -#ifdef NKRO_ENABLE - if (keyboard_protocol && keymap_config.nkro) { - uint8_t i = 0; - for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) - ; - return i<<3 | biton(keyboard_report->nkro.bits[i]); - } -#endif -#ifdef USB_6KRO_ENABLE - uint8_t i = cb_head; - do { - if (keyboard_report->keys[i] != 0) { - break; - } - i = RO_INC(i); - } while (i != cb_tail); - return keyboard_report->keys[i]; -#else - return keyboard_report->keys[0]; -#endif -} - - - -/* local functions */ -static inline void add_key_byte(uint8_t code) -{ -#ifdef USB_6KRO_ENABLE - int8_t i = cb_head; - int8_t empty = -1; - if (cb_count) { - do { - if (keyboard_report->keys[i] == code) { - return; - } - if (empty == -1 && keyboard_report->keys[i] == 0) { - empty = i; - } - i = RO_INC(i); - } while (i != cb_tail); - if (i == cb_tail) { - if (cb_tail == cb_head) { - // buffer is full - if (empty == -1) { - // pop head when has no empty space - cb_head = RO_INC(cb_head); - cb_count--; - } - else { - // left shift when h