diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2017-06-19 14:04:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-19 14:04:19 -0400 |
| commit | e951317acbad8ef67a9da13b657e13e6c1d27e1d (patch) | |
| tree | a9c616a4a7d91eaf38bef570c9487493ca2b2c2e | |
| parent | 621ae42a6cb9f96b8c02a0094b36daf125c4e6ca (diff) | |
| parent | 1aa0be4cf1d00f852150e2b2ed5e4c151aeeef3a (diff) | |
| download | qmk_firmware-e951317acbad8ef67a9da13b657e13e6c1d27e1d.tar.gz qmk_firmware-e951317acbad8ef67a9da13b657e13e6c1d27e1d.zip | |
Merge pull request #1409 from fredizzimo/full_unit_test
Take first baby steps towards testing the whole QMK
30 files changed, 1095 insertions, 351 deletions
| @@ -419,7 +419,7 @@ define BUILD_TEST | |||
| 419 | MAKE_TARGET := $2 | 419 | MAKE_TARGET := $2 |
| 420 | COMMAND := $1 | 420 | COMMAND := $1 |
| 421 | MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET) | 421 | MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET) |
| 422 | MAKE_VARS := TEST=$$(TEST_NAME) | 422 | MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS=$$(FULL_TESTS) |
| 423 | MAKE_MSG := $$(MSG_MAKE_TEST) | 423 | MAKE_MSG := $$(MSG_MAKE_TEST) |
| 424 | $$(eval $$(call BUILD)) | 424 | $$(eval $$(call BUILD)) |
| 425 | ifneq ($$(MAKE_TARGET),clean) | 425 | ifneq ($$(MAKE_TARGET),clean) |
diff --git a/build_full_test.mk b/build_full_test.mk new file mode 100644 index 000000000..bfd89174d --- /dev/null +++ b/build_full_test.mk | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | # Copyright 2017 Fred Sundvik | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify | ||
| 4 | # it under the terms of the GNU General Public License as published by | ||
| 5 | # the Free Software Foundation, either version 2 of the License, or | ||
| 6 | # (at your option) any later version. | ||
| 7 | # | ||
| 8 | # This program is distributed in the hope that it will be useful, | ||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | # GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | #include $(TMK_PATH)/protocol.mk | ||
| 17 | |||
| 18 | TEST_PATH=tests/$(TEST) | ||
| 19 | |||
| 20 | $(TEST)_SRC= \ | ||
| 21 | $(TEST_PATH)/test.cpp \ | ||
| 22 | $(TMK_COMMON_SRC) \ | ||
| 23 | $(QUANTUM_SRC) \ | ||
| 24 | tests/test_common/matrix.c \ | ||
| 25 | tests/test_common/test_driver.cpp \ | ||
| 26 | tests/test_common/keyboard_report_util.cpp \ | ||
| 27 | tests/test_common/test_fixture.cpp | ||
| 28 | $(TEST)_DEFS=$(TMK_COMMON_DEFS) | ||
| 29 | $(TEST)_CONFIG=$(TEST_PATH)/config.h | ||
| 30 | VPATH+=$(TOP_DIR)/tests/test_common | ||
diff --git a/build_keyboard.mk b/build_keyboard.mk index 36eab3a9e..3ec389ac9 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -31,8 +31,6 @@ $(error MASTER does not have a valid value(left/right)) | |||
| 31 | endif | 31 | endif |
| 32 | endif | 32 | endif |
| 33 | 33 | ||
| 34 | |||
| 35 | |||
| 36 | KEYBOARD_PATH := keyboards/$(KEYBOARD) | 34 | KEYBOARD_PATH := keyboards/$(KEYBOARD) |
| 37 | KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c | 35 | KEYBOARD_C := $(KEYBOARD_PATH)/$(KEYBOARD).c |
| 38 | 36 | ||
| @@ -42,7 +40,6 @@ else | |||
| 42 | $(error "$(KEYBOARD_C)" does not exist) | 40 | $(error "$(KEYBOARD_C)" does not exist) |
| 43 | endif | 41 | endif |
| 44 | 42 | ||
| 45 | |||
| 46 | ifneq ($(SUBPROJECT),) | 43 | ifneq ($(SUBPROJECT),) |
| 47 | SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT) | 44 | SUBPROJECT_PATH := keyboards/$(KEYBOARD)/$(SUBPROJECT) |
| 48 | SUBPROJECT_C := $(SUBPROJECT_PATH)/$(SUBPROJECT).c | 45 | SUBPROJECT_C := $(SUBPROJECT_PATH)/$(SUBPROJECT).c |
| @@ -118,141 +115,12 @@ endif | |||
| 118 | # # project specific files | 115 | # # project specific files |
| 119 | SRC += $(KEYBOARD_C) \ | 116 | SRC += $(KEYBOARD_C) \ |
| 120 | $(KEYMAP_C) \ | 117 | $(KEYMAP_C) \ |
| 121 | $(QUANTUM_DIR)/quantum.c \ | 118 | $(QUANTUM_SRC) |
| 122 | $(QUANTUM_DIR)/keymap_common.c \ | ||
| 123 | $(QUANTUM_DIR)/keycode_config.c \ | ||
| 124 | $(QUANTUM_DIR)/process_keycode/process_leader.c | ||
| 125 | 119 | ||
| 126 | ifneq ($(SUBPROJECT),) | 120 | ifneq ($(SUBPROJECT),) |
| 127 | SRC += $(SUBPROJECT_C) | 121 | SRC += $(SUBPROJECT_C) |
| 128 | endif | 122 | endif |
| 129 | 123 | ||
| 130 | ifndef CUSTOM_MATRIX | ||
| 131 | SRC += $(QUANTUM_DIR)/matrix.c | ||
| 132 | endif | ||
| 133 | |||
| 134 | ifeq ($(strip $(API_SYSEX_ENABLE)), yes) | ||
| 135 | OPT_DEFS += -DAPI_SYSEX_ENABLE | ||
| 136 | SRC += $(QUANTUM_DIR)/api/api_sysex.c | ||
| 137 | OPT_DEFS += -DAPI_ENABLE | ||
| 138 | SRC += $(QUANTUM_DIR)/api.c | ||
| 139 | MIDI_ENABLE=yes | ||
| 140 | endif | ||
| 141 | |||
| 142 | MUSIC_ENABLE := 0 | ||
| 143 | |||
| 144 | ifeq ($(strip $(AUDIO_ENABLE)), yes) | ||
| 145 | OPT_DEFS += -DAUDIO_ENABLE | ||
| 146 | MUSIC_ENABLE := 1 | ||
| 147 | SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c | ||
| 148 | SRC += $(QUANTUM_DIR)/audio/audio.c | ||
| 149 | SRC += $(QUANTUM_DIR)/audio/voices.c | ||
| 150 | SRC += $(QUANTUM_DIR)/audio/luts.c | ||
| 151 | endif | ||
| 152 | |||
| 153 | ifeq ($(strip $(MIDI_ENABLE)), yes) | ||
| 154 | OPT_DEFS += -DMIDI_ENABLE | ||
| 155 | MUSIC_ENABLE := 1 | ||
| 156 | SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c | ||
| 157 | endif | ||
| 158 | |||
| 159 | ifeq ($(MUSIC_ENABLE), 1) | ||
| 160 | SRC += $(QUANTUM_DIR)/process_keycode/process_music.c | ||
| 161 | endif | ||
| 162 | |||
| 163 | ifeq ($(strip $(COMBO_ENABLE)), yes) | ||
| 164 | OPT_DEFS += -DCOMBO_ENABLE | ||
| 165 | SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c | ||
| 166 | endif | ||
| 167 | |||
| 168 | ifeq ($(strip $(VIRTSER_ENABLE)), yes) | ||
| 169 | OPT_DEFS += -DVIRTSER_ENABLE | ||
| 170 | endif | ||
| 171 | |||
| 172 | ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) | ||
| 173 | OPT_DEFS += -DFAUXCLICKY_ENABLE | ||
| 174 | SRC += $(QUANTUM_DIR)/fauxclicky.c | ||
| 175 | endif | ||
| 176 | |||
| 177 | ifeq ($(strip $(UCIS_ENABLE)), yes) | ||
| 178 | OPT_DEFS += -DUCIS_ENABLE | ||
| 179 | UNICODE_COMMON = yes | ||
| 180 | SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c | ||
| 181 | endif | ||
| 182 | |||
| 183 | ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) | ||
| 184 | OPT_DEFS += -DUNICODEMAP_ENABLE | ||
| 185 | UNICODE_COMMON = yes | ||
| 186 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c | ||
| 187 | endif | ||
| 188 | |||
| 189 | ifeq ($(strip $(UNICODE_ENABLE)), yes) | ||
| 190 | OPT_DEFS += -DUNICODE_ENABLE | ||
| 191 | UNICODE_COMMON = yes | ||
| 192 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c | ||
| 193 | endif | ||
| 194 | |||
| 195 | ifeq ($(strip $(UNICODE_COMMON)), yes) | ||
| 196 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c | ||
| 197 | endif | ||
| 198 | |||
| 199 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | ||
| 200 | OPT_DEFS += -DRGBLIGHT_ENABLE | ||
| 201 | SRC += $(QUANTUM_DIR)/light_ws2812.c | ||
| 202 | SRC += $(QUANTUM_DIR)/rgblight.c | ||
| 203 | CIE1931_CURVE = yes | ||
| 204 | LED_BREATHING_TABLE = yes | ||
| 205 | endif | ||
| 206 | |||
| 207 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | ||
| 208 | OPT_DEFS += -DTAP_DANCE_ENABLE | ||
| 209 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c | ||
| 210 | endif | ||
| 211 | |||
| 212 | ifeq ($(strip $(PRINTING_ENABLE)), yes) | ||
| 213 | OPT_DEFS += -DPRINTING_ENABLE | ||
| 214 | SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c | ||
| 215 | SRC += $(TMK_DIR)/protocol/serial_uart.c | ||
| 216 | endif | ||
| 217 | |||
| 218 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) | ||
| 219 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) | ||
| 220 | OPT_DEFS += $(SERIAL_DEFS) | ||
| 221 | VAPTH += $(SERIAL_PATH) | ||
| 222 | endif | ||
| 223 | |||
| 224 | ifneq ($(strip $(VARIABLE_TRACE)),) | ||
| 225 | SRC += $(QUANTUM_DIR)/variable_trace.c | ||
| 226 | OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE)) | ||
| 227 | ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),) | ||
| 228 | OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE)) | ||
| 229 | endif | ||
| 230 | endif | ||
| 231 | |||
| 232 | ifeq ($(strip $(LCD_ENABLE)), yes) | ||
| 233 | CIE1931_CURVE = yes | ||
| 234 | endif | ||
| 235 | |||
| 236 | ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) | ||
| 237 | ifeq ($(strip $(VISUALIZER_ENABLE)), yes) | ||
| 238 | CIE1931_CURVE = yes | ||
| 239 | endif | ||
| 240 | endif | ||
| 241 | |||
| 242 | ifeq ($(strip $(CIE1931_CURVE)), yes) | ||
| 243 | OPT_DEFS += -DUSE_CIE1931_CURVE | ||
| 244 | LED_TABLES = yes | ||
| 245 | endif | ||
| 246 | |||
| 247 | ifeq ($(strip $(LED_BREATHING_TABLE)), yes) | ||
| 248 | OPT_DEFS += -DUSE_LED_BREATHING_TABLE | ||
| 249 | LED_TABLES = yes | ||
| 250 | endif | ||
| 251 | |||
| 252 | ifeq ($(strip $(LED_TABLES)), yes) | ||
| 253 | SRC += $(QUANTUM_DIR)/led_tables.c | ||
| 254 | endif | ||
| 255 | |||
| 256 | # Optimize size but this may cause error "relocation truncated to fit" | 124 | # Optimize size but this may cause error "relocation truncated to fit" |
| 257 | #EXTRALDFLAGS = -Wl,--relax | 125 | #EXTRALDFLAGS = -Wl,--relax |
| 258 | 126 | ||
| @@ -264,9 +132,10 @@ endif | |||
| 264 | VPATH += $(KEYBOARD_PATH) | 132 | VPATH += $(KEYBOARD_PATH) |
| 265 | VPATH += $(COMMON_VPATH) | 133 | VPATH += $(COMMON_VPATH) |
| 266 | 134 | ||
| 135 | include common_features.mk | ||
| 267 | include $(TMK_PATH)/protocol.mk | 136 | include $(TMK_PATH)/protocol.mk |
| 268 | |||
| 269 | include $(TMK_PATH)/common.mk | 137 | include $(TMK_PATH)/common.mk |
| 138 | |||
| 270 | SRC += $(TMK_COMMON_SRC) | 139 | SRC += $(TMK_COMMON_SRC) |
| 271 | OPT_DEFS += $(TMK_COMMON_DEFS) | 140 | OPT_DEFS += $(TMK_COMMON_DEFS) |
| 272 | EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS) | 141 | EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS) |
diff --git a/build_test.mk b/build_test.mk index ee15a4572..cac2cba50 100644 --- a/build_test.mk +++ b/build_test.mk | |||
| @@ -40,13 +40,23 @@ VPATH +=\ | |||
| 40 | all: elf | 40 | all: elf |
| 41 | 41 | ||
| 42 | VPATH += $(COMMON_VPATH) | 42 | VPATH += $(COMMON_VPATH) |
| 43 | PLATFORM:=TEST | ||
| 43 | 44 | ||
| 45 | ifneq ($(filter $(FULL_TESTS),$(TEST)),) | ||
| 46 | include tests/$(TEST)/rules.mk | ||
| 47 | endif | ||
| 48 | |||
| 49 | include common_features.mk | ||
| 44 | include $(TMK_PATH)/common.mk | 50 | include $(TMK_PATH)/common.mk |
| 45 | include $(QUANTUM_PATH)/serial_link/tests/rules.mk | 51 | include $(QUANTUM_PATH)/serial_link/tests/rules.mk |
| 52 | ifneq ($(filter $(FULL_TESTS),$(TEST)),) | ||
| 53 | include build_full_test.mk | ||
| 54 | endif | ||
| 46 | 55 | ||
| 47 | $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC) | 56 | $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC) |
| 48 | $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC) | 57 | $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC) |
| 49 | $(TEST_OBJ)/$(TEST)_DEFS := $($(TEST)_DEFS) | 58 | $(TEST_OBJ)/$(TEST)_DEFS := $($(TEST)_DEFS) |
| 59 | $(TEST_OBJ)/$(TEST)_CONFIG := $($(TEST)_CONFIG) | ||
| 50 | 60 | ||
| 51 | include $(TMK_PATH)/native.mk | 61 | include $(TMK_PATH)/native.mk |
| 52 | include $(TMK_PATH)/rules.mk | 62 | include $(TMK_PATH)/rules.mk |
| @@ -11,17 +11,10 @@ QUANTUM_PATH = $(TOP_DIR)/$(QUANTUM_DIR) | |||
| 11 | 11 | ||
| 12 | BUILD_DIR := $(TOP_DIR)/.build | 12 | BUILD_DIR := $(TOP_DIR)/.build |
| 13 | 13 | ||
| 14 | SERIAL_DIR := $(QUANTUM_DIR)/serial_link | ||
| 15 | SERIAL_PATH := $(QUANTUM_PATH)/serial_link | ||
| 16 | SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c) | ||
| 17 | SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) | ||
| 18 | SERIAL_DEFS += -DSERIAL_LINK_ENABLE | ||
| 19 | |||
| 20 | COMMON_VPATH := $(TOP_DIR) | 14 | COMMON_VPATH := $(TOP_DIR) |
| 21 | COMMON_VPATH += $(TMK_PATH) | 15 | COMMON_VPATH += $(TMK_PATH) |
| 22 | COMMON_VPATH += $(QUANTUM_PATH) | 16 | COMMON_VPATH += $(QUANTUM_PATH) |
| 23 | COMMON_VPATH += $(QUANTUM_PATH)/keymap_extras | 17 | COMMON_VPATH += $(QUANTUM_PATH)/keymap_extras |
| 24 | COMMON_VPATH += $(QUANTUM_PATH)/audio | 18 | COMMON_VPATH += $(QUANTUM_PATH)/audio |
| 25 | COMMON_VPATH += $(QUANTUM_PATH)/process_keycode | 19 | COMMON_VPATH += $(QUANTUM_PATH)/process_keycode |
| 26 | COMMON_VPATH += $(QUANTUM_PATH)/api | 20 | COMMON_VPATH += $(QUANTUM_PATH)/api \ No newline at end of file |
| 27 | COMMON_VPATH += $(SERIAL_PATH) \ No newline at end of file | ||
diff --git a/common_features.mk b/common_features.mk new file mode 100644 index 000000000..f5e7af01f --- /dev/null +++ b/common_features.mk | |||
| @@ -0,0 +1,153 @@ | |||
| 1 | # Copyright 2017 Fred Sundvik | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify | ||
| 4 | # it under the terms of the GNU General Public License as published by | ||
| 5 | # the Free Software Foundation, either version 2 of the License, or | ||
| 6 | # (at your option) any later version. | ||
| 7 | # | ||
| 8 | # This program is distributed in the hope that it will be useful, | ||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | # GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | SERIAL_DIR := $(QUANTUM_DIR)/serial_link | ||
| 17 | SERIAL_PATH := $(QUANTUM_PATH)/serial_link | ||
| 18 | SERIAL_SRC := $(wildcard $(SERIAL_PATH)/protocol/*.c) | ||
| 19 | SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c) | ||
| 20 | SERIAL_DEFS += -DSERIAL_LINK_ENABLE | ||
| 21 | COMMON_VPATH += $(SERIAL_PATH) | ||
| 22 | |||
| 23 | ifeq ($(strip $(API_SYSEX_ENABLE)), yes) | ||
| 24 | OPT_DEFS += -DAPI_SYSEX_ENABLE | ||
| 25 | SRC += $(QUANTUM_DIR)/api/api_sysex.c | ||
| 26 | OPT_DEFS += -DAPI_ENABLE | ||
| 27 | SRC += $(QUANTUM_DIR)/api.c | ||
| 28 | MIDI_ENABLE=yes | ||
| 29 | endif | ||
| 30 | |||
| 31 | MUSIC_ENABLE := 0 | ||
| 32 | |||
| 33 | ifeq ($(strip $(AUDIO_ENABLE)), yes) | ||
| 34 | OPT_DEFS += -DAUDIO_ENABLE | ||
| 35 | MUSIC_ENABLE := 1 | ||
| 36 | SRC += $(QUANTUM_DIR)/process_keycode/process_audio.c | ||
| 37 | SRC += $(QUANTUM_DIR)/audio/audio.c | ||
| 38 | SRC += $(QUANTUM_DIR)/audio/voices.c | ||
| 39 | SRC += $(QUANTUM_DIR)/audio/luts.c | ||
| 40 | endif | ||
| 41 | |||
| 42 | ifeq ($(strip $(MIDI_ENABLE)), yes) | ||
| 43 | OPT_DEFS += -DMIDI_ENABLE | ||
| 44 | MUSIC_ENABLE := 1 | ||
| 45 | SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c | ||
| 46 | endif | ||
| 47 | |||
| 48 | ifeq ($(MUSIC_ENABLE), 1) | ||
| 49 | SRC += $(QUANTUM_DIR)/process_keycode/process_music.c | ||
| 50 | endif | ||
| 51 | |||
| 52 | ifeq ($(strip $(COMBO_ENABLE)), yes) | ||
| 53 | OPT_DEFS += -DCOMBO_ENABLE | ||
| 54 | SRC += $(QUANTUM_DIR)/process_keycode/process_combo.c | ||
| 55 | endif | ||
| 56 | |||
| 57 | ifeq ($(strip $(VIRTSER_ENABLE)), yes) | ||
| 58 | OPT_DEFS += -DVIRTSER_ENABLE | ||
| 59 | endif | ||
| 60 | |||
| 61 | ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) | ||
| 62 | OPT_DEFS += -DFAUXCLICKY_ENABLE | ||
| 63 | SRC += $(QUANTUM_DIR)/fauxclicky.c | ||
| 64 | endif | ||
| 65 | |||
| 66 | ifeq ($(strip $(UCIS_ENABLE)), yes) | ||
| 67 | OPT_DEFS += -DUCIS_ENABLE | ||
| 68 | UNICODE_COMMON = yes | ||
| 69 | SRC += $(QUANTUM_DIR)/process_keycode/process_ucis.c | ||
| 70 | endif | ||
| 71 | |||
| 72 | ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) | ||
| 73 | OPT_DEFS += -DUNICODEMAP_ENABLE | ||
| 74 | UNICODE_COMMON = yes | ||
| 75 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicodemap.c | ||
| 76 | endif | ||
| 77 | |||
| 78 | ifeq ($(strip $(UNICODE_ENABLE)), yes) | ||
| 79 | OPT_DEFS += -DUNICODE_ENABLE | ||
| 80 | UNICODE_COMMON = yes | ||
| 81 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicode.c | ||
| 82 | endif | ||
| 83 | |||
| 84 | ifeq ($(strip $(UNICODE_COMMON)), yes) | ||
| 85 | SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c | ||
| 86 | endif | ||
| 87 | |||
| 88 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | ||
| 89 | OPT_DEFS += -DRGBLIGHT_ENABLE | ||
| 90 | SRC += $(QUANTUM_DIR)/light_ws2812.c | ||
| 91 | SRC += $(QUANTUM_DIR)/rgblight.c | ||
| 92 | CIE1931_CURVE = yes | ||
| 93 | LED_BREATHING_TABLE = yes | ||
| 94 | endif | ||
| 95 | |||
| 96 | ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) | ||
| 97 | OPT_DEFS += -DTAP_DANCE_ENABLE | ||
| 98 | SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c | ||
| 99 | endif | ||
| 100 | |||
| 101 | ifeq ($(strip $(PRINTING_ENABLE)), yes) | ||
| 102 | OPT_DEFS += -DPRINTING_ENABLE | ||
| 103 | SRC += $(QUANTUM_DIR)/process_keycode/process_printer.c | ||
| 104 | SRC += $(TMK_DIR)/protocol/serial_uart.c | ||
| 105 | endif | ||
| 106 | |||
| 107 | ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes) | ||
| 108 | SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC)) | ||
| 109 | OPT_DEFS += $(SERIAL_DEFS) | ||
| 110 | VAPTH += $(SERIAL_PATH) | ||
| 111 | endif | ||
| 112 | |||
| 113 | ifneq ($(strip $(VARIABLE_TRACE)),) | ||
| 114 | SRC += $(QUANTUM_DIR)/variable_trace.c | ||
| 115 | OPT_DEFS += -DNUM_TRACED_VARIABLES=$(strip $(VARIABLE_TRACE)) | ||
| 116 | ifneq ($(strip $(MAX_VARIABLE_TRACE_SIZE)),) | ||
| 117 | OPT_DEFS += -DMAX_VARIABLE_TRACE_SIZE=$(strip $(MAX_VARIABLE_TRACE_SIZE)) | ||
| 118 | endif | ||
| 119 | endif | ||
| 120 | |||
| 121 | ifeq ($(strip $(LCD_ENABLE)), yes) | ||
| 122 | CIE1931_CURVE = yes | ||
| 123 | endif | ||
| 124 | |||
| 125 | ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) | ||
| 126 | ifeq ($(strip $(VISUALIZER_ENABLE)), yes) | ||
| 127 | CIE1931_CURVE = yes | ||
| 128 | endif | ||
| 129 | endif | ||
| 130 | |||
| 131 | ifeq ($(strip $(CIE1931_CURVE)), yes) | ||
| 132 | OPT_DEFS += -DUSE_CIE1931_CURVE | ||
| 133 | LED_TABLES = yes | ||
| 134 | endif | ||
| 135 | |||
| 136 | ifeq ($(strip $(LED_BREATHING_TABLE)), yes) | ||
| 137 | OPT_DEFS += -DUSE_LED_BREATHING_TABLE | ||
| 138 | LED_TABLES = yes | ||
| 139 | endif | ||
| 140 | |||
| 141 | ifeq ($(strip $(LED_TABLES)), yes) | ||
| 142 | SRC += $(QUANTUM_DIR)/led_tables.c | ||
| 143 | endif | ||
| 144 | |||
| 145 | QUANTUM_SRC:= \ | ||
| 146 | $(QUANTUM_DIR)/quantum.c \ | ||
| 147 | $(QUANTUM_DIR)/keymap_common.c \ | ||
| 148 | $(QUANTUM_DIR)/keycode_config.c \ | ||
| 149 | $(QUANTUM_DIR)/process_keycode/process_leader.c | ||
| 150 | |||
| 151 | ifndef CUSTOM_MATRIX | ||
| 152 | QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c | ||
| 153 | endif \ No newline at end of file | ||
diff --git a/testlist.mk b/testlist.mk index 1884d6d3f..d949fb3ea 100644 --- a/testlist.mk +++ b/testlist.mk | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | TEST_LIST = $(notdir $(patsubst %/rules.mk,%,$(wildcard $(ROOT_DIR)/tests/*/rules.mk))) | ||
| 2 | FULL_TESTS := $(TEST_LIST) | ||
| 3 | |||
| 1 | include $(ROOT_DIR)/quantum/serial_link/tests/testlist.mk | 4 | include $(ROOT_DIR)/quantum/serial_link/tests/testlist.mk |
| 2 | 5 | ||
| 3 | define VALIDATE_TEST_LIST | 6 | define VALIDATE_TEST_LIST |
| @@ -10,4 +13,5 @@ define VALIDATE_TEST_LIST | |||
| 10 | endif | 13 | endif |
| 11 | endef | 14 | endef |
| 12 | 15 | ||
| 16 | |||
| 13 | $(eval $(call VALIDATE_TEST_LIST,$(firstword $(TEST_LIST)),$(wordlist 2,9999,$(TEST_LIST)))) \ No newline at end of file | 17 | $(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 000000000..4da8d0425 --- /dev/null +++ b/tests/basic/config.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef TESTS_BASIC_CONFIG_H_ | ||
| 18 | #define TESTS_BASIC_CONFIG_H_ | ||
| 19 | |||
| 20 | #define MATRIX_ROWS 2 | ||
| 21 | #define MATRIX_COLS 2 | ||
| 22 | |||
| 23 | |||
| 24 | #endif /* TESTS_BASIC_CONFIG_H_ */ | ||
diff --git a/tests/basic/rules.mk b/tests/basic/rules.mk new file mode 100644 index 000000000..8a906807c --- /dev/null +++ b/tests/basic/rules.mk | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | # Copyright 2017 Fred Sundvik | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify | ||
| 4 | # it under the terms of the GNU General Public License as published by | ||
| 5 | # the Free Software Foundation, either version 2 of the License, or | ||
| 6 | # (at your option) any later version. | ||
| 7 | # | ||
| 8 | # This program is distributed in the hope that it will be useful, | ||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | # GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License | ||
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | |||
| 16 | CUSTOM_MATRIX=yes \ No newline at end of file | ||
diff --git a/tests/basic/test.cpp b/tests/basic/test.cpp new file mode 100644 index 000000000..1bd5c2762 --- /dev/null +++ b/tests/basic/test.cpp | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "gtest/gtest.h" | ||
| 18 | #include "gmock/gmock.h" | ||
| 19 | |||
| 20 | #include "quantum.h" | ||
| 21 | #include "test_driver.h" | ||
| 22 | #include "test_matrix.h" | ||
| 23 | #include "keyboard_report_util.h" | ||
| 24 | #include "test_fixture.h" | ||
| 25 | |||
| 26 | using testing::_; | ||
| 27 | using testing::Return; | ||
| 28 | |||
| 29 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 30 | [0] = { | ||
| 31 | {KC_A, KC_B}, | ||
| 32 | {KC_C, KC_D} | ||
| 33 | }, | ||
| 34 | }; | ||
| 35 | |||
| 36 | class KeyPress : public TestFixture {}; | ||
| 37 | |||
| 38 | TEST_F(KeyPress, SendKeyboardIsNotCalledWhenNoKeyIsPressed) { | ||
| 39 | TestDriver driver; | ||
| 40 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0); | ||
| 41 | keyboard_task(); | ||
| 42 | } | ||
| 43 | |||
| 44 | TEST_F(KeyPress, CorrectKeyIsReportedWhenPressed) { | ||
| 45 | TestDriver driver; | ||
| 46 | press_key(0, 0); | ||
| 47 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A))); | ||
| 48 | keyboard_task(); | ||
| 49 | } | ||
| 50 | |||
| 51 | TEST_F(KeyPress, CorrectKeysAreReportedWhenTwoKeysArePressed) { | ||
| 52 | TestDriver driver; | ||
| 53 | press_key(1, 0); | ||
| 54 | press_key(0, 1); | ||
| 55 | //Note that QMK only processes one key at a time | ||
| 56 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B))); | ||
| 57 | keyboard_task(); | ||
| 58 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B, KC_C))); | ||
| 59 | keyboard_task(); | ||
| 60 | } | ||
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp new file mode 100644 index 000000000..aca4433dd --- /dev/null +++ b/tests/test_common/keyboard_report_util.cpp | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "keyboard_report_util.h" | ||
| 18 | #include <vector> | ||
| 19 | #include <algorithm> | ||
| 20 | using namespace testing; | ||
| 21 | |||
| 22 | namespace | ||
| 23 | { | ||
| 24 | std::vector<uint8_t> get_keys(const report_keyboard_t& report) { | ||
| 25 | std::vector<uint8_t> result; | ||
| 26 | #if defined(NKRO_ENABLE) | ||
| 27 | #error NKRO support not implemented yet | ||
| 28 | #elif defined(USB_6KRO_ENABLE) | ||
| 29 | #error 6KRO support not implemented yet | ||
| 30 | #else | ||
| 31 | for(size_t i=0; i<KEYBOARD_REPORT_KEYS; i++) { | ||
| 32 | if (report.keys[i]) { | ||
| 33 | result.emplace_back(report.keys[i]); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | #endif | ||
| 37 | std::sort(result.begin(), result.end()); | ||
| 38 | return result; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) { | ||
| 43 | auto lhskeys = get_keys(lhs); | ||
| 44 | auto rhskeys = get_keys(rhs); | ||
| 45 | return lhs.mods == rhs.mods && lhskeys == rhskeys; | ||
| 46 | } | ||
| 47 | |||
| 48 | std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) { | ||
| 49 | stream << "Keyboard report:" << std::endl; | ||
| 50 | stream << "Mods: " << value.mods << std::endl; | ||
| 51 | // TODO: This should probably print friendly names for the keys | ||
| 52 | for (uint32_t k: get_keys(value)) { | ||
| 53 | stream << k << std::endl; | ||
| 54 | } | ||
| 55 | return stream; | ||
| 56 | } | ||
| 57 | |||
| 58 | KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { | ||
| 59 | // TODO: Support modifiers | ||
| 60 | memset(m_report.raw, 0, sizeof(m_report.raw)); | ||
| 61 | for (auto k: keys) { | ||
| 62 | add_key_to_report(&m_report, k); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | bool KeyboardReportMatcher::MatchAndExplain(report_keyboard_t& report, MatchResultListener* listener) const { | ||
| 67 | return m_report == report; | ||
| 68 | } | ||
| 69 | |||
| 70 | void KeyboardReportMatcher::DescribeTo(::std::ostream* os) const { | ||
| 71 | *os << "is equal to " << m_report; | ||
| 72 | } | ||
| 73 | |||
| 74 | void KeyboardReportMatcher::DescribeNegationTo(::std::ostream* os) const { | ||
| 75 | *os << "is not equal to " << m_report; | ||
| 76 | } \ No newline at end of file | ||
diff --git a/tests/test_common/keyboard_report_util.h b/tests/test_common/keyboard_report_util.h new file mode 100644 index 000000000..48543c205 --- /dev/null +++ b/tests/test_common/keyboard_report_util.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | #include "report.h" | ||
| 19 | #include <ostream> | ||
| 20 | #include "gmock/gmock.h" | ||
| 21 | |||
| 22 | bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs); | ||
| 23 | std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value); | ||
| 24 | |||
| 25 | class KeyboardReportMatcher : public testing::MatcherInterface<report_keyboard_t&> { | ||
| 26 | public: | ||
| 27 | KeyboardReportMatcher(const std::vector<uint8_t>& keys); | ||
| 28 | virtual bool MatchAndExplain(report_keyboard_t& report, testing::MatchResultListener* listener) const override; | ||
| 29 | virtual void DescribeTo(::std::ostream* os) const override; | ||
| 30 | virtual void DescribeNegationTo(::std::ostream* os) const override; | ||
| 31 | private: | ||
| 32 | report_keyboard_t m_report; | ||
| 33 | }; | ||
| 34 | |||
| 35 | |||
| 36 | template<typename... Ts> | ||
| 37 | inline testing::Matcher<report_keyboard_t&> KeyboardReport(Ts... keys) { | ||
| 38 | return testing::MakeMatcher(new KeyboardReportMatcher(std::vector<uint8_t>({keys...}))); | ||
| 39 | } \ No newline at end of file | ||
diff --git a/tests/test_common/matrix.c b/tests/test_common/matrix.c new file mode 100644 index 000000000..0d9fa68b0 --- /dev/null +++ b/tests/test_common/matrix.c | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | |||
| 18 | #include "matrix.h" | ||
| 19 | #include "test_matrix.h" | ||
| 20 | #include <string.h> | ||
| 21 | |||
| 22 | static matrix_row_t matrix[MATRIX_ROWS] = {}; | ||
| 23 | |||
| 24 | void matrix_init(void) { | ||
| 25 | clear_all_keys(); | ||
| 26 | matrix_init_quantum(); | ||
| 27 | } | ||
| 28 | |||
| 29 | uint8_t matrix_scan(void) { | ||
| 30 | matrix_scan_quantum(); | ||
| 31 | return 1; | ||
| 32 | } | ||
| 33 | |||
| 34 | matrix_row_t matrix_get_row(uint8_t row) { | ||
| 35 | return matrix[row]; | ||
| 36 | } | ||
| 37 | |||
| 38 | void matrix_print(void) { | ||
| 39 | |||
| 40 | } | ||
| 41 | |||
| 42 | void matrix_init_kb(void) { | ||
| 43 | |||
| 44 | } | ||
| 45 | |||
| 46 | void matrix_scan_kb(void) { | ||
| 47 | |||
| 48 | } | ||
| 49 | |||
| 50 | void press_key(uint8_t col, uint8_t row) { | ||
| 51 | matrix[row] |= 1 << col; | ||
| 52 | } | ||
| 53 | |||
| 54 | void release_key(uint8_t col, uint8_t row) { | ||
| 55 | matrix[row] &= ~(1 << col); | ||
| 56 | } | ||
| 57 | |||
| 58 | void clear_all_keys(void) { | ||
| 59 | memset(matrix, 0, sizeof(matrix)); | ||
| 60 | } | ||
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp new file mode 100644 index 000000000..feb80563a --- /dev/null +++ b/tests/test_common/test_driver.cpp | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "test_driver.h" | ||
| 18 | |||
| 19 | TestDriver* TestDriver::m_this = nullptr; | ||
| 20 | |||
| 21 | TestDriver::TestDriver() | ||
| 22 | : m_driver{ | ||
| 23 | &TestDriver::keyboard_leds, | ||
| 24 | &TestDriver::send_keyboard, | ||
| 25 | &TestDriver::send_mouse, | ||
| 26 | &TestDriver::send_system, | ||
| 27 | &TestDriver::send_consumer | ||
| 28 | } | ||
| 29 | { | ||
| 30 | host_set_driver(&m_driver); | ||
| 31 | m_this = this; | ||
| 32 | } | ||
| 33 | |||
| 34 | TestDriver::~TestDriver() { | ||
| 35 | m_this = nullptr; | ||
| 36 | } | ||
| 37 | |||
| 38 | uint8_t TestDriver::keyboard_leds(void) { | ||
| 39 | return m_this->m_leds; | ||
| 40 | } | ||
| 41 | |||
| 42 | void TestDriver::send_keyboard(report_keyboard_t* report) { | ||
| 43 | m_this->send_keyboard_mock(*report); | ||
| 44 | |||
| 45 | } | ||
| 46 | |||
| 47 | void TestDriver::send_mouse(report_mouse_t* report) { | ||
| 48 | m_this->send_mouse_mock(*report); | ||
| 49 | } | ||
| 50 | |||
| 51 | void TestDriver::send_system(uint16_t data) { | ||
| 52 | m_this->send_system_mock(data); | ||
| 53 | } | ||
| 54 | |||
| 55 | void TestDriver::send_consumer(uint16_t data) { | ||
| 56 | m_this->send_consumer(data); | ||
| 57 | } | ||
diff --git a/tests/test_common/test_driver.h b/tests/test_common/test_driver.h new file mode 100644 index 000000000..0123fd539 --- /dev/null +++ b/tests/test_common/test_driver.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef TESTS_TEST_COMMON_TEST_DRIVER_H_ | ||
| 18 | #define TESTS_TEST_COMMON_TEST_DRIVER_H_ | ||
| 19 | |||
| 20 | #include "gmock/gmock.h" | ||
| 21 | #include <stdint.h> | ||
| 22 | #include "host.h" | ||
| 23 | #include "keyboard_report_util.h" | ||
| 24 | |||
| 25 | |||
| 26 | class TestDriver { | ||
| 27 | public: | ||
| 28 | TestDriver(); | ||
| 29 | ~TestDriver(); | ||
| 30 | void set_leds(uint8_t leds) { m_leds = leds; } | ||
| 31 | |||
| 32 | MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&)); | ||
| 33 | MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&)); | ||
| 34 | MOCK_METHOD1(send_system_mock, void (uint16_t)); | ||
| 35 | MOCK_METHOD1(send_consumer_mock, void (uint16_t)); | ||
| 36 | private: | ||
| 37 | static uint8_t keyboard_leds(void); | ||
| 38 | static void send_keyboard(report_keyboard_t *report); | ||
| 39 | static void send_mouse(report_mouse_t* report); | ||
| 40 | static void send_system(uint16_t data); | ||
| 41 | static void send_consumer(uint16_t data); | ||
| 42 | host_driver_t m_driver; | ||
| 43 | uint8_t m_leds = 0; | ||
| 44 | static TestDriver* m_this; | ||
| 45 | }; | ||
| 46 | |||
| 47 | |||
| 48 | #endif /* TESTS_TEST_COMMON_TEST_DRIVER_H_ */ | ||
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp new file mode 100644 index 000000000..eef9b854b --- /dev/null +++ b/tests/test_common/test_fixture.cpp | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #include "test_fixture.h" | ||
| 2 | #include "gmock/gmock.h" | ||
| 3 | #include "test_driver.h" | ||
| 4 | #include "test_matrix.h" | ||
| 5 | #include "keyboard.h" | ||
| 6 | |||
| 7 | using testing::_; | ||
| 8 | using testing::AnyNumber; | ||
| 9 | using testing::Return; | ||
| 10 | using testing::Between; | ||
| 11 | |||
| 12 | void TestFixture::SetUpTestCase() { | ||
| 13 | TestDriver driver; | ||
| 14 | EXPECT_CALL(driver, send_keyboard_mock(_)); | ||
| 15 | keyboard_init(); | ||
| 16 | } | ||
| 17 | |||
| 18 | void TestFixture::TearDownTestCase() { | ||
| 19 | } | ||
| 20 | |||
| 21 | TestFixture::TestFixture() { | ||
| 22 | } | ||
| 23 | |||
| 24 | TestFixture::~TestFixture() { | ||
| 25 | TestDriver driver; | ||
| 26 | clear_all_keys(); | ||
| 27 | // Run for a while to make sure all keys are completely released | ||
| 28 | // Should probably wait until tapping term etc, has timed out | ||
| 29 | EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber()); | ||
| 30 | for (int i=0; i<100; i++) { | ||
| 31 | keyboard_task(); | ||
| 32 | } | ||
| 33 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 34 | // Verify that the matrix really is cleared | ||
| 35 | EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(Between(0, 1)); | ||
| 36 | } \ No newline at end of file | ||
diff --git a/tests/test_common/test_fixture.h b/tests/test_common/test_fixture.h new file mode 100644 index 000000000..a775a425a --- /dev/null +++ b/tests/test_common/test_fixture.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include "gtest/gtest.h" | ||
| 20 | |||
| 21 | class TestFixture : public testing::Test { | ||
| 22 | public: | ||
| 23 | TestFixture(); | ||
| 24 | ~TestFixture(); | ||
| 25 | static void SetUpTestCase(); | ||
| 26 | static void TearDownTestCase(); | ||
| 27 | |||
| 28 | }; \ No newline at end of file | ||
diff --git a/tests/test_common/test_matrix.h b/tests/test_common/test_matrix.h new file mode 100644 index 000000000..174fc4f22 --- /dev/null +++ b/tests/test_common/test_matrix.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef TESTS_TEST_COMMON_TEST_MATRIX_H_ | ||
| 18 | #define TESTS_TEST_COMMON_TEST_MATRIX_H_ | ||
| 19 | |||
| 20 | #ifdef __cplusplus | ||
| 21 | extern "C" { | ||
| 22 | #endif | ||
| 23 | |||
| 24 | void press_key(uint8_t col, uint8_t row); | ||
| 25 | void release_key(uint8_t col, uint8_t row); | ||
| 26 | void clear_all_keys(void); | ||
| 27 | |||
| 28 | #ifdef __cplusplus | ||
| 29 | } | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #endif /* TESTS_TEST_COMMON_TEST_MATRIX_H_ */ | ||
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index edec2acb4..75b810d98 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -3,6 +3,8 @@ ifeq ($(PLATFORM),AVR) | |||
| 3 | PLATFORM_COMMON_DIR = $(COMMON_DIR)/avr | 3 | PLATFORM_COMMON_DIR = $(COMMON_DIR)/avr |
| 4 | else ifeq ($(PLATFORM),CHIBIOS) | 4 | else ifeq ($(PLATFORM),CHIBIOS) |
| 5 | PLATFORM_COMMON_DIR = $(COMMON_DIR)/chibios | 5 | PLATFORM_COMMON_DIR = $(COMMON_DIR)/chibios |
| 6 | else | ||
| 7 | PLATFORM_COMMON_DIR = $(COMMON_DIR)/test | ||
| 6 | endif | 8 | endif |
| 7 | 9 | ||
| 8 | TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ | 10 | TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ |
| @@ -16,6 +18,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ | |||
| 16 | $(COMMON_DIR)/debug.c \ | 18 | $(COMMON_DIR)/debug.c \ |
| 17 | $(COMMON_DIR)/util.c \ | 19 | $(COMMON_DIR)/util.c \ |
| 18 | $(COMMON_DIR)/eeconfig.c \ | 20 | $(COMMON_DIR)/eeconfig.c \ |
| 21 | $(COMMON_DIR)/report.c \ | ||
| 19 | $(PLATFORM_COMMON_DIR)/suspend.c \ | 22 | $(PLATFORM_COMMON_DIR)/suspend.c \ |
| 20 | $(PLATFORM_COMMON_DIR)/timer.c \ | 23 | $(PLATFORM_COMMON_DIR)/timer.c \ |
| 21 | $(PLATFORM_COMMON_DIR)/bootloader.c \ | 24 | $(PLATFORM_COMMON_DIR)/bootloader.c \ |
| @@ -29,6 +32,10 @@ ifeq ($(PLATFORM),CHIBIOS) | |||
| 29 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom.c | 32 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom.c |
| 30 | endif | 33 | endif |
| 31 | 34 | ||
| 35 | ifeq ($(PLATFORM),TEST) | ||
| 36 | TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/eeprom.c | ||
| 37 | endif | ||
| 38 | |||
| 32 | 39 | ||
| 33 | 40 | ||
| 34 | # Option modules | 41 | # Option modules |
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 77848c092..148162a51 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 <http://www.gnu.org/licenses/>. | |||
| 25 | extern keymap_config_t keymap_config; | 25 | extern keymap_config_t keymap_config; |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | static inline void add_key_byte(uint8_t code); | ||
| 29 | static inline void del_key_byte(uint8_t code); | ||
| 30 | #ifdef NKRO_ENABLE | ||
| 31 | static inline void add_key_bit(uint8_t code); | ||
| 32 | static inline void del_key_bit(uint8_t code); | ||
| 33 | #endif | ||
| 34 | |||
| 35 | static uint8_t real_mods = 0; | 28 | static uint8_t real_mods = 0; |
| 36 | static uint8_t weak_mods = 0; | 29 | static uint8_t weak_mods = 0; |
| 37 | static uint8_t macro_mods = 0; | 30 | static uint8_t macro_mods = 0; |
| @@ -50,6 +43,10 @@ static int8_t cb_count = 0; | |||
| 50 | //report_keyboard_t keyboard_report = {}; | 43 | //report_keyboard_t keyboard_report = {}; |
| 51 | report_keyboard_t *keyboard_report = &(report_keyboard_t){}; | 44 | report_keyboard_t *keyboard_report = &(report_keyboard_t){}; |
| 52 | 45 | ||
| 46 | extern inline void add_key(uint8_t key); | ||
| 47 | extern inline void del_key(uint8_t key); | ||
| 48 | extern inline void clear_keys(void); | ||
| 49 | |||
| 53 | #ifndef NO_ACTION_ONESHOT | 50 | #ifndef NO_ACTION_ONESHOT |
| 54 | static int8_t oneshot_mods = 0; | 51 | static int8_t oneshot_mods = 0; |
| 55 | static int8_t oneshot_locked_mods = 0; | 52 | static int8_t oneshot_locked_mods = 0; |
| @@ -134,7 +131,7 @@ void send_keyboard_report(void) { | |||
| 134 | } | 131 | } |
| 135 | #endif | 132 | #endif |
| 136 | keyboard_report->mods |= oneshot_mods; | 133 | keyboard_report->mods |= oneshot_mods; |
| 137 | if (has_anykey()) { | 134 | if (has_anykey(keyboard_report)) { |
| 138 | clear_oneshot_mods(); | 135 | clear_oneshot_mods(); |
| 139 | } | 136 | } |
| 140 | } | 137 | } |
| @@ -143,38 +140,6 @@ void send_keyboard_report(void) { | |||
| 143 | host_keyboard_send(keyboard_report); | 140 | host_keyboard_send(keyboard_report); |
| 144 | } | 141 | } |
| 145 | 142 | ||
| 146 | /* key */ | ||
| 147 | void add_key(uint8_t key) | ||
| 148 | { | ||
| 149 | #ifdef NKRO_ENABLE | ||
| 150 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 151 | add_key_bit(key); | ||
| 152 | return; | ||
| 153 | } | ||
| 154 | #endif | ||
| 155 | add_key_byte(key); | ||
| 156 | } | ||
| 157 | |||
| 158 | void del_key(uint8_t key) | ||
| 159 | { | ||
| 160 | #ifdef NKRO_ENABLE | ||
| 161 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 162 | del_key_bit(key); | ||
| 163 | return; | ||
| 164 | } | ||
| 165 | #endif | ||
| 166 | del_key_byte(key); | ||
| 167 | } | ||
| 168 | |||
| 169 | void clear_keys(void) | ||
| 170 | { | ||
| 171 | // not clear mods | ||
| 172 | for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { | ||
| 173 | keyboard_report->raw[i] = 0; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | |||
| 178 | /* modifier */ | 143 | /* modifier */ |
| 179 | uint8_t get_mods(void) { return real_mods; } | 144 | uint8_t get_mods(void) { return real_mods; } |
| 180 | void add_mods(uint8_t mods) { real_mods |= mods; } | 145 | void add_mods(uint8_t mods) { real_mods |= mods; } |
| @@ -221,166 +186,7 @@ uint8_t get_oneshot_mods(void) | |||
| 221 | /* | 186 | /* |
| 222 | * inspect keyboard state | 187 | * inspect keyboard state |
| 223 | */ | 188 | */ |
| 224 | uint8_t has_anykey(void) | ||
| 225 | { | ||
| 226 | uint8_t cnt = 0; | ||
| 227 | for (uint8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { | ||
| 228 | if (keyboard_report->raw[i]) | ||
| 229 | cnt++; | ||
| 230 | } | ||
| 231 | return cnt; | ||
| 232 | } | ||
| 233 | |||
| 234 | uint8_t has_anymod(void) | 189 | uint8_t has_anymod(void) |
| 235 | { | 190 | { |
| 236 | return bitpop(real_mods); | 191 | return bitpop(real_mods); |
| 237 | } | 192 | } |
| 238 | |||
| 239 | uint8_t get_first_key(void) | ||
| 240 | { | ||
| 241 | #ifdef NKRO_ENABLE | ||
| 242 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 243 | uint8_t i = 0; | ||
| 244 | for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) | ||
| 245 | ; | ||
| 246 | return i<<3 | biton(keyboard_report->nkro.bits[i]); | ||
| 247 | } | ||
| 248 | #endif | ||
| 249 | #ifdef USB_6KRO_ENABLE | ||
| 250 | uint8_t i = cb_head; | ||
| 251 | do { | ||
| 252 | if (keyboard_report->keys[i] != 0) { | ||
| 253 | break; | ||
| 254 | } | ||
| 255 | i = RO_INC(i); | ||
| 256 | } while (i != cb_tail); | ||
| 257 | return keyboard_report->keys[i]; | ||
| 258 | #else | ||
| 259 | return keyboard_report->keys[0]; | ||
| 260 | #endif | ||
| 261 | } | ||
| 262 | |||
| 263 | |||
| 264 | |||
| 265 | /* local functions */ | ||
| 266 | static inline void add_key_byte(uint8_t code) | ||
| 267 | { | ||
| 268 | #ifdef USB_6KRO_ENABLE | ||
| 269 | int8_t i = cb_head; | ||
| 270 | int8_t empty = -1; | ||
| 271 | if (cb_count) { | ||
| 272 | do { | ||
| 273 | if (keyboard_report->keys[i] == code) { | ||
| 274 | return; | ||
| 275 | } | ||
| 276 | if (empty == -1 && keyboard_report->keys[i] == 0) { | ||
| 277 | empty = i; | ||
| 278 | } | ||
| 279 | i = RO_INC(i); | ||
| 280 | } while (i != cb_tail); | ||
| 281 | if (i == cb_tail) { | ||
| 282 | if (cb_tail == cb_head) { | ||
| 283 | // buffer is full | ||
| 284 | if (empty == -1) { | ||
| 285 | // pop head when has no empty space | ||
| 286 | cb_head = RO_INC(cb_head); | ||
| 287 | cb_count--; | ||
| 288 | } | ||
| 289 | else { | ||
| 290 | // left shift when has empty space | ||
| 291 | uint8_t offset = 1; | ||
| 292 | i = RO_INC(empty); | ||
| 293 | do { | ||
| 294 | if (keyboard_report->keys[i] != 0) { | ||
| 295 | keyboard_report->keys[empty] = keyboard_report->keys[i]; | ||
| 296 | keyboard_report->keys[i] = 0; | ||
| 297 | empty = RO_INC(empty); | ||
| 298 | } | ||
| 299 | else { | ||
| 300 | offset++; | ||
| 301 | } | ||
| 302 | i = RO_INC(i); | ||
| 303 | } while (i != cb_tail); | ||
| 304 | cb_tail = RO_SUB(cb_tail, offset); | ||
| 305 | } | ||
| 306 | } | ||
| 307 | } | ||
| 308 | } | ||
| 309 | // add to tail | ||
| 310 | keyboard_report->keys[cb_tail] = code; | ||
| 311 | cb_tail = RO_INC(cb_tail); | ||
| 312 | cb_count++; | ||
| 313 | #else | ||
| 314 | int8_t i = 0; | ||
| 315 | int8_t empty = -1; | ||
| 316 | for (; i < KEYBOARD_REPORT_KEYS; i++) { | ||
| 317 | if (keyboard_report->keys[i] == code) { | ||
| 318 | break; | ||
| 319 | } | ||
| 320 | if (empty == -1 && keyboard_report->keys[i] == 0) { | ||
| 321 | empty = i; | ||
| 322 | } | ||
| 323 | } | ||
| 324 | if (i == KEYBOARD_REPORT_KEYS) { | ||
| 325 | if (empty != -1) { | ||
| 326 | keyboard_report->keys[empty] = code; | ||
| 327 | } | ||
| 328 | } | ||
| 329 | #endif | ||
| 330 | } | ||
| 331 | |||
| 332 | static inline void del_key_byte(uint8_t code) | ||
| 333 | { | ||
| 334 | #ifdef USB_6KRO_ENABLE | ||
| 335 | uint8_t i = cb_head; | ||
| 336 | if (cb_count) { | ||
| 337 | do { | ||
| 338 | if (keyboard_report->keys[i] == code) { | ||
| 339 | keyboard_report->keys[i] = 0; | ||
| 340 | cb_count--; | ||
| 341 | if (cb_count == 0) { | ||
| 342 | // reset head and tail | ||
| 343 | cb_tail = cb_head = 0; | ||
| 344 | } | ||
| 345 | if (i == RO_DEC(cb_tail)) { | ||
| 346 | // left shift when next to tail | ||
| 347 | do { | ||
| 348 | cb_tail = RO_DEC(cb_tail); | ||
| 349 | if (keyboard_report->keys[RO_DEC(cb_tail)] != 0) { | ||
| 350 | break; | ||
| 351 | } | ||
| 352 | } while (cb_tail != cb_head); | ||
| 353 | } | ||
| 354 | break; | ||
| 355 | } | ||
| 356 | i = RO_INC(i); | ||
| 357 | } while (i != cb_tail); | ||
| 358 | } | ||
| 359 | #else | ||
| 360 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | ||
| 361 | if (keyboard_report->keys[i] == code) { | ||
| 362 | keyboard_report->keys[i] = 0; | ||
| 363 | } | ||
| 364 | } | ||
| 365 | #endif | ||
| 366 | } | ||
| 367 | |||
| 368 | #ifdef NKRO_ENABLE | ||
| 369 | static inline void add_key_bit(uint8_t code) | ||
| 370 | { | ||
| 371 | if ((code>>3) < KEYBOARD_REPORT_BITS) { | ||
| 372 | keyboard_report->nkro.bits[code>>3] |= 1<<(code&7); | ||
| 373 | } else { | ||
| 374 | dprintf("add_key_bit: can't add: %02X\n", code); | ||
| 375 | } | ||
| 376 | } | ||
| 377 | |||
| 378 | static inline void del_key_bit(uint8_t code) | ||
| 379 | { | ||
| 380 | if ((code>>3) < KEYBOARD_REPORT_BITS) { | ||
| 381 | keyboard_report->nkro.bits[code>>3] &= ~(1<<(code&7)); | ||
| 382 | } else { | ||
| 383 | dprintf("del_key_bit: can't del: %02X\n", code); | ||
| 384 | } | ||
| 385 | } | ||
| 386 | #endif | ||
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h index dd0c4c2bf..345893151 100644 --- a/tmk_core/common/action_util.h +++ b/tmk_core/common/action_util.h | |||
| @@ -29,9 +29,17 @@ extern report_keyboard_t *keyboard_report; | |||
| 29 | void send_keyboard_report(void); | 29 | void send_keyboard_report(void); |
| 30 | 30 | ||
| 31 | /* key */ | 31 | /* key */ |
| 32 | void add_key(uint8_t key); | 32 | inline void add_key(uint8_t key) { |
| 33 | void del_key(uint8_t key); | 33 | add_key_to_report(keyboard_report, key); |
| 34 | void clear_keys(void); | 34 | } |
| 35 | |||
| 36 | inline void del_key(uint8_t key) { | ||
| 37 | del_key_from_report(keyboard_report, key); | ||
| 38 | } | ||
| 39 | |||
| 40 | inline void clear_keys(void) { | ||
| 41 | clear_keys_from_report(keyboard_report); | ||
| 42 | } | ||
| 35 | 43 | ||
| 36 | /* modifier */ | 44 | /* modifier */ |
| 37 | uint8_t get_mods(void); | 45 | uint8_t get_mods(void); |
| @@ -82,9 +90,7 @@ uint8_t get_oneshot_layer_state(void); | |||
| 82 | bool has_oneshot_layer_timed_out(void); | 90 | bool has_oneshot_layer_timed_out(void); |
| 83 | 91 | ||
| 84 | /* inspect */ | 92 | /* inspect */ |
| 85 | uint8_t has_anykey(void); | ||
| 86 | uint8_t has_anymod(void); | 93 | uint8_t has_anymod(void); |
| 87 | uint8_t get_first_key(void); | ||
| 88 | 94 | ||
| 89 | #ifdef __cplusplus | 95 | #ifdef __cplusplus |
| 90 | } | 96 | } |
diff --git a/tmk_core/common/eeprom.h b/tmk_core/common/eeprom.h index 2cc2ccee3..3696d0df3 100644 --- a/tmk_core/common/eeprom.h +++ b/tmk_core/common/eeprom.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | #if defined(__AVR__) | 4 | #if defined(__AVR__) |
| 5 | #include <avr/eeprom.h> | 5 | #include <avr/eeprom.h> |
| 6 | #else | 6 | #else |
| 7 | #include <stdint.h> | ||
| 8 | |||
| 7 | uint8_t eeprom_read_byte (const uint8_t *__p); | 9 | uint8_t eeprom_read_byte (const uint8_t *__p); |
| 8 | uint16_t eeprom_read_word (const uint16_t *__p); | 10 | uint16_t eeprom_read_word (const uint16_t *__p); |
| 9 | uint32_t eeprom_read_dword (const uint32_t *__p); | 11 | uint32_t eeprom_read_dword (const uint32_t *__p); |
diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h index 5b2765625..a09f91be8 100644 --- a/tmk_core/common/progmem.h +++ b/tmk_core/common/progmem.h | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #if defined(__AVR__) | 4 | #if defined(__AVR__) |
| 5 | # include <avr/pgmspace.h> | 5 | # include <avr/pgmspace.h> |
| 6 | #elif defined(__arm__) | 6 | #else |
| 7 | # define PROGMEM | 7 | # define PROGMEM |
| 8 | # define pgm_read_byte(p) *((unsigned char*)p) | 8 | # define pgm_read_byte(p) *((unsigned char*)p) |
| 9 | # define pgm_read_word(p) *((uint16_t*)p) | 9 | # define pgm_read_word(p) *((uint16_t*)p) |
diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c new file mode 100644 index 000000000..74c6d3fdd --- /dev/null +++ b/tmk_core/common/report.c | |||
| @@ -0,0 +1,207 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "report.h" | ||
| 18 | #include "host.h" | ||
| 19 | #include "keycode_config.h" | ||
| 20 | #include "debug.h" | ||
| 21 | #include "util.h" | ||
| 22 | |||
| 23 | uint8_t has_anykey(report_keyboard_t* keyboard_report) | ||
| 24 | { | ||
| 25 | uint8_t cnt = 0; | ||
| 26 | for (uint8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { | ||
| 27 | if (keyboard_report->raw[i]) | ||
| 28 | cnt++; | ||
| 29 | } | ||
| 30 | return cnt; | ||
| 31 | } | ||
| 32 | |||
| 33 | uint8_t get_first_key(report_keyboard_t* keyboard_report) | ||
| 34 | { | ||
| 35 | #ifdef NKRO_ENABLE | ||
| 36 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 37 | uint8_t i = 0; | ||
| 38 | for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) | ||
| 39 | ; | ||
| 40 | return i<<3 | biton(keyboard_report->nkro.bits[i]); | ||
| 41 | } | ||
| 42 | #endif | ||
| 43 | #ifdef USB_6KRO_ENABLE | ||
| 44 | uint8_t i = cb_head; | ||
| 45 | do { | ||
| 46 | if (keyboard_report->keys[i] != 0) { | ||
| 47 | break; | ||
| 48 | } | ||
| 49 | i = RO_INC(i); | ||
| 50 | } while (i != cb_tail); | ||
| 51 | return keyboard_report->keys[i]; | ||
| 52 | #else | ||
| 53 | return keyboard_report->keys[0]; | ||
| 54 | #endif | ||
| 55 | } | ||
| 56 | |||
| 57 | void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) | ||
| 58 | { | ||
| 59 | #ifdef USB_6KRO_ENABLE | ||
| 60 | int8_t i = cb_head; | ||
| 61 | int8_t empty = -1; | ||
| 62 | if (cb_count) { | ||
| 63 | do { | ||
| 64 | if (keyboard_report->keys[i] == code) { | ||
| 65 | return; | ||
| 66 | } | ||
| 67 | if (empty == -1 && keyboard_report->keys[i] == 0) { | ||
| 68 | empty = i; | ||
| 69 | } | ||
| 70 | i = RO_INC(i); | ||
| 71 | } while (i != cb_tail); | ||
| 72 | if (i == cb_tail) { | ||
| 73 | if (cb_tail == cb_head) { | ||
| 74 | // buffer is full | ||
| 75 | if (empty == -1) { | ||
| 76 | // pop head when has no empty space | ||
| 77 | cb_head = RO_INC(cb_head); | ||
| 78 | cb_count--; | ||
| 79 | } | ||
| 80 | else { | ||
| 81 | // left shift when has empty space | ||
| 82 | uint8_t offset = 1; | ||
| 83 | i = RO_INC(empty); | ||
| 84 | do { | ||
| 85 | if (keyboard_report->keys[i] != 0) { | ||
| 86 | keyboard_report->keys[empty] = keyboard_report->keys[i]; | ||
| 87 | keyboard_report->keys[i] = 0; | ||
| 88 | empty = RO_INC(empty); | ||
| 89 | } | ||
| 90 | else { | ||
| 91 | offset++; | ||
| 92 | } | ||
| 93 | i = RO_INC(i); | ||
| 94 | } while (i != cb_tail); | ||
| 95 | cb_tail = RO_SUB(cb_tail, offset); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | // add to tail | ||
| 101 | keyboard_report->keys[cb_tail] = code; | ||
| 102 | cb_tail = RO_INC(cb_tail); | ||
| 103 | cb_count++; | ||
| 104 | #else | ||
| 105 | int8_t i = 0; | ||
| 106 | int8_t empty = -1; | ||
| 107 | for (; i < KEYBOARD_REPORT_KEYS; i++) { | ||
| 108 | if (keyboard_report->keys[i] == code) { | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | if (empty == -1 && keyboard_report->keys[i] == 0) { | ||
| 112 | empty = i; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | if (i == KEYBOARD_REPORT_KEYS) { | ||
| 116 | if (empty != -1) { | ||
| 117 | keyboard_report->keys[empty] = code; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | #endif | ||
| 121 | } | ||
| 122 | |||
| 123 | void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) | ||
| 124 | { | ||
| 125 | #ifdef USB_6KRO_ENABLE | ||
| 126 | uint8_t i = cb_head; | ||
| 127 | if (cb_count) { | ||
| 128 | do { | ||
| 129 | if (keyboard_report->keys[i] == code) { | ||
| 130 | keyboard_report->keys[i] = 0; | ||
| 131 | cb_count--; | ||
| 132 | if (cb_count == 0) { | ||
| 133 | // reset head and tail | ||
| 134 | cb_tail = cb_head = 0; | ||
| 135 | } | ||
| 136 | if (i == RO_DEC(cb_tail)) { | ||
| 137 | // left shift when next to tail | ||
| 138 | do { | ||
| 139 | cb_tail = RO_DEC(cb_tail); | ||
| 140 | if (keyboard_report->keys[RO_DEC(cb_tail)] != 0) { | ||
| 141 | break; | ||
| 142 | } | ||
| 143 | } while (cb_tail != cb_head); | ||
| 144 | } | ||
| 145 | break; | ||
| 146 | } | ||
| 147 | i = RO_INC(i); | ||
| 148 | } while (i != cb_tail); | ||
| 149 | } | ||
| 150 | #else | ||
| 151 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | ||
| 152 | if (keyboard_report->keys[i] == code) { | ||
| 153 | keyboard_report->keys[i] = 0; | ||
| 154 | } | ||
| 155 | } | ||
| 156 | #endif | ||
| 157 | } | ||
| 158 | |||
| 159 | #ifdef NKRO_ENABLE | ||
| 160 | void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) | ||
| 161 | { | ||
| 162 | if ((code>>3) < KEYBOARD_REPORT_BITS) { | ||
| 163 | keyboard_report->nkro.bits[code>>3] |= 1<<(code&7); | ||
| 164 | } else { | ||
| 165 | dprintf("add_key_bit: can't add: %02X\n", code); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) | ||
| 170 | { | ||
| 171 | if ((code>>3) < KEYBOARD_REPORT_BITS) { | ||
| 172 | keyboard_report->nkro.bits[code>>3] &= ~(1<<(code&7)); | ||
| 173 | } else { | ||
| 174 | dprintf("del_key_bit: can't del: %02X\n", code); | ||
| 175 | } | ||
| 176 | } | ||
| 177 | #endif | ||
| 178 | |||
| 179 | void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key) | ||
| 180 | { | ||
| 181 | #ifdef NKRO_ENABLE | ||
| 182 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 183 | add_key_bit(keyboard_report, key); | ||
| 184 | return; | ||
| 185 | } | ||
| 186 | #endif | ||
| 187 | add_key_byte(keyboard_report, key); | ||
| 188 | } | ||
| 189 | |||
| 190 | void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) | ||
| 191 | { | ||
| 192 | #ifdef NKRO_ENABLE | ||
| 193 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 194 | del_key_bit(keyboard_report, key); | ||
| 195 | return; | ||
| 196 | } | ||
| 197 | #endif | ||
| 198 | del_key_byte(keyboard_report, key); | ||
| 199 | } | ||
| 200 | |||
| 201 | void clear_keys_from_report(report_keyboard_t* keyboard_report) | ||
| 202 | { | ||
| 203 | // not clear mods | ||
| 204 | for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { | ||
| 205 | keyboard_report->raw[i] = 0; | ||
| 206 | } | ||
| 207 | } \ No newline at end of file | ||
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 8fb28b6ce..899fc524c 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h | |||
| @@ -174,6 +174,20 @@ typedef struct { | |||
| 174 | (key == KC_WWW_REFRESH ? AC_REFRESH : \ | 174 | (key == KC_WWW_REFRESH ? AC_REFRESH : \ |
| 175 | (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))) | 175 | (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))) |
| 176 | 176 | ||
| 177 | uint8_t has_anykey(report_keyboard_t* keyboard_report); | ||
| 178 | uint8_t get_first_key(report_keyboard_t* keyboard_report); | ||
| 179 | |||
| 180 | void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code); | ||
| 181 | void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code); | ||
| 182 | #ifdef NKRO_ENABLE | ||
| 183 | void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code); | ||
| 184 | void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code); | ||
| 185 | #endif | ||
| 186 | |||
| 187 | void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key); | ||
| 188 | void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key); | ||
| 189 | void clear_keys_from_report(report_keyboard_t* keyboard_report); | ||
| 190 | |||
| 177 | #ifdef __cplusplus | 191 | #ifdef __cplusplus |
| 178 | } | 192 | } |
| 179 | #endif | 193 | #endif |
diff --git a/tmk_core/common/test/bootloader.c b/tmk_core/common/test/bootloader.c new file mode 100644 index 000000000..5155d9ff0 --- /dev/null +++ b/tmk_core/common/test/bootloader.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "bootloader.h" | ||
| 18 | |||
| 19 | void bootloader_jump(void) {} | ||
diff --git a/tmk_core/common/test/eeprom.c b/tmk_core/common/test/eeprom.c new file mode 100644 index 000000000..61cc039ef --- /dev/null +++ b/tmk_core/common/test/eeprom.c | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "eeprom.h" | ||
| 18 | |||
| 19 | #define EEPROM_SIZE 32 | ||
| 20 | |||
| 21 | static uint8_t buffer[EEPROM_SIZE]; | ||
| 22 | |||
| 23 | uint8_t eeprom_read_byte(const uint8_t *addr) { | ||
| 24 | uintptr_t offset = (uintptr_t)addr; | ||
| 25 | return buffer[offset]; | ||
| 26 | } | ||
| 27 | |||
| 28 | void eeprom_write_byte(uint8_t *addr, uint8_t value) { | ||
| 29 | uintptr_t offset = (uintptr_t)addr; | ||
| 30 | buffer[offset] = value; | ||
| 31 | } | ||
| 32 | |||
| 33 | uint16_t eeprom_read_word(const uint16_t *addr) { | ||
| 34 | const uint8_t *p = (const uint8_t *)addr; | ||
| 35 | return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8); | ||
| 36 | } | ||
| 37 | |||
| 38 | uint32_t eeprom_read_dword(const uint32_t *addr) { | ||
| 39 | const uint8_t *p = (const uint8_t *)addr; | ||
| 40 | return eeprom_read_byte(p) | (eeprom_read_byte(p+1) << 8) | ||
| 41 | | (eeprom_read_byte(p+2) << 16) | (eeprom_read_byte(p+3) << 24); | ||
| 42 | } | ||
| 43 | |||
| 44 | void eeprom_read_block(void *buf, const void *addr, uint32_t len) { | ||
| 45 | const uint8_t *p = (const uint8_t *)addr; | ||
| 46 | uint8_t *dest = (uint8_t *)buf; | ||
| 47 | while (len--) { | ||
| 48 | *dest++ = eeprom_read_byte(p++); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | void eeprom_write_word(uint16_t *addr, uint16_t value) { | ||
| 53 | uint8_t *p = (uint8_t *)addr; | ||
| 54 | eeprom_write_byte(p++, value); | ||
| 55 | eeprom_write_byte(p, value >> 8); | ||
| 56 | } | ||
| 57 | |||
| 58 | void eeprom_write_dword(uint32_t *addr, uint32_t value) { | ||
| 59 | uint8_t *p = (uint8_t *)addr; | ||
| 60 | eeprom_write_byte(p++, value); | ||
| 61 | eeprom_write_byte(p++, value >> 8); | ||
| 62 | eeprom_write_byte(p++, value >> 16); | ||
| 63 | eeprom_write_byte(p, value >> 24); | ||
| 64 | } | ||
| 65 | |||
| 66 | void eeprom_write_block(const void *buf, void *addr, uint32_t len) { | ||
| 67 | uint8_t *p = (uint8_t *)addr; | ||
| 68 | const uint8_t *src = (const uint8_t *)buf; | ||
| 69 | while (len--) { | ||
| 70 | eeprom_write_byte(p++, *src++); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | void eeprom_update_byte(uint8_t *addr, uint8_t value) { | ||
| 75 | eeprom_write_byte(addr, value); | ||
| 76 | } | ||
| 77 | |||
| 78 | void eeprom_update_word(uint16_t *addr, uint16_t value) { | ||
| 79 | uint8_t *p = (uint8_t *)addr; | ||
| 80 | eeprom_write_byte(p++, value); | ||
| 81 | eeprom_write_byte(p, value >> 8); | ||
| 82 | } | ||
| 83 | |||
| 84 | void eeprom_update_dword(uint32_t *addr, uint32_t value) { | ||
| 85 | uint8_t *p = (uint8_t *)addr; | ||
| 86 | eeprom_write_byte(p++, value); | ||
| 87 | eeprom_write_byte(p++, value >> 8); | ||
| 88 | eeprom_write_byte(p++, value >> 16); | ||
| 89 | eeprom_write_byte(p, value >> 24); | ||
| 90 | } | ||
| 91 | |||
| 92 | void eeprom_update_block(const void *buf, void *addr, uint32_t len) { | ||
| 93 | uint8_t *p = (uint8_t *)addr; | ||
| 94 | const uint8_t *src = (const uint8_t *)buf; | ||
| 95 | while (len--) { | ||
| 96 | eeprom_write_byte(p++, *src++); | ||
| 97 | } | ||
| 98 | } | ||
diff --git a/tmk_core/common/test/suspend.c b/tmk_core/common/test/suspend.c new file mode 100644 index 000000000..01d1930ea --- /dev/null +++ b/tmk_core/common/test/suspend.c | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | |||
diff --git a/tmk_core/common/test/timer.c b/tmk_core/common/test/timer.c new file mode 100644 index 000000000..09ea91a89 --- /dev/null +++ b/tmk_core/common/test/timer.c | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | /* Copyright 2017 Fred Sundvik | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "timer.h" | ||
| 18 | |||
| 19 | // TODO: the timer should work, but at a much faster rate than realtime | ||
| 20 | // It should also have some kind of integration with the testing system | ||
| 21 | |||
| 22 | void timer_init(void) {} | ||
| 23 | |||
| 24 | void timer_clear(void) {} | ||
| 25 | |||
| 26 | uint16_t timer_read(void) { return 0; } | ||
| 27 | uint32_t timer_read32(void) { return 0; } | ||
| 28 | uint16_t timer_elapsed(uint16_t last) { return 0; } | ||
| 29 | uint32_t timer_elapsed32(uint32_t last) { return 0; } | ||
| 30 | |||
diff --git a/tmk_core/common/wait.h b/tmk_core/common/wait.h index 82727be01..911c9ddb5 100644 --- a/tmk_core/common/wait.h +++ b/tmk_core/common/wait.h | |||
| @@ -9,13 +9,16 @@ extern "C" { | |||
| 9 | # include <util/delay.h> | 9 | # include <util/delay.h> |
| 10 | # define wait_ms(ms) _delay_ms(ms) | 10 | # define wait_ms(ms) _delay_ms(ms) |
| 11 | # define wait_us(us) _delay_us(us) | 11 | # define wait_us(us) _delay_us(us) |
| 12 | #elif defined(PROTOCOL_CHIBIOS) /* __AVR__ */ | 12 | #elif defined(PROTOCOL_CHIBIOS) |
| 13 | # include "ch.h" | 13 | # include "ch.h" |
| 14 | # define wait_ms(ms) chThdSleepMilliseconds(ms) | 14 | # define wait_ms(ms) chThdSleepMilliseconds(ms) |
| 15 | # define wait_us(us) chThdSleepMicroseconds(us) | 15 | # define wait_us(us) chThdSleepMicroseconds(us) |
| 16 | #elif defined(__arm__) /* __AVR__ */ | 16 | #elif defined(__arm__) |
| 17 | # include "wait_api.h" | 17 | # include "wait_api.h" |
| 18 | #endif /* __AVR__ */ | 18 | #else // Unit tests |
| 19 | #define wait_ms(ms) | ||
| 20 | #define wait_us(us) | ||
| 21 | #endif | ||
| 19 | 22 | ||
| 20 | #ifdef __cplusplus | 23 | #ifdef __cplusplus |
| 21 | } | 24 | } |
