diff options
Diffstat (limited to 'tmk_core')
29 files changed, 299 insertions, 75 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index 690154535..d942e7ade 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk | |||
| @@ -237,6 +237,15 @@ endef | |||
| 237 | bootloadHID: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware | 237 | bootloadHID: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware |
| 238 | $(call EXEC_BOOTLOADHID) | 238 | $(call EXEC_BOOTLOADHID) |
| 239 | 239 | ||
| 240 | HID_BOOTLOADER_CLI ?= hid_bootloader_cli | ||
| 241 | |||
| 242 | define EXEC_HID_LUFA | ||
| 243 | $(HID_BOOTLOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex | ||
| 244 | endef | ||
| 245 | |||
| 246 | hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware | ||
| 247 | $(call EXEC_HID_LUFA) | ||
| 248 | |||
| 240 | # Convert hex to bin. | 249 | # Convert hex to bin. |
| 241 | bin: $(BUILD_DIR)/$(TARGET).hex | 250 | bin: $(BUILD_DIR)/$(TARGET).hex |
| 242 | $(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin | 251 | $(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
| @@ -295,19 +304,26 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf | |||
| 295 | @$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof | 304 | @$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof |
| 296 | $(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof | 305 | $(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof |
| 297 | 306 | ||
| 298 | bootloader: | 307 | ifeq ($(strip $(BOOTLOADER)), qmk-dfu) |
| 299 | ifneq ($(strip $(BOOTLOADER)), qmk-dfu) | 308 | QMK_BOOTLOADER_TYPE = DFU |
| 300 | $(error Please set BOOTLOADER = qmk-dfu first!) | 309 | else ifeq ($(strip $(BOOTLOADER)), qmk-hid) |
| 310 | QMK_BOOTLOADER_TYPE = HID | ||
| 301 | endif | 311 | endif |
| 302 | make -C lib/lufa/Bootloaders/DFU/ clean | 312 | |
| 303 | $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h | 313 | bootloader: |
| 304 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) | 314 | ifeq ($(strip $(QMK_BOOTLOADER_TYPE)),) |
| 315 | $(error Please set BOOTLOADER to "qmk-dfu" or "qmk-hid" first!) | ||
| 316 | else | ||
| 317 | make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ clean | ||
| 318 | $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Keyboard.h | ||
| 319 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) | ||
| 305 | $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) | 320 | $(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0)) |
| 306 | $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) | 321 | $(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0)) |
| 307 | $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) | 322 | $(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0)) |
| 308 | make -C lib/lufa/Bootloaders/DFU/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB) | 323 | make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB) |
| 309 | printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n" | 324 | printf "Bootloader$(QMK_BOOTLOADER_TYPE).hex copied to $(TARGET)_bootloader.hex\n" |
| 310 | cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex | 325 | cp lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Bootloader$(QMK_BOOTLOADER_TYPE).hex $(TARGET)_bootloader.hex |
| 326 | endif | ||
| 311 | 327 | ||
| 312 | production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware | 328 | production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware |
| 313 | @cat $(BUILD_DIR)/$(TARGET).hex | awk '/^:00000001FF/ == 0' > $(TARGET)_production.hex | 329 | @cat $(BUILD_DIR)/$(TARGET).hex | awk '/^:00000001FF/ == 0' > $(TARGET)_production.hex |
| @@ -328,6 +344,8 @@ else ifeq ($(strip $(BOOTLOADER)), USBasp) | |||
| 328 | $(call EXEC_USBASP) | 344 | $(call EXEC_USBASP) |
| 329 | else ifeq ($(strip $(BOOTLOADER)), bootloadHID) | 345 | else ifeq ($(strip $(BOOTLOADER)), bootloadHID) |
| 330 | $(call EXEC_BOOTLOADHID) | 346 | $(call EXEC_BOOTLOADHID) |
| 347 | else ifeq ($(strip $(BOOTLOADER)), qmk-hid) | ||
| 348 | $(call EXEC_HID_LUFA) | ||
| 331 | else | 349 | else |
| 332 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" | 350 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" |
| 333 | endif | 351 | endif |
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 97299b7d3..7eda36046 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk | |||
| @@ -390,8 +390,10 @@ ifndef TEENSY_LOADER_CLI | |||
| 390 | endif | 390 | endif |
| 391 | endif | 391 | endif |
| 392 | 392 | ||
| 393 | TEENSY_LOADER_CLI_MCU ?= $(MCU_LDSCRIPT) | ||
| 394 | |||
| 393 | define EXEC_TEENSY | 395 | define EXEC_TEENSY |
| 394 | $(TEENSY_LOADER_CLI) -mmcu=$(MCU_LDSCRIPT) -w -v $(BUILD_DIR)/$(TARGET).hex | 396 | $(TEENSY_LOADER_CLI) -mmcu=$(TEENSY_LOADER_CLI_MCU) -w -v $(BUILD_DIR)/$(TARGET).hex |
| 395 | endef | 397 | endef |
| 396 | 398 | ||
| 397 | teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter | 399 | teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter |
| @@ -408,6 +410,8 @@ else ifeq ($(strip $(BOOTLOADER)),kiibohd) | |||
| 408 | $(call EXEC_DFU_UTIL) | 410 | $(call EXEC_DFU_UTIL) |
| 409 | else ifeq ($(strip $(MCU_FAMILY)),KINETIS) | 411 | else ifeq ($(strip $(MCU_FAMILY)),KINETIS) |
| 410 | $(call EXEC_TEENSY) | 412 | $(call EXEC_TEENSY) |
| 413 | else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062) | ||
| 414 | $(call EXEC_TEENSY) | ||
| 411 | else ifeq ($(strip $(MCU_FAMILY)),STM32) | 415 | else ifeq ($(strip $(MCU_FAMILY)),STM32) |
| 412 | $(call EXEC_DFU_UTIL) | 416 | $(call EXEC_DFU_UTIL) |
| 413 | else | 417 | else |
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index af2d7d964..ed1a4bd20 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c | |||
| @@ -131,32 +131,32 @@ bool layer_state_cmp(layer_state_t cmp_layer_state, uint8_t layer) { | |||
| 131 | if (!cmp_layer_state) { | 131 | if (!cmp_layer_state) { |
| 132 | return layer == 0; | 132 | return layer == 0; |
| 133 | } | 133 | } |
| 134 | return (cmp_layer_state & (1UL << layer)) != 0; | 134 | return (cmp_layer_state & ((layer_state_t)1 << layer)) != 0; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | /** \brief Layer move | 137 | /** \brief Layer move |
| 138 | * | 138 | * |
| 139 | * Turns on the given layer and turn off all other layers | 139 | * Turns on the given layer and turn off all other layers |
| 140 | */ | 140 | */ |
| 141 | void layer_move(uint8_t layer) { layer_state_set(1UL << layer); } | 141 | void layer_move(uint8_t layer) { layer_state_set((layer_state_t)1 << layer); } |
| 142 | 142 | ||
| 143 | /** \brief Layer on | 143 | /** \brief Layer on |
| 144 | * | 144 | * |
| 145 | * Turns on given layer | 145 | * Turns on given layer |
| 146 | */ | 146 | */ |
| 147 | void layer_on(uint8_t layer) { layer_state_set(layer_state | (1UL << layer)); } | 147 | void layer_on(uint8_t layer) { layer_state_set(layer_state | ((layer_state_t)1 << layer)); } |
| 148 | 148 | ||
| 149 | /** \brief Layer off | 149 | /** \brief Layer off |
| 150 | * | 150 | * |
| 151 | * Turns off given layer | 151 | * Turns off given layer |
| 152 | */ | 152 | */ |
| 153 | void layer_off(uint8_t layer) { layer_state_set(layer_state & ~(1UL << layer)); } | 153 | void layer_off(uint8_t layer) { layer_state_set(layer_state & ~((layer_state_t)1 << layer)); } |
| 154 | 154 | ||
| 155 | /** \brief Layer invert | 155 | /** \brief Layer invert |
| 156 | * | 156 | * |
| 157 | * Toggle the given layer (set it if it's unset, or unset it if it's set) | 157 | * Toggle the given layer (set it if it's unset, or unset it if it's set) |
| 158 | */ | 158 | */ |
| 159 | void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ (1UL << layer)); } | 159 | void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ ((layer_state_t)1 << layer)); } |
| 160 | 160 | ||
| 161 | /** \brief Layer or | 161 | /** \brief Layer or |
| 162 | * | 162 | * |
| @@ -258,7 +258,7 @@ uint8_t layer_switch_get_layer(keypos_t key) { | |||
| 258 | layer_state_t layers = layer_state | default_layer_state; | 258 | layer_state_t layers = layer_state | default_layer_state; |
| 259 | /* check top layer first */ | 259 | /* check top layer first */ |
| 260 | for (int8_t i = MAX_LAYER - 1; i >= 0; i--) { | 260 | for (int8_t i = MAX_LAYER - 1; i >= 0; i--) { |
| 261 | if (layers & (1UL << i)) { | 261 | if (layers & ((layer_state_t)1 << i)) { |
| 262 | action = action_for_key(i, key); | 262 | action = action_for_key(i, key); |
| 263 | if (action.code != ACTION_TRANSPARENT) { | 263 | if (action.code != ACTION_TRANSPARENT) { |
| 264 | return i; | 264 | return i; |
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index d72cd3e3a..b87d096ee 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h | |||
| @@ -21,6 +21,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
| 22 | #include "action.h" | 22 | #include "action.h" |
| 23 | 23 | ||
| 24 | #ifdef DYNAMIC_KEYMAP_ENABLE | ||
| 25 | # ifndef DYNAMIC_KEYMAP_LAYER_COUNT | ||
| 26 | # define DYNAMIC_KEYMAP_LAYER_COUNT 4 | ||
| 27 | # endif | ||
| 28 | # if DYNAMIC_KEYMAP_LAYER_COUNT <= 8 | ||
| 29 | # ifndef LAYER_STATE_8BIT | ||
| 30 | # define LAYER_STATE_8BIT | ||
| 31 | # endif | ||
| 32 | # elif DYNAMIC_KEYMAP_LAYER_COUNT <= 16 | ||
| 33 | # ifndef LAYER_STATE_16BIT | ||
| 34 | # define LAYER_STATE_16BIT | ||
| 35 | # endif | ||
| 36 | # else | ||
| 37 | # ifndef LAYER_STATE_32BIT | ||
| 38 | # define LAYER_STATE_32BIT | ||
| 39 | # endif | ||
| 40 | # endif | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #if !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_32BIT) | ||
| 44 | # define LAYER_STATE_32BIT | ||
| 45 | #endif | ||
| 46 | |||
| 24 | #if defined(LAYER_STATE_8BIT) | 47 | #if defined(LAYER_STATE_8BIT) |
| 25 | typedef uint8_t layer_state_t; | 48 | typedef uint8_t layer_state_t; |
| 26 | # define MAX_LAYER_BITS 3 | 49 | # define MAX_LAYER_BITS 3 |
| @@ -35,13 +58,15 @@ typedef uint16_t layer_state_t; | |||
| 35 | # define MAX_LAYER 16 | 58 | # define MAX_LAYER 16 |
| 36 | # endif | 59 | # endif |
| 37 | # define get_highest_layer(state) biton16(state) | 60 | # define get_highest_layer(state) biton16(state) |
| 38 | #else | 61 | #elif defined(LAYER_STATE_32BIT) |
| 39 | typedef uint32_t layer_state_t; | 62 | typedef uint32_t layer_state_t; |
| 40 | # define MAX_LAYER_BITS 5 | 63 | # define MAX_LAYER_BITS 5 |
| 41 | # ifndef MAX_LAYER | 64 | # ifndef MAX_LAYER |
| 42 | # define MAX_LAYER 32 | 65 | # define MAX_LAYER 32 |
| 43 | # endif | 66 | # endif |
| 44 | # define get_highest_layer(state) biton32(state) | 67 | # define get_highest_layer(state) biton32(state) |
| 68 | #else | ||
| 69 | # error Layer Mask size not specified. HOW?! | ||
| 45 | #endif | 70 | #endif |
| 46 | 71 | ||
| 47 | /* | 72 | /* |
| @@ -92,7 +117,7 @@ layer_state_t layer_state_set_kb(layer_state_t state); | |||
| 92 | 117 | ||
| 93 | # define layer_state_set(layer) | 118 | # define layer_state_set(layer) |
| 94 | # define layer_state_is(layer) (layer == 0) | 119 | # define layer_state_is(layer) (layer == 0) |
| 95 | # define layer_state_cmp(state, layer) (state == 0 ? layer == 0 : (state & 1UL << layer) != 0) | 120 | # define layer_state_cmp(state, layer) (state == 0 ? layer == 0 : (state & (layer_state_t)1 << layer) != 0) |
| 96 | 121 | ||
| 97 | # define layer_debug() | 122 | # define layer_debug() |
| 98 | # define layer_clear() | 123 | # define layer_clear() |
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index a57c8bf66..2b3c00cba 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
| @@ -27,6 +27,10 @@ extern keymap_config_t keymap_config; | |||
| 27 | static uint8_t real_mods = 0; | 27 | static uint8_t real_mods = 0; |
| 28 | static uint8_t weak_mods = 0; | 28 | static uint8_t weak_mods = 0; |
| 29 | static uint8_t macro_mods = 0; | 29 | static uint8_t macro_mods = 0; |
| 30 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 31 | static uint8_t weak_override_mods = 0; | ||
| 32 | static uint8_t suppressed_mods = 0; | ||
| 33 | #endif | ||
| 30 | 34 | ||
| 31 | #ifdef USB_6KRO_ENABLE | 35 | #ifdef USB_6KRO_ENABLE |
| 32 | # define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS) | 36 | # define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS) |
| @@ -229,6 +233,7 @@ void send_keyboard_report(void) { | |||
| 229 | keyboard_report->mods = real_mods; | 233 | keyboard_report->mods = real_mods; |
| 230 | keyboard_report->mods |= weak_mods; | 234 | keyboard_report->mods |= weak_mods; |
| 231 | keyboard_report->mods |= macro_mods; | 235 | keyboard_report->mods |= macro_mods; |
| 236 | |||
| 232 | #ifndef NO_ACTION_ONESHOT | 237 | #ifndef NO_ACTION_ONESHOT |
| 233 | if (oneshot_mods) { | 238 | if (oneshot_mods) { |
| 234 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 239 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
| @@ -244,6 +249,13 @@ void send_keyboard_report(void) { | |||
| 244 | } | 249 | } |
| 245 | 250 | ||
| 246 | #endif | 251 | #endif |
| 252 | |||
| 253 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 254 | // These need to be last to be able to properly control key overrides | ||
| 255 | keyboard_report->mods &= ~suppressed_mods; | ||
| 256 | keyboard_report->mods |= weak_override_mods; | ||
| 257 | #endif | ||
| 258 | |||
| 247 | host_keyboard_send(keyboard_report); | 259 | host_keyboard_send(keyboard_report); |
| 248 | } | 260 | } |
| 249 | 261 | ||
| @@ -299,6 +311,22 @@ void set_weak_mods(uint8_t mods) { weak_mods = mods; } | |||
| 299 | */ | 311 | */ |
| 300 | void clear_weak_mods(void) { weak_mods = 0; } | 312 | void clear_weak_mods(void) { weak_mods = 0; } |
| 301 | 313 | ||
| 314 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 315 | /** \brief set weak mods used by key overrides. DO not call this manually | ||
| 316 | */ | ||
| 317 | void set_weak_override_mods(uint8_t mods) { weak_override_mods = mods; } | ||
| 318 | /** \brief clear weak mods used by key overrides. DO not call this manually | ||
| 319 | */ | ||
| 320 | void clear_weak_override_mods(void) { weak_override_mods = 0; } | ||
| 321 | |||
| 322 | /** \brief set suppressed mods used by key overrides. DO not call this manually | ||
| 323 | */ | ||
| 324 | void set_suppressed_override_mods(uint8_t mods) { suppressed_mods = mods; } | ||
| 325 | /** \brief clear suppressed mods used by key overrides. DO not call this manually | ||
| 326 | */ | ||
| 327 | void clear_suppressed_override_mods(void) { suppressed_mods = 0; } | ||
| 328 | #endif | ||
| 329 | |||
| 302 | /* macro modifier */ | 330 | /* macro modifier */ |
| 303 | /** \brief get macro mods | 331 | /** \brief get macro mods |
| 304 | * | 332 | * |
diff --git a/tmk_core/common/arm_atsam/_timer.h b/tmk_core/common/arm_atsam/_timer.h new file mode 100644 index 000000000..77402b612 --- /dev/null +++ b/tmk_core/common/arm_atsam/_timer.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* Copyright 2021 Simon Arlott | ||
| 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 | #pragma once | ||
| 17 | |||
| 18 | // The platform is 32-bit, so prefer 32-bit timers to avoid overflow | ||
| 19 | #define FAST_TIMER_T_SIZE 32 | ||
diff --git a/tmk_core/common/avr/_timer.h b/tmk_core/common/avr/_timer.h new file mode 100644 index 000000000..b81e0f68b --- /dev/null +++ b/tmk_core/common/avr/_timer.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* Copyright 2021 Simon Arlott | ||
| 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 | #pragma once | ||
| 17 | |||
| 18 | // The platform is 8-bit, so prefer 16-bit timers to reduce code size | ||
| 19 | #define FAST_TIMER_T_SIZE 16 | ||
diff --git a/tmk_core/common/avr/gpio.h b/tmk_core/common/avr/gpio.h index 231556c29..e9be68491 100644 --- a/tmk_core/common/avr/gpio.h +++ b/tmk_core/common/avr/gpio.h | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | 20 | ||
| 21 | typedef uint8_t pin_t; | 21 | typedef uint8_t pin_t; |
| 22 | 22 | ||
| 23 | /* Operation of GPIO by pin. */ | ||
| 24 | |||
| 23 | #define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) | 25 | #define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) |
| 24 | #define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) | 26 | #define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) |
| 25 | #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") | 27 | #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") |
| @@ -32,3 +34,16 @@ typedef uint8_t pin_t; | |||
| 32 | #define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF))) | 34 | #define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF))) |
| 33 | 35 | ||
| 34 | #define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF)) | 36 | #define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF)) |
| 37 | |||
| 38 | /* Operation of GPIO by port. */ | ||
| 39 | |||
| 40 | typedef uint8_t port_data_t; | ||
| 41 | |||
| 42 | #define readPort(port) PINx_ADDRESS(port) | ||
| 43 | |||
| 44 | #define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF)) | ||
| 45 | #define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF)) | ||
| 46 | #define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF)) | ||
| 47 | |||
| 48 | #define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF)) | ||
| 49 | #define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF)) | ||
diff --git a/tmk_core/common/chibios/_timer.h b/tmk_core/common/chibios/_timer.h new file mode 100644 index 000000000..77402b612 --- /dev/null +++ b/tmk_core/common/chibios/_timer.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* Copyright 2021 Simon Arlott | ||
| 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 | #pragma once | ||
| 17 | |||
| 18 | // The platform is 32-bit, so prefer 32-bit timers to avoid overflow | ||
| 19 | #define FAST_TIMER_T_SIZE 32 | ||
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c index 11f7abf43..f9514ee5f 100644 --- a/tmk_core/common/chibios/bootloader.c +++ b/tmk_core/common/chibios/bootloader.c | |||
| @@ -95,7 +95,7 @@ void enter_bootloader_mode_if_requested(void) { | |||
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | #elif defined(KL2x) || defined(K20x) || defined(MK66F18) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS | 98 | #elif defined(KL2x) || defined(K20x) || defined(MK66F18) || defined(MIMXRT1062) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS |
| 99 | /* Kinetis */ | 99 | /* Kinetis */ |
| 100 | 100 | ||
| 101 | # if defined(BOOTLOADER_KIIBOHD) | 101 | # if defined(BOOTLOADER_KIIBOHD) |
| @@ -103,7 +103,8 @@ void enter_bootloader_mode_if_requested(void) { | |||
| 103 | # define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000 | 103 | # define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000 |
| 104 | const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff"; | 104 | const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff"; |
| 105 | __attribute__((weak)) void bootloader_jump(void) { | 105 | __attribute__((weak)) void bootloader_jump(void) { |
| 106 | __builtin_memcpy((void *)VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic)); | 106 | void *volatile vbat = (void *)VBAT; |
| 107 | __builtin_memcpy(vbat, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic)); | ||
| 107 | // request reset | 108 | // request reset |
| 108 | SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk; | 109 | SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk; |
| 109 | } | 110 | } |
diff --git a/tmk_core/common/chibios/gpio.h b/tmk_core/common/chibios/gpio.h index 5d0e142ab..4d057f1ca 100644 --- a/tmk_core/common/chibios/gpio.h +++ b/tmk_core/common/chibios/gpio.h | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | 20 | ||
| 21 | typedef ioline_t pin_t; | 21 | typedef ioline_t pin_t; |
| 22 | 22 | ||
| 23 | /* Operation of GPIO by pin. */ | ||
| 24 | |||
| 23 | #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT) | 25 | #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT) |
| 24 | #define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP) | 26 | #define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP) |
| 25 | #define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN) | 27 | #define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN) |
| @@ -32,3 +34,17 @@ typedef ioline_t pin_t; | |||
| 32 | #define readPin(pin) palReadLine(pin) | 34 | #define readPin(pin) palReadLine(pin) |
| 33 | 35 | ||
| 34 | #define togglePin(pin) palToggleLine(pin) | 36 | #define togglePin(pin) palToggleLine(pin) |
| 37 | |||
| 38 | /* Operation of GPIO by port. */ | ||
| 39 | |||
| 40 | typedef uint16_t port_data_t; | ||
| 41 | |||
| 42 | #define readPort(pin) palReadPort(PAL_PORT(pin)) | ||
| 43 | |||
| 44 | #define setPortBitInput(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT) | ||
| 45 | #define setPortBitInputHigh(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT_PULLUP) | ||
| 46 | #define setPortBitInputLow(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_INPUT_PULLDOWN) | ||
| 47 | #define setPortBitOutput(pin, bit) palSetPadMode(PAL_PORT(pin), bit, PAL_MODE_OUTPUT_PUSHPULL) | ||
| 48 | |||
| 49 | #define writePortBitLow(pin, bit) palClearLine(PAL_LINE(PAL_PORT(pin), bit)) | ||
| 50 | #define writePortBitHigh(pin, bit) palSetLine(PAL_LINE(PAL_PORT(pin), bit)) | ||
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index e7d92cfac..a8b391e89 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c | |||
| @@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 17 | ||
| 18 | #include <stdint.h> | 18 | #include <stdint.h> |
| 19 | //#include <avr/interrupt.h> | 19 | //#include <avr/interrupt.h> |
| 20 | #include "keyboard.h" | ||
| 20 | #include "keycode.h" | 21 | #include "keycode.h" |
| 21 | #include "host.h" | 22 | #include "host.h" |
| 22 | #include "util.h" | 23 | #include "util.h" |
| @@ -35,15 +36,20 @@ void host_set_driver(host_driver_t *d) { driver = d; } | |||
| 35 | 36 | ||
| 36 | host_driver_t *host_get_driver(void) { return driver; } | 37 | host_driver_t *host_get_driver(void) { return driver; } |
| 37 | 38 | ||
| 39 | #ifdef SPLIT_KEYBOARD | ||
| 40 | uint8_t split_led_state = 0; | ||
| 41 | void set_split_host_keyboard_leds(uint8_t led_state) { split_led_state = led_state; } | ||
| 42 | #endif | ||
| 43 | |||
| 38 | uint8_t host_keyboard_leds(void) { | 44 | uint8_t host_keyboard_leds(void) { |
| 45 | #ifdef SPLIT_KEYBOARD | ||
| 46 | if (!is_keyboard_master()) return split_led_state; | ||
| 47 | #endif | ||
| 39 | if (!driver) return 0; | 48 | if (!driver) return 0; |
| 40 | return (*driver->keyboard_leds)(); | 49 | return (*driver->keyboard_leds)(); |
| 41 | } | 50 | } |
| 42 | 51 | ||
| 43 | led_t host_keyboard_led_state(void) { | 52 | led_t host_keyboard_led_state(void) { return (led_t)host_keyboard_leds(); } |
| 44 | if (!driver) return (led_t){0}; | ||
| 45 | return (led_t)((*driver->keyboard_leds)()); | ||
| 46 | } | ||
| 47 | 53 | ||
| 48 | /* send report */ | 54 | /* send report */ |
| 49 | void host_keyboard_send(report_keyboard_t *report) { | 55 | void host_keyboard_send(report_keyboard_t *report) { |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 3d6092e71..28fa97bc8 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -85,6 +85,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 85 | #ifdef OLED_DRIVER_ENABLE | 85 | #ifdef OLED_DRIVER_ENABLE |
| 86 | # include "oled_driver.h" | 86 | # include "oled_driver.h" |
| 87 | #endif | 87 | #endif |
| 88 | #ifdef ST7565_ENABLE | ||
| 89 | # include "st7565.h" | ||
| 90 | #endif | ||
| 88 | #ifdef VELOCIKEY_ENABLE | 91 | #ifdef VELOCIKEY_ENABLE |
| 89 | # include "velocikey.h" | 92 | # include "velocikey.h" |
| 90 | #endif | 93 | #endif |
| @@ -100,6 +103,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 100 | #ifdef EEPROM_DRIVER | 103 | #ifdef EEPROM_DRIVER |
| 101 | # include "eeprom_driver.h" | 104 | # include "eeprom_driver.h" |
| 102 | #endif | 105 | #endif |
| 106 | #if defined(CRC_ENABLE) | ||
| 107 | # include "crc.h" | ||
| 108 | #endif | ||
| 103 | 109 | ||
| 104 | static uint32_t last_input_modification_time = 0; | 110 | static uint32_t last_input_modification_time = 0; |
| 105 | uint32_t last_input_activity_time(void) { return last_input_modification_time; } | 111 | uint32_t last_input_activity_time(void) { return last_input_modification_time; } |
| @@ -297,6 +303,9 @@ void keyboard_init(void) { | |||
| 297 | timer_init(); | 303 | timer_init(); |
| 298 | sync_timer_init(); | 304 | sync_timer_init(); |
| 299 | matrix_init(); | 305 | matrix_init(); |
| 306 | #if defined(CRC_ENABLE) | ||
| 307 | crc_init(); | ||
| 308 | #endif | ||
| 300 | #ifdef VIA_ENABLE | 309 | #ifdef VIA_ENABLE |
| 301 | via_init(); | 310 | via_init(); |
| 302 | #endif | 311 | #endif |
| @@ -306,6 +315,9 @@ void keyboard_init(void) { | |||
| 306 | #ifdef OLED_DRIVER_ENABLE | 315 | #ifdef OLED_DRIVER_ENABLE |
| 307 | oled_init(OLED_ROTATION_0); | 316 | oled_init(OLED_ROTATION_0); |
| 308 | #endif | 317 | #endif |
| 318 | #ifdef ST7565_ENABLE | ||
| 319 | st7565_init(DISPLAY_ROTATION_0); | ||
| 320 | #endif | ||
| 309 | #ifdef PS2_MOUSE_ENABLE | 321 | #ifdef PS2_MOUSE_ENABLE |
| 310 | ps2_mouse_init(); | 322 | ps2_mouse_init(); |
| 311 | #endif | 323 | #endif |
| @@ -470,6 +482,18 @@ MATRIX_LOOP_END: | |||
| 470 | # endif | 482 | # endif |
| 471 | #endif | 483 | #endif |
| 472 | 484 | ||
| 485 | #ifdef ST7565_ENABLE | ||
| 486 | st7565_task(); | ||
| 487 | # ifndef ST7565_DISABLE_TIMEOUT | ||
| 488 | // Wake up display if user is using those fabulous keys or spinning those encoders! | ||
| 489 | # ifdef ENCODER_ENABLE | ||
| 490 | if (matrix_changed || encoders_changed) st7565_on(); | ||
| 491 | # else | ||
| 492 | if (matrix_changed) st7565_on(); | ||
| 493 | # endif | ||
| 494 | # endif | ||
| 495 | #endif | ||
| 496 | |||
| 473 | #ifdef MOUSEKEY_ENABLE | 497 | #ifdef MOUSEKEY_ENABLE |
| 474 | // mousekey repeat & acceleration | 498 | // mousekey repeat & acceleration |
| 475 | mousekey_task(); | 499 | mousekey_task(); |
diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h index 4e4771e52..3a7a16968 100644 --- a/tmk_core/common/progmem.h +++ b/tmk_core/common/progmem.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #if defined(__AVR__) | 3 | #if defined(__AVR__) |
| 4 | # include <avr/pgmspace.h> | 4 | # include <avr/pgmspace.h> |
| 5 | #else | 5 | #else |
| 6 | # include <string.h> | ||
| 6 | # define PROGMEM | 7 | # define PROGMEM |
| 7 | # define PSTR(x) x | 8 | # define PSTR(x) x |
| 8 | # define PGM_P const char* | 9 | # define PGM_P const char* |
diff --git a/tmk_core/common/sync_timer.c b/tmk_core/common/sync_timer.c index de24b463b..68b92d8b4 100644 --- a/tmk_core/common/sync_timer.c +++ b/tmk_core/common/sync_timer.c | |||
| @@ -26,7 +26,7 @@ SOFTWARE. | |||
| 26 | #include "sync_timer.h" | 26 | #include "sync_timer.h" |
| 27 | #include "keyboard.h" | 27 | #include "keyboard.h" |
| 28 | 28 | ||
| 29 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | 29 | #if (defined(SPLIT_KEYBOARD) || defined(SERIAL_LINK_ENABLE)) && !defined(DISABLE_SYNC_TIMER) |
| 30 | volatile int32_t sync_timer_ms; | 30 | volatile int32_t sync_timer_ms; |
| 31 | 31 | ||
| 32 | void sync_timer_init(void) { sync_timer_ms = 0; } | 32 | void sync_timer_init(void) { sync_timer_ms = 0; } |
diff --git a/tmk_core/common/sync_timer.h b/tmk_core/common/sync_timer.h index 9ddef45bb..744e2b50d 100644 --- a/tmk_core/common/sync_timer.h +++ b/tmk_core/common/sync_timer.h | |||
| @@ -32,7 +32,7 @@ SOFTWARE. | |||
| 32 | extern "C" { | 32 | extern "C" { |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | 35 | #if (defined(SPLIT_KEYBOARD) || defined(SERIAL_LINK_ENABLE)) && !defined(DISABLE_SYNC_TIMER) |
| 36 | void sync_timer_init(void); | 36 | void sync_timer_init(void); |
| 37 | void sync_timer_update(uint32_t time); | 37 | void sync_timer_update(uint32_t time); |
| 38 | uint16_t sync_timer_read(void); | 38 | uint16_t sync_timer_read(void); |
diff --git a/tmk_core/common/timer.h b/tmk_core/common/timer.h index abddcea85..02e39e79e 100644 --- a/tmk_core/common/timer.h +++ b/tmk_core/common/timer.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> |
| 3 | Copyright 2021 Simon Arlott | ||
| 3 | 4 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 5 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
| @@ -17,6 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 17 | 18 | ||
| 18 | #pragma once | 19 | #pragma once |
| 19 | 20 | ||
| 21 | #if __has_include_next("_timer.h") | ||
| 22 | # include_next "_timer.h" /* Include the platform's _timer.h */ | ||
| 23 | #endif | ||
| 24 | |||
| 20 | #include <stdint.h> | 25 | #include <stdint.h> |
| 21 | 26 | ||
| 22 | #define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a))))) | 27 | #define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a))))) |
| @@ -42,6 +47,21 @@ uint32_t timer_elapsed32(uint32_t last); | |||
| 42 | #define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2) | 47 | #define timer_expired(current, future) ((uint16_t)(current - future) < UINT16_MAX / 2) |
| 43 | #define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2) | 48 | #define timer_expired32(current, future) ((uint32_t)(current - future) < UINT32_MAX / 2) |
| 44 | 49 | ||
| 50 | // Use an appropriate timer integer size based on architecture (16-bit will overflow sooner) | ||
| 51 | #if FAST_TIMER_T_SIZE < 32 | ||
| 52 | # define TIMER_DIFF_FAST(a, b) TIMER_DIFF_16(a, b) | ||
| 53 | # define timer_expired_fast(current, future) timer_expired(current, future) | ||
| 54 | typedef uint16_t fast_timer_t; | ||
| 55 | fast_timer_t inline timer_read_fast(void) { return timer_read(); } | ||
| 56 | fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed(last); } | ||
| 57 | #else | ||
| 58 | # define TIMER_DIFF_FAST(a, b) TIMER_DIFF_32(a, b) | ||
| 59 | # define timer_expired_fast(current, future) timer_expired32(current, future) | ||
| 60 | typedef uint32_t fast_timer_t; | ||
| 61 | fast_timer_t inline timer_read_fast(void) { return timer_read32(); } | ||
| 62 | fast_timer_t inline timer_elapsed_fast(fast_timer_t last) { return timer_elapsed32(last); } | ||
| 63 | #endif | ||
| 64 | |||
| 45 | #ifdef __cplusplus | 65 | #ifdef __cplusplus |
| 46 | } | 66 | } |
| 47 | #endif | 67 | #endif |
diff --git a/tmk_core/common/usb_util.c b/tmk_core/common/usb_util.c index d4134a044..dd1deeaa1 100644 --- a/tmk_core/common/usb_util.c +++ b/tmk_core/common/usb_util.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include "quantum.h" | 16 | #include "quantum.h" |
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | 18 | ||
| 19 | __attribute__((weak)) void usb_disable(void) {} | 19 | __attribute__((weak)) void usb_disconnect(void) {} |
| 20 | __attribute__((weak)) bool usb_connected_state(void) { return true; } | 20 | __attribute__((weak)) bool usb_connected_state(void) { return true; } |
| 21 | __attribute__((weak)) bool usb_vbus_state(void) { | 21 | __attribute__((weak)) bool usb_vbus_state(void) { |
| 22 | #ifdef USB_VBUS_PIN | 22 | #ifdef USB_VBUS_PIN |
diff --git a/tmk_core/common/usb_util.h b/tmk_core/common/usb_util.h index 4ebedb1e7..13db9fbfb 100644 --- a/tmk_core/common/usb_util.h +++ b/tmk_core/common/usb_util.h | |||
| @@ -17,6 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | #include <stdbool.h> | 18 | #include <stdbool.h> |
| 19 | 19 | ||
| 20 | void usb_disable(void); | 20 | void usb_disconnect(void); |
| 21 | bool usb_connected_state(void); | 21 | bool usb_connected_state(void); |
| 22 | bool usb_vbus_state(void); | 22 | bool usb_vbus_state(void); |
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h index 9c9d94789..1c0983115 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h | |||
| @@ -23,6 +23,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 23 | #include "compiler.h" | 23 | #include "compiler.h" |
| 24 | #include "usb_protocol_hid.h" | 24 | #include "usb_protocol_hid.h" |
| 25 | 25 | ||
| 26 | #ifndef USB_POLLING_INTERVAL_MS | ||
| 27 | # define USB_POLLING_INTERVAL_MS 10 | ||
| 28 | #endif | ||
| 29 | |||
| 26 | #ifdef VIRTSER_ENABLE | 30 | #ifdef VIRTSER_ENABLE |
| 27 | // because CDC uses IAD (interface association descriptor | 31 | // because CDC uses IAD (interface association descriptor |
| 28 | // per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0) | 32 | // per USB Interface Association Descriptor Device Class Code and Use Model 7/23/2003 Rev 1.0) |
| @@ -118,7 +122,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 118 | #define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM | 122 | #define UDI_HID_KBD_EP_IN KEYBOARD_IN_EPNUM |
| 119 | #define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1) | 123 | #define NEXT_IN_EPNUM_1 (KEYBOARD_IN_EPNUM + 1) |
| 120 | #define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE | 124 | #define UDI_HID_KBD_EP_SIZE KEYBOARD_EPSIZE |
| 121 | #define KBD_POLLING_INTERVAL 10 | 125 | #define KBD_POLLING_INTERVAL USB_POLLING_INTERVAL_MS |
| 122 | #ifndef UDI_HID_KBD_STRING_ID | 126 | #ifndef UDI_HID_KBD_STRING_ID |
| 123 | # define UDI_HID_KBD_STRING_ID 0 | 127 | # define UDI_HID_KBD_STRING_ID 0 |
| 124 | #endif | 128 | #endif |
| @@ -128,7 +132,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 128 | # define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1) | 132 | # define NEXT_IN_EPNUM_2 (MOUSE_IN_EPNUM + 1) |
| 129 | # define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM | 133 | # define UDI_HID_MOU_EP_IN MOUSE_IN_EPNUM |
| 130 | # define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE | 134 | # define UDI_HID_MOU_EP_SIZE MOUSE_EPSIZE |
| 131 | # define MOU_POLLING_INTERVAL 10 | 135 | # define MOU_POLLING_INTERVAL USB_POLLING_INTERVAL_MS |
| 132 | # ifndef UDI_HID_MOU_STRING_ID | 136 | # ifndef UDI_HID_MOU_STRING_ID |
| 133 | # define UDI_HID_MOU_STRING_ID 0 | 137 | # define UDI_HID_MOU_STRING_ID 0 |
| 134 | # endif | 138 | # endif |
| @@ -141,7 +145,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 141 | # define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM | 145 | # define UDI_HID_EXK_EP_IN EXTRAKEY_IN_EPNUM |
| 142 | # define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1) | 146 | # define NEXT_IN_EPNUM_3 (EXTRAKEY_IN_EPNUM + 1) |
| 143 | # define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE | 147 | # define UDI_HID_EXK_EP_SIZE EXTRAKEY_EPSIZE |
| 144 | # define EXTRAKEY_POLLING_INTERVAL 10 | 148 | # define EXTRAKEY_POLLING_INTERVAL USB_POLLING_INTERVAL_MS |
| 145 | # ifndef UDI_HID_EXK_STRING_ID | 149 | # ifndef UDI_HID_EXK_STRING_ID |
| 146 | # define UDI_HID_EXK_STRING_ID 0 | 150 | # define UDI_HID_EXK_STRING_ID 0 |
| 147 | # endif | 151 | # endif |
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d04302aca..407b8ea75 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
| @@ -903,7 +903,8 @@ static void send_extra(uint8_t report_id, uint16_t data) { | |||
| 903 | return; | 903 | return; |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | report_extra_t report = {.report_id = report_id, .usage = data}; | 906 | static report_extra_t report; |
| 907 | report = (report_extra_t){.report_id = report_id, .usage = data}; | ||
| 907 | 908 | ||
| 908 | usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); | 909 | usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); |
| 909 | osalSysUnlock(); | 910 | osalSysUnlock(); |
| @@ -1051,45 +1052,44 @@ void virtser_task(void) { | |||
| 1051 | #ifdef JOYSTICK_ENABLE | 1052 | #ifdef JOYSTICK_ENABLE |
| 1052 | 1053 | ||
| 1053 | void send_joystick_packet(joystick_t *joystick) { | 1054 | void send_joystick_packet(joystick_t *joystick) { |
| 1054 | joystick_report_t rep = { | 1055 | static joystick_report_t rep; |
| 1056 | rep = (joystick_report_t) { | ||
| 1055 | # if JOYSTICK_AXES_COUNT > 0 | 1057 | # if JOYSTICK_AXES_COUNT > 0 |
| 1056 | .axes = | 1058 | .axes = |
| 1057 | { | 1059 | { joystick->axes[0], |
| 1058 | joystick->axes[0], | ||
| 1059 | 1060 | ||
| 1060 | # if JOYSTICK_AXES_COUNT >= 2 | 1061 | # if JOYSTICK_AXES_COUNT >= 2 |
| 1061 | joystick->axes[1], | 1062 | joystick->axes[1], |
| 1062 | # endif | 1063 | # endif |
| 1063 | # if JOYSTICK_AXES_COUNT >= 3 | 1064 | # if JOYSTICK_AXES_COUNT >= 3 |
| 1064 | joystick->axes[2], | 1065 | joystick->axes[2], |
| 1065 | # endif | 1066 | # endif |
| 1066 | # if JOYSTICK_AXES_COUNT >= 4 | 1067 | # if JOYSTICK_AXES_COUNT >= 4 |
| 1067 | joystick->axes[3], | 1068 | joystick->axes[3], |
| 1068 | # endif | 1069 | # endif |
| 1069 | # if JOYSTICK_AXES_COUNT >= 5 | 1070 | # if JOYSTICK_AXES_COUNT >= 5 |
| 1070 | joystick->axes[4], | 1071 | joystick->axes[4], |
| 1071 | # endif | 1072 | # endif |
| 1072 | # if JOYSTICK_AXES_COUNT >= 6 | 1073 | # if JOYSTICK_AXES_COUNT >= 6 |
| 1073 | joystick->axes[5], | 1074 | joystick->axes[5], |
| 1074 | # endif | 1075 | # endif |
| 1075 | }, | 1076 | }, |
| 1076 | # endif // JOYSTICK_AXES_COUNT>0 | 1077 | # endif // JOYSTICK_AXES_COUNT>0 |
| 1077 | 1078 | ||
| 1078 | # if JOYSTICK_BUTTON_COUNT > 0 | 1079 | # if JOYSTICK_BUTTON_COUNT > 0 |
| 1079 | .buttons = | 1080 | .buttons = { |
| 1080 | { | 1081 | joystick->buttons[0], |
| 1081 | joystick->buttons[0], | ||
| 1082 | 1082 | ||
| 1083 | # if JOYSTICK_BUTTON_COUNT > 8 | 1083 | # if JOYSTICK_BUTTON_COUNT > 8 |
| 1084 | joystick->buttons[1], | 1084 | joystick->buttons[1], |
| 1085 | # endif | 1085 | # endif |
| 1086 | # if JOYSTICK_BUTTON_COUNT > 16 | 1086 | # if JOYSTICK_BUTTON_COUNT > 16 |
| 1087 | joystick->buttons[2], | 1087 | joystick->buttons[2], |
| 1088 | # endif | 1088 | # endif |
| 1089 | # if JOYSTICK_BUTTON_COUNT > 24 | 1089 | # if JOYSTICK_BUTTON_COUNT > 24 |
| 1090 | joystick->buttons[3], | 1090 | joystick->buttons[3], |
| 1091 | # endif | 1091 | # endif |
| 1092 | } | 1092 | } |
| 1093 | # endif // JOYSTICK_BUTTON_COUNT>0 | 1093 | # endif // JOYSTICK_BUTTON_COUNT>0 |
| 1094 | }; | 1094 | }; |
| 1095 | 1095 | ||
diff --git a/tmk_core/protocol/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c index 5945e8a8d..e32d6ebfa 100644 --- a/tmk_core/protocol/chibios/usb_util.c +++ b/tmk_core/protocol/chibios/usb_util.c | |||
| @@ -16,6 +16,6 @@ | |||
| 16 | #include <hal.h> | 16 | #include <hal.h> |
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | 18 | ||
| 19 | void usb_disable(void) { usbStop(&USBD1); } | 19 | void usb_disconnect(void) { usbStop(&USBD1); } |
| 20 | 20 | ||
| 21 | bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } | 21 | bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 63619fdb3..4ac079e16 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -314,45 +314,44 @@ static void Console_Task(void) { | |||
| 314 | void send_joystick_packet(joystick_t *joystick) { | 314 | void send_joystick_packet(joystick_t *joystick) { |
| 315 | uint8_t timeout = 255; | 315 | uint8_t timeout = 255; |
| 316 | 316 | ||
| 317 | joystick_report_t r = { | 317 | static joystick_report_t; |
| 318 | r = (joystick_report_t) { | ||
| 318 | # if JOYSTICK_AXES_COUNT > 0 | 319 | # if JOYSTICK_AXES_COUNT > 0 |
| 319 | .axes = | 320 | .axes = |
| 320 | { | 321 | { joystick->axes[0], |
| 321 | joystick->axes[0], | ||
| 322 | 322 | ||
| 323 | # if JOYSTICK_AXES_COUNT >= 2 | 323 | # if JOYSTICK_AXES_COUNT >= 2 |
| 324 | joystick->axes[1], | 324 | joystick->axes[1], |
| 325 | # endif | 325 | # endif |
| 326 | # if JOYSTICK_AXES_COUNT >= 3 | 326 | # if JOYSTICK_AXES_COUNT >= 3 |
| 327 | joystick->axes[2], | 327 | joystick->axes[2], |
| 328 | # endif | 328 | # endif |
| 329 | # if JOYSTICK_AXES_COUNT >= 4 | 329 | # if JOYSTICK_AXES_COUNT >= 4 |
| 330 | joystick->axes[3], | 330 | joystick->axes[3], |
| 331 | # endif | 331 | # endif |
| 332 | # if JOYSTICK_AXES_COUNT >= 5 | 332 | # if JOYSTICK_AXES_COUNT >= 5 |
| 333 | joystick->axes[4], | 333 | joystick->axes[4], |
| 334 | # endif | 334 | # endif |
| 335 | # if JOYSTICK_AXES_COUNT >= 6 | 335 | # if JOYSTICK_AXES_COUNT >= 6 |
| 336 | joystick->axes[5], | 336 | joystick->axes[5], |
| 337 | # endif | 337 | # endif |
| 338 | }, | 338 | }, |
| 339 | # endif // JOYSTICK_AXES_COUNT>0 | 339 | # endif // JOYSTICK_AXES_COUNT>0 |
| 340 | 340 | ||
| 341 | # if JOYSTICK_BUTTON_COUNT > 0 | 341 | # if JOYSTICK_BUTTON_COUNT > 0 |
| 342 | .buttons = | 342 | .buttons = { |
| 343 | { | 343 | joystick->buttons[0], |
| 344 | joystick->buttons[0], | ||
| 345 | 344 | ||
| 346 | # if JOYSTICK_BUTTON_COUNT > 8 | 345 | # if JOYSTICK_BUTTON_COUNT > 8 |
| 347 | joystick->buttons[1], | 346 | joystick->buttons[1], |
| 348 | # endif | 347 | # endif |
| 349 | # if JOYSTICK_BUTTON_COUNT > 16 | 348 | # if JOYSTICK_BUTTON_COUNT > 16 |
| 350 | joystick->buttons[2], | 349 | joystick->buttons[2], |
| 351 | # endif | 350 | # endif |
| 352 | # if JOYSTICK_BUTTON_COUNT > 24 | 351 | # if JOYSTICK_BUTTON_COUNT > 24 |
| 353 | joystick->buttons[3], | 352 | joystick->buttons[3], |
| 354 | # endif | 353 | # endif |
| 355 | } | 354 | } |
| 356 | # endif // JOYSTICK_BUTTON_COUNT>0 | 355 | # endif // JOYSTICK_BUTTON_COUNT>0 |
| 357 | }; | 356 | }; |
| 358 | 357 | ||
| @@ -768,7 +767,8 @@ static void send_extra(uint8_t report_id, uint16_t data) { | |||
| 768 | 767 | ||
| 769 | if (USB_DeviceState != DEVICE_STATE_Configured) return; | 768 | if (USB_DeviceState != DEVICE_STATE_Configured) return; |
| 770 | 769 | ||
| 771 | report_extra_t r = {.report_id = report_id, .usage = data}; | 770 | static report_extra_t r; |
| 771 | r = (report_extra_t){.report_id = report_id, .usage = data}; | ||
| 772 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); | 772 | Endpoint_SelectEndpoint(SHARED_IN_EPNUM); |
| 773 | 773 | ||
| 774 | /* Check if write ready for a polling interval around 10ms */ | 774 | /* Check if write ready for a polling interval around 10ms */ |
diff --git a/tmk_core/protocol/lufa/usb_util.c b/tmk_core/protocol/lufa/usb_util.c index 9e943a21b..9691eff1e 100644 --- a/tmk_core/protocol/lufa/usb_util.c +++ b/tmk_core/protocol/lufa/usb_util.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | #include "wait.h" | 18 | #include "wait.h" |
| 19 | 19 | ||
| 20 | void usb_disable(void) { | 20 | void usb_disconnect(void) { |
| 21 | USB_Disable(); | 21 | USB_Disable(); |
| 22 | USB_DeviceState = DEVICE_STATE_Unattached; | 22 | USB_DeviceState = DEVICE_STATE_Unattached; |
| 23 | } | 23 | } |
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index ba7760f28..7a4a79031 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c | |||
| @@ -351,7 +351,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { | |||
| 351 | .Size = sizeof(USB_Descriptor_Device_t), | 351 | .Size = sizeof(USB_Descriptor_Device_t), |
| 352 | .Type = DTYPE_Device | 352 | .Type = DTYPE_Device |
| 353 | }, | 353 | }, |
| 354 | .USBSpecification = VERSION_BCD(1, 1, 0), | 354 | .USBSpecification = VERSION_BCD(2, 0, 0), |
| 355 | 355 | ||
| 356 | #if VIRTSER_ENABLE | 356 | #if VIRTSER_ENABLE |
| 357 | .Class = USB_CSCP_IADDeviceClass, | 357 | .Class = USB_CSCP_IADDeviceClass, |
| @@ -953,10 +953,10 @@ const USB_Descriptor_String_t PROGMEM ProductString = { | |||
| 953 | #if defined(SERIAL_NUMBER) | 953 | #if defined(SERIAL_NUMBER) |
| 954 | const USB_Descriptor_String_t PROGMEM SerialNumberString = { | 954 | const USB_Descriptor_String_t PROGMEM SerialNumberString = { |
| 955 | .Header = { | 955 | .Header = { |
| 956 | .Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator | 956 | .Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator |
| 957 | .Type = DTYPE_String | 957 | .Type = DTYPE_String |
| 958 | }, | 958 | }, |
| 959 | .UnicodeString = LSTR(SERIAL_NUMBER) | 959 | .UnicodeString = USBSTR(SERIAL_NUMBER) |
| 960 | }; | 960 | }; |
| 961 | #endif | 961 | #endif |
| 962 | 962 | ||
diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h index b1f602c82..ce0cf0976 100644 --- a/tmk_core/protocol/usb_descriptor_common.h +++ b/tmk_core/protocol/usb_descriptor_common.h | |||
| @@ -16,6 +16,10 @@ | |||
| 16 | 16 | ||
| 17 | #pragma once | 17 | #pragma once |
| 18 | 18 | ||
| 19 | // Prefix string literal with L for descriptors | ||
| 20 | #define USBCONCAT(a, b) a##b | ||
| 21 | #define USBSTR(s) USBCONCAT(L, s) | ||
| 22 | |||
| 19 | ///////////////////// | 23 | ///////////////////// |
| 20 | // RAW Usage page and ID configuration | 24 | // RAW Usage page and ID configuration |
| 21 | 25 | ||
diff --git a/tmk_core/protocol/vusb/usb_util.c b/tmk_core/protocol/vusb/usb_util.c index 602854dbe..4ee2d3188 100644 --- a/tmk_core/protocol/vusb/usb_util.c +++ b/tmk_core/protocol/vusb/usb_util.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include <usbdrv/usbdrv.h> | 16 | #include <usbdrv/usbdrv.h> |
| 17 | #include "usb_util.h" | 17 | #include "usb_util.h" |
| 18 | 18 | ||
| 19 | void usb_disable(void) { usbDeviceDisconnect(); } | 19 | void usb_disconnect(void) { usbDeviceDisconnect(); } |
| 20 | 20 | ||
| 21 | bool usb_connected_state(void) { | 21 | bool usb_connected_state(void) { |
| 22 | usbPoll(); | 22 | usbPoll(); |
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 9362fbde7..98cebf601 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -272,7 +272,8 @@ static void send_extra(uint8_t report_id, uint16_t data) { | |||
| 272 | last_id = report_id; | 272 | last_id = report_id; |
| 273 | last_data = data; | 273 | last_data = data; |
| 274 | 274 | ||
| 275 | report_extra_t report = {.report_id = report_id, .usage = data}; | 275 | static report_extra_t report; |
| 276 | report = (report_extra_t){.report_id = report_id, .usage = data}; | ||
| 276 | if (usbInterruptIsReadyShared()) { | 277 | if (usbInterruptIsReadyShared()) { |
| 277 | usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); | 278 | usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); |
| 278 | } | 279 | } |
| @@ -598,10 +599,10 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = { | |||
| 598 | #if defined(SERIAL_NUMBER) | 599 | #if defined(SERIAL_NUMBER) |
| 599 | const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { | 600 | const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { |
| 600 | .header = { | 601 | .header = { |
| 601 | .bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), | 602 | .bLength = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), |
| 602 | .bDescriptorType = USBDESCR_STRING | 603 | .bDescriptorType = USBDESCR_STRING |
| 603 | }, | 604 | }, |
| 604 | .bString = LSTR(SERIAL_NUMBER) | 605 | .bString = USBSTR(SERIAL_NUMBER) |
| 605 | }; | 606 | }; |
| 606 | #endif | 607 | #endif |
| 607 | 608 | ||
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index fc2dc68be..597f7aa82 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -458,7 +458,7 @@ ifeq ($(findstring avr-gcc,$(CC)),avr-gcc) | |||
| 458 | SIZE_MARGIN = 1024 | 458 | SIZE_MARGIN = 1024 |
| 459 | 459 | ||
| 460 | check-size: | 460 | check-size: |
| 461 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) | 461 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) |
| 462 | $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) | 462 | $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) |
| 463 | $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) | 463 | $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) |
| 464 | $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) | 464 | $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) |
