diff options
author | William Chang <william@factual.com> | 2019-07-13 10:18:33 -0700 |
---|---|---|
committer | William Chang <william@factual.com> | 2019-07-13 10:18:33 -0700 |
commit | 71493b2f9bbd5f3d18373c518fa14ccafcbf48fc (patch) | |
tree | 3bb3e5e496621535611e087720aa5c4d7a533e5e /tmk_core | |
parent | 86ad4988fe7ff64916127509d84f44c56fa097aa (diff) | |
parent | da1f05fbc19477c05c0c01bb07fabfaf1ece9d54 (diff) | |
download | qmk_firmware-71493b2f9bbd5f3d18373c518fa14ccafcbf48fc.tar.gz |
Merge branch 'master' of https://github.com/qmk/qmk_firmware
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/chibios.mk | 19 | ||||
-rw-r--r-- | tmk_core/common/action.c | 22 | ||||
-rw-r--r-- | tmk_core/common/action_layer.c | 36 | ||||
-rw-r--r-- | tmk_core/common/action_layer.h | 38 | ||||
-rw-r--r-- | tmk_core/common/bootmagic.c | 4 | ||||
-rw-r--r-- | tmk_core/common/magic.c | 2 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/led_matrix.c | 3 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/md_bootloader.h | 3 | ||||
-rw-r--r-- | tmk_core/rules.mk | 9 |
9 files changed, 82 insertions, 54 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 44c00bdd1..4aebb4776 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk @@ -201,7 +201,6 @@ DFU_ARGS ?= ifneq ("$(SERIAL)","") DFU_ARGS += -S $(SERIAL) endif -DFU_SUFFIX_ARGS ?= ST_LINK_ARGS ?= @@ -209,7 +208,6 @@ ST_LINK_ARGS ?= EXTRALIBDIRS = $(RULESPATH)/ld DFU_UTIL ?= dfu-util -DFU_SUFFIX ?= dfu-suffix ST_LINK_CLI ?= st-link_cli # Generate a .qmk for the QMK-FF @@ -260,8 +258,17 @@ dfu-util-wait: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter $(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst + +# Autodetect teensy loader +ifndef TEENSY_LOADER_CLI + ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) + TEENSY_LOADER_CLI ?= teensy-loader-cli + else + TEENSY_LOADER_CLI ?= teensy_loader_cli + endif +endif + +teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter + $(TEENSY_LOADER_CLI) -mmcu=$(MCU_LDSCRIPT) -w -v $(BUILD_DIR)/$(TARGET).hex + bin: $(BUILD_DIR)/$(TARGET).bin sizeafter - if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \ - $(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\ - fi - $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index d4d4ac28d..6a560229a 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -44,6 +44,9 @@ int retro_tapping_counter = 0; #include <fauxclicky.h> #endif +#ifndef TAP_HOLD_CAPS_DELAY +# define TAP_HOLD_CAPS_DELAY 200 +#endif /** \brief Called to execute an action. * * FIXME: Needs documentation. @@ -403,13 +406,13 @@ void process_action(keyrecord_t *record, action_t action) /* Default Layer Bitwise Operation */ if (!event.pressed) { uint8_t shift = action.layer_bitop.part*4; - uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift; - uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0; + layer_state_t bits = ((layer_state_t)action.layer_bitop.bits)<<shift; + layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf)<<shift) : 0; switch (action.layer_bitop.op) { case OP_BIT_AND: default_layer_and(bits | mask); break; case OP_BIT_OR: default_layer_or(bits | mask); break; case OP_BIT_XOR: default_layer_xor(bits | mask); break; - case OP_BIT_SET: default_layer_and(mask); default_layer_or(bits); break; + case OP_BIT_SET: default_layer_set(bits | mask); break; } } } else { @@ -417,13 +420,13 @@ void process_action(keyrecord_t *record, action_t action) if (event.pressed ? (action.layer_bitop.on & ON_PRESS) : (action.layer_bitop.on & ON_RELEASE)) { uint8_t shift = action.layer_bitop.part*4; - uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift; - uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0; + layer_state_t bits = ((layer_state_t)action.layer_bitop.bits)<<shift; + layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf)<<shift) : 0; switch (action.layer_bitop.op) { case OP_BIT_AND: layer_and(bits | mask); break; case OP_BIT_OR: layer_or(bits | mask); break; case OP_BIT_XOR: layer_xor(bits | mask); break; - case OP_BIT_SET: layer_and(mask); layer_or(bits); break; + case OP_BIT_SET: layer_state_set(bits | mask); break; } } } @@ -518,7 +521,7 @@ void process_action(keyrecord_t *record, action_t action) if (tap_count > 0) { dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); if (action.layer_tap.code == KC_CAPS) { - wait_ms(80); + wait_ms(TAP_HOLD_CAPS_DELAY); } unregister_code(action.layer_tap.code); } else { @@ -853,8 +856,13 @@ void unregister_code(uint8_t code) */ void tap_code(uint8_t code) { register_code(code); + if (code == KC_CAPS) { + wait_ms(TAP_HOLD_CAPS_DELAY); + } #if TAP_CODE_DELAY > 0 + else { wait_ms(TAP_CODE_DELAY); + } #endif unregister_code(code); } diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index 47cad996a..dfcbc110a 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c @@ -13,14 +13,14 @@ /** \brief Default Layer State */ -uint32_t default_layer_state = 0; +layer_state_t default_layer_state = 0; /** \brief Default Layer State Set At user Level * * Run user code on default layer state change */ __attribute__((weak)) -uint32_t default_layer_state_set_user(uint32_t state) { +layer_state_t default_layer_state_set_user(layer_state_t state) { return state; } @@ -29,7 +29,7 @@ uint32_t default_layer_state_set_user(uint32_t state) { * Run keyboard code on default layer state change */ __attribute__((weak)) -uint32_t default_layer_state_set_kb(uint32_t state) { +layer_state_t default_layer_state_set_kb(layer_state_t state) { return default_layer_state_set_user(state); } @@ -37,7 +37,7 @@ uint32_t default_layer_state_set_kb(uint32_t state) { * * Static function to set the default layer state, prints debug info and clears keys */ -static void default_layer_state_set(uint32_t state) { +static void default_layer_state_set(layer_state_t state) { state = default_layer_state_set_kb(state); debug("default_layer_state: "); default_layer_debug(); debug(" to "); @@ -62,7 +62,7 @@ void default_layer_debug(void) { * * Sets the default layer state. */ -void default_layer_set(uint32_t state) { +void default_layer_set(layer_state_t state) { default_layer_state_set(state); } @@ -71,21 +71,21 @@ void default_layer_set(uint32_t state) { * * Turns on the default layer based on matching bits between specifed layer and existing layer state */ -void default_layer_or(uint32_t state) { +void default_layer_or(layer_state_t state) { default_layer_state_set(default_layer_state | state); } /** \brief Default Layer And * * Turns on default layer based on matching enabled bits between specifed layer and existing layer state */ -void default_layer_and(uint32_t state) { +void default_layer_and(layer_state_t state) { default_layer_state_set(default_layer_state & state); } /** \brief Default Layer Xor * * Turns on default layer based on non-matching bits between specifed layer and existing layer state */ -void default_layer_xor(uint32_t state) { +void default_layer_xor(layer_state_t state) { default_layer_state_set(default_layer_state ^ state); } #endif @@ -94,14 +94,14 @@ void default_layer_xor(uint32_t state) { #ifndef NO_ACTION_LAYER /** \brief Keymap Layer State */ -uint32_t layer_state = 0; +layer_state_t layer_state = 0; /** \brief Layer state set user * * Runs user code on layer state change */ __attribute__((weak)) -uint32_t layer_state_set_user(uint32_t state) { +layer_state_t layer_state_set_user(layer_state_t state) { return state; } @@ -110,7 +110,7 @@ uint32_t layer_state_set_user(uint32_t state) { * Runs keyboard code on layer state change */ __attribute__((weak)) -uint32_t layer_state_set_kb(uint32_t state) { +layer_state_t layer_state_set_kb(layer_state_t state) { return layer_state_set_user(state); } @@ -118,7 +118,7 @@ uint32_t layer_state_set_kb(uint32_t state) { * * Sets the layer to match the specifed state (a bitmask) */ -void layer_state_set(uint32_t state) { +void layer_state_set(layer_state_t state) { state = layer_state_set_kb(state); dprint("layer_state: "); layer_debug(); dprint(" to "); @@ -151,7 +151,7 @@ bool layer_state_is(uint8_t layer) { * * Used for comparing layers {mostly used for unit testing} */ -bool layer_state_cmp(uint32_t cmp_layer_state, uint8_t layer) { +bool layer_state_cmp(layer_state_t cmp_layer_state, uint8_t layer) { if (!cmp_layer_state) { return layer == 0; } return (cmp_layer_state & (1UL<<layer)) != 0; } @@ -192,21 +192,21 @@ void layer_invert(uint8_t layer) { * * Turns on layers based on matching bits between specifed layer and existing layer state */ -void layer_or(uint32_t state) { +void layer_or(layer_state_t state) { layer_state_set(layer_state | state); } /** \brief Layer and * * Turns on layers based on matching enabled bits between specifed layer and existing layer state */ -void layer_and(uint32_t state) { +void layer_and(layer_state_t state) { layer_state_set(layer_state & state); } /** \brief Layer xor * * Turns on layers based on non-matching bits between specifed layer and existing layer state */ -void layer_xor(uint32_t state) { +void layer_xor(layer_state_t state) { layer_state_set(layer_state ^ state); } @@ -301,9 +301,9 @@ uint8_t layer_switch_get_layer(keypos_t key) { action_t action; action.code = ACTION_TRANSPARENT; - uint32_t layers = layer_state | default_layer_state; + layer_state_t layers = layer_state | default_layer_state; /* check top layer first */ - for (int8_t i = 31; i >= 0; i--) { + for (int8_t i = sizeof(layer_state_t) * 8 - 1; i >= 0; i--) { if (layers & (1UL << i)) { action = action_for_key(i, key); if (action.code != ACTION_TRANSPARENT) { diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 6e2f35d90..7fa30c86d 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h @@ -21,24 +21,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "keyboard.h" #include "action.h" +#if defined(LAYER_STATE_8BIT) || ( defined(DYNAMIC_KEYMAP_ENABLE) && DYNAMIC_KEYMAP_LAYER_COUNT >= 8 ) +typedef uint8_t layer_state_t; +#elif defined(LAYER_STATE_16BIT) +typedef uint16_t layer_state_t; +#else +typedef uint32_t layer_state_t; +#endif + /* * Default Layer */ -extern uint32_t default_layer_state; +extern layer_state_t default_layer_state; void default_layer_debug(void); -void default_layer_set(uint32_t state); +void default_layer_set(layer_state_t state); __attribute__((weak)) -uint32_t default_layer_state_set_kb(uint32_t state); +layer_state_t default_layer_state_set_kb(layer_state_t state); __attribute__((weak)) -uint32_t default_layer_state_set_user(uint32_t state); +layer_state_t default_layer_state_set_user(layer_state_t state); #ifndef NO_ACTION_LAYER /* bitwise operation */ -void default_layer_or(uint32_t state); -void default_layer_and(uint32_t state); -void default_layer_xor(uint32_t state); +void default_layer_or(layer_state_t state); +void default_layer_and(layer_state_t state); +void default_layer_xor(layer_state_t state); #else #define default_layer_or(state) #define default_layer_and(state) @@ -50,11 +58,11 @@ void default_layer_xor(uint32_t state); * Keymap Layer */ #ifndef NO_ACTION_LAYER -extern uint32_t layer_state; +extern layer_state_t layer_state; -void layer_state_set(uint32_t state); +void layer_state_set(layer_state_t state); bool layer_state_is(uint8_t layer); -bool layer_state_cmp(uint32_t layer1, uint8_t layer2); +bool layer_state_cmp(layer_state_t layer1, uint8_t layer2); void layer_debug(void); void layer_clear(void); @@ -63,9 +71,9 @@ void layer_on(uint8_t layer); void layer_off(uint8_t layer); void layer_invert(uint8_t layer); /* bitwise operation */ -void layer_or(uint32_t state); -void layer_and(uint32_t state); -void layer_xor(uint32_t state); +void layer_or(layer_state_t state); +void layer_and(layer_state_t state); +void layer_xor(layer_state_t state); #else #define layer_state 0 @@ -84,8 +92,8 @@ void layer_xor(uint32_t state); #define layer_xor(state) #endif -uint32_t layer_state_set_user(uint32_t state); -uint32_t layer_state_set_kb(uint32_t state); +layer_state_t layer_state_set_user(layer_state_t state); +layer_state_t layer_state_set_kb(layer_state_t state); /* pressed actions cache */ #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c index 9f79fb8ee..cc780d17a 100644 --- a/tmk_core/common/bootmagic.c +++ b/tmk_core/common/bootmagic.c @@ -99,10 +99,10 @@ void bootmagic(void) if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } if (default_layer) { eeconfig_update_default_layer(default_layer); - default_layer_set((uint32_t)default_layer); + default_layer_set((layer_state_t)default_layer); } else { default_layer = eeconfig_read_default_layer(); - default_layer_set((uint32_t)default_layer); + default_layer_set((layer_state_t)default_layer); } } diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c index 714acc0f5..2b1a6a6ad 100644 --- a/tmk_core/common/magic.c +++ b/tmk_core/common/magic.c @@ -33,6 +33,6 @@ void magic(void) uint8_t default_layer = 0; default_layer = eeconfig_read_default_layer(); - default_layer_set((uint32_t)default_layer); + default_layer_set((layer_state_t)default_layer); } diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index ea067a743..42dfccbc5 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -27,8 +27,6 @@ led_instruction_t led_instructions[] = { { .end = 1 } }; static void led_matrix_massdrop_config_override(int i); #endif // USE_MASSDROP_CONFIGURATOR -extern rgb_config_t rgb_matrix_config; -extern rgb_counters_t g_rgb_counters; void SERCOM1_0_Handler( void ) { @@ -431,7 +429,6 @@ static void led_run_pattern(led_setup_t *f, float* ro, float* go, float* bo, flo } } -extern led_config_t g_led_config; static void led_matrix_massdrop_config_override(int i) { float ro = 0; diff --git a/tmk_core/protocol/arm_atsam/md_bootloader.h b/tmk_core/protocol/arm_atsam/md_bootloader.h index 956145c31..6b80ef492 100644 --- a/tmk_core/protocol/arm_atsam/md_bootloader.h +++ b/tmk_core/protocol/arm_atsam/md_bootloader.h @@ -11,7 +11,7 @@ extern uint32_t _erom; //WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support extern uint32_t _eram; #define BOOTLOADER_MAGIC 0x3B9ACA00 -#define MAGIC_ADDR (uint32_t *)(&_eram - 4) +#define MAGIC_ADDR (uint32_t *)((intptr_t)(&_eram) - 4) #endif #ifdef MD_BOOTLOADER @@ -22,4 +22,3 @@ extern uint32_t _eram; #endif //MD_BOOTLOADER #endif //_MD_BOOTLOADER_H_ - diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 6d2bb51f0..96b6e3a27 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -223,6 +223,10 @@ $(foreach LOBJ, $(NO_LTO_OBJ), $(eval $(call NO_LTO,$(LOBJ)))) MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) +# Add QMK specific flags +DFU_SUFFIX ?= dfu-suffix +DFU_SUFFIX_ARGS ?= + elf: $(BUILD_DIR)/$(TARGET).elf hex: $(BUILD_DIR)/$(TARGET).hex @@ -279,6 +283,10 @@ gccversion : @$(SILENT) || printf "$(MSG_BIN) $@" | $(AWK_CMD) $(eval CMD=$(BIN) $< $@ || exit 0) @$(BUILD_CMD) + if [ ! -z "$(DFU_SUFFIX_ARGS)" ]; then \ + $(DFU_SUFFIX) $(DFU_SUFFIX_ARGS) -a $(BUILD_DIR)/$(TARGET).bin 1>/dev/null ;\ + fi + $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin; BEGIN = gccversion sizebefore @@ -390,6 +398,7 @@ check-size: $(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)) $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) + $(eval PERCENT_SIZE=$(shell expr $(CURRENT_SIZE) \* 100 / $(MAX_SIZE))) if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \ $(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \ if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \ |