diff options
57 files changed, 570 insertions, 287 deletions
diff --git a/common_features.mk b/common_features.mk index 8c9d0a90c..bdde278b9 100644 --- a/common_features.mk +++ b/common_features.mk | |||
@@ -422,10 +422,6 @@ ifeq ($(strip $(TERMINAL_ENABLE)), yes) | |||
422 | OPT_DEFS += -DUSER_PRINT | 422 | OPT_DEFS += -DUSER_PRINT |
423 | endif | 423 | endif |
424 | 424 | ||
425 | ifeq ($(strip $(USB_HID_ENABLE)), yes) | ||
426 | include $(TMK_DIR)/protocol/usb_hid.mk | ||
427 | endif | ||
428 | |||
429 | ifeq ($(strip $(WPM_ENABLE)), yes) | 425 | ifeq ($(strip $(WPM_ENABLE)), yes) |
430 | SRC += $(QUANTUM_DIR)/wpm.c | 426 | SRC += $(QUANTUM_DIR)/wpm.c |
431 | OPT_DEFS += -DWPM_ENABLE | 427 | OPT_DEFS += -DWPM_ENABLE |
@@ -459,6 +455,23 @@ ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes) | |||
459 | SRC += $(QUANTUM_DIR)/dip_switch.c | 455 | SRC += $(QUANTUM_DIR)/dip_switch.c |
460 | endif | 456 | endif |
461 | 457 | ||
458 | VALID_MAGIC_TYPES := yes full lite | ||
459 | BOOTMAGIC_ENABLE ?= no | ||
460 | ifneq ($(strip $(BOOTMAGIC_ENABLE)), no) | ||
461 | ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),) | ||
462 | $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic) | ||
463 | endif | ||
464 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) | ||
465 | OPT_DEFS += -DBOOTMAGIC_LITE | ||
466 | QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c | ||
467 | else | ||
468 | OPT_DEFS += -DBOOTMAGIC_ENABLE | ||
469 | QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_full.c | ||
470 | endif | ||
471 | endif | ||
472 | COMMON_VPATH += $(QUANTUM_DIR)/bootmagic | ||
473 | QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c | ||
474 | |||
462 | VALID_CUSTOM_MATRIX_TYPES:= yes lite no | 475 | VALID_CUSTOM_MATRIX_TYPES:= yes lite no |
463 | 476 | ||
464 | CUSTOM_MATRIX ?= no | 477 | CUSTOM_MATRIX ?= no |
diff --git a/docs/keycodes.md b/docs/keycodes.md index 9acf8b683..f3c519b13 100644 --- a/docs/keycodes.md +++ b/docs/keycodes.md | |||
@@ -516,6 +516,9 @@ See also: [One Shot Keys](one_shot_keys.md) | |||
516 | |------------|----------------------------------| | 516 | |------------|----------------------------------| |
517 | |`OSM(mod)` |Hold `mod` for one keypress | | 517 | |`OSM(mod)` |Hold `mod` for one keypress | |
518 | |`OSL(layer)`|Switch to `layer` for one keypress| | 518 | |`OSL(layer)`|Switch to `layer` for one keypress| |
519 | |`OS_ON` |Turns One Shot keys on | | ||
520 | |`OS_OFF` |Turns One Shot keys off | | ||
521 | |`OS_TOGG` |Toggles One Shot keys status | | ||
519 | 522 | ||
520 | ## Space Cadet :id=space-cadet | 523 | ## Space Cadet :id=space-cadet |
521 | 524 | ||
diff --git a/docs/one_shot_keys.md b/docs/one_shot_keys.md index 9a082d7d6..9fc548629 100644 --- a/docs/one_shot_keys.md +++ b/docs/one_shot_keys.md | |||
@@ -17,6 +17,9 @@ You can control the behavior of one shot keys by defining these in `config.h`: | |||
17 | 17 | ||
18 | * `OSM(mod)` - Momentarily hold down *mod*. You must use the `MOD_*` keycodes as shown in [Mod Tap](mod_tap.md), not the `KC_*` codes. | 18 | * `OSM(mod)` - Momentarily hold down *mod*. You must use the `MOD_*` keycodes as shown in [Mod Tap](mod_tap.md), not the `KC_*` codes. |
19 | * `OSL(layer)` - momentary switch to *layer*. | 19 | * `OSL(layer)` - momentary switch to *layer*. |
20 | * `OS_ON` - Turns on One Shot keys. | ||
21 | * `OS_OFF` - Turns off One Shot keys. OSM act as regular mod keys, OSL act like `MO`. | ||
22 | * `ON_TOGG` - Toggles the one shot key status. | ||
20 | 23 | ||
21 | Sometimes, you want to activate a one-shot key as part of a macro or tap dance routine. | 24 | Sometimes, you want to activate a one-shot key as part of a macro or tap dance routine. |
22 | 25 | ||
diff --git a/keyboards/aeboards/ext65/rev2/config.h b/keyboards/aeboards/ext65/rev2/config.h index 541f07ee9..dc1bfb71c 100644 --- a/keyboards/aeboards/ext65/rev2/config.h +++ b/keyboards/aeboards/ext65/rev2/config.h | |||
@@ -74,3 +74,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
74 | #define BACKLIGHT_LEVELS 6 | 74 | #define BACKLIGHT_LEVELS 6 |
75 | #define BACKLIGHT_BREATHING | 75 | #define BACKLIGHT_BREATHING |
76 | #define BREATHING_PERIOD 6 | 76 | #define BREATHING_PERIOD 6 |
77 | |||
78 | #define SLEEP_LED_GPT_DRIVER GPTD1 | ||
diff --git a/keyboards/aeboards/ext65/rev2/halconf.h b/keyboards/aeboards/ext65/rev2/halconf.h index 6e2f53640..9fa1eca60 100644 --- a/keyboards/aeboards/ext65/rev2/halconf.h +++ b/keyboards/aeboards/ext65/rev2/halconf.h | |||
@@ -27,5 +27,7 @@ | |||
27 | 27 | ||
28 | #define HAL_USE_SPI TRUE | 28 | #define HAL_USE_SPI TRUE |
29 | 29 | ||
30 | #define HAL_USE_GPT TRUE | ||
31 | |||
30 | #include_next <halconf.h> | 32 | #include_next <halconf.h> |
31 | 33 | ||
diff --git a/keyboards/aeboards/ext65/rev2/mcuconf.h b/keyboards/aeboards/ext65/rev2/mcuconf.h index 26ce80615..43d53d4f2 100644 --- a/keyboards/aeboards/ext65/rev2/mcuconf.h +++ b/keyboards/aeboards/ext65/rev2/mcuconf.h | |||
@@ -32,3 +32,5 @@ | |||
32 | #undef STM32_SPI_USE_SPI2 | 32 | #undef STM32_SPI_USE_SPI2 |
33 | #define STM32_SPI_USE_SPI2 TRUE | 33 | #define STM32_SPI_USE_SPI2 TRUE |
34 | 34 | ||
35 | #undef STM32_GPT_USE_TIM1 | ||
36 | #define STM32_GPT_USE_TIM1 TRUE | ||
diff --git a/keyboards/cannonkeys/an_c/rules.mk b/keyboards/cannonkeys/an_c/rules.mk index 8ed2d0ead..7309744d1 100644 --- a/keyboards/cannonkeys/an_c/rules.mk +++ b/keyboards/cannonkeys/an_c/rules.mk | |||
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
11 | EXTRAKEY_ENABLE = yes # Audio control and System control | 11 | EXTRAKEY_ENABLE = yes # Audio control and System control |
12 | CONSOLE_ENABLE = yes # Console for debug | 12 | CONSOLE_ENABLE = yes # Console for debug |
13 | COMMAND_ENABLE = yes # Commands for debug and configuration | 13 | COMMAND_ENABLE = yes # Commands for debug and configuration |
14 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 14 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
15 | NKRO_ENABLE = yes # USB Nkey Rollover | 15 | NKRO_ENABLE = yes # USB Nkey Rollover |
16 | CUSTOM_MATRIX = no # Custom matrix file | 16 | CUSTOM_MATRIX = no # Custom matrix file |
17 | BACKLIGHT_ENABLE = yes | 17 | BACKLIGHT_ENABLE = yes |
diff --git a/keyboards/cannonkeys/chimera65/rules.mk b/keyboards/cannonkeys/chimera65/rules.mk index 4d940da78..a08f2fa49 100644 --- a/keyboards/cannonkeys/chimera65/rules.mk +++ b/keyboards/cannonkeys/chimera65/rules.mk | |||
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
11 | EXTRAKEY_ENABLE = yes # Audio control and System control | 11 | EXTRAKEY_ENABLE = yes # Audio control and System control |
12 | CONSOLE_ENABLE = yes # Console for debug | 12 | CONSOLE_ENABLE = yes # Console for debug |
13 | COMMAND_ENABLE = yes # Commands for debug and configuration | 13 | COMMAND_ENABLE = yes # Commands for debug and configuration |
14 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 14 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
15 | NKRO_ENABLE = yes # USB Nkey Rollover | 15 | NKRO_ENABLE = yes # USB Nkey Rollover |
16 | CUSTOM_MATRIX = no # Custom matrix file | 16 | CUSTOM_MATRIX = no # Custom matrix file |
17 | BACKLIGHT_ENABLE = yes | 17 | BACKLIGHT_ENABLE = yes |
diff --git a/keyboards/cannonkeys/instant60/rules.mk b/keyboards/cannonkeys/instant60/rules.mk index 0973ad954..e5ba2903b 100644 --- a/keyboards/cannonkeys/instant60/rules.mk +++ b/keyboards/cannonkeys/instant60/rules.mk | |||
@@ -10,7 +10,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
10 | EXTRAKEY_ENABLE = yes # Audio control and System control | 10 | EXTRAKEY_ENABLE = yes # Audio control and System control |
11 | CONSOLE_ENABLE = yes # Console for debug | 11 | CONSOLE_ENABLE = yes # Console for debug |
12 | COMMAND_ENABLE = yes # Commands for debug and configuration | 12 | COMMAND_ENABLE = yes # Commands for debug and configuration |
13 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 13 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
14 | NKRO_ENABLE = yes # USB Nkey Rollover | 14 | NKRO_ENABLE = yes # USB Nkey Rollover |
15 | CUSTOM_MATRIX = no # Custom matrix file | 15 | CUSTOM_MATRIX = no # Custom matrix file |
16 | BACKLIGHT_ENABLE = yes | 16 | BACKLIGHT_ENABLE = yes |
diff --git a/keyboards/cannonkeys/iron165/rules.mk b/keyboards/cannonkeys/iron165/rules.mk index 3925458dd..9de75a614 100644 --- a/keyboards/cannonkeys/iron165/rules.mk +++ b/keyboards/cannonkeys/iron165/rules.mk | |||
@@ -9,7 +9,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
9 | EXTRAKEY_ENABLE = yes # Audio control and System control | 9 | EXTRAKEY_ENABLE = yes # Audio control and System control |
10 | CONSOLE_ENABLE = yes # Console for debug | 10 | CONSOLE_ENABLE = yes # Console for debug |
11 | COMMAND_ENABLE = yes # Commands for debug and configuration | 11 | COMMAND_ENABLE = yes # Commands for debug and configuration |
12 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 12 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
13 | NKRO_ENABLE = yes # USB Nkey Rollover | 13 | NKRO_ENABLE = yes # USB Nkey Rollover |
14 | CUSTOM_MATRIX = no # Custom matrix file | 14 | CUSTOM_MATRIX = no # Custom matrix file |
15 | BACKLIGHT_ENABLE = yes | 15 | BACKLIGHT_ENABLE = yes |
diff --git a/keyboards/cannonkeys/satisfaction75/rules.mk b/keyboards/cannonkeys/satisfaction75/rules.mk index e3abea546..3861b4849 100644 --- a/keyboards/cannonkeys/satisfaction75/rules.mk +++ b/keyboards/cannonkeys/satisfaction75/rules.mk | |||
@@ -15,7 +15,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
15 | EXTRAKEY_ENABLE = yes # Audio control and System control | 15 | EXTRAKEY_ENABLE = yes # Audio control and System control |
16 | CONSOLE_ENABLE = yes # Console for debug | 16 | CONSOLE_ENABLE = yes # Console for debug |
17 | COMMAND_ENABLE = yes # Commands for debug and configuration | 17 | COMMAND_ENABLE = yes # Commands for debug and configuration |
18 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 18 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
19 | NKRO_ENABLE = yes # USB Nkey Rollover | 19 | NKRO_ENABLE = yes # USB Nkey Rollover |
20 | CUSTOM_MATRIX = no # Custom matrix file | 20 | CUSTOM_MATRIX = no # Custom matrix file |
21 | ENCODER_ENABLE = yes | 21 | ENCODER_ENABLE = yes |
diff --git a/keyboards/cannonkeys/savage65/rules.mk b/keyboards/cannonkeys/savage65/rules.mk index 8e1b984fd..2454573d2 100644 --- a/keyboards/cannonkeys/savage65/rules.mk +++ b/keyboards/cannonkeys/savage65/rules.mk | |||
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
11 | EXTRAKEY_ENABLE = yes # Audio control and System control | 11 | EXTRAKEY_ENABLE = yes # Audio control and System control |
12 | CONSOLE_ENABLE = yes # Console for debug | 12 | CONSOLE_ENABLE = yes # Console for debug |
13 | COMMAND_ENABLE = yes # Commands for debug and configuration | 13 | COMMAND_ENABLE = yes # Commands for debug and configuration |
14 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 14 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
15 | NKRO_ENABLE = yes # USB Nkey Rollover | 15 | NKRO_ENABLE = yes # USB Nkey Rollover |
16 | CUSTOM_MATRIX = no # Custom matrix file | 16 | CUSTOM_MATRIX = no # Custom matrix file |
17 | BACKLIGHT_ENABLE = yes | 17 | BACKLIGHT_ENABLE = yes |
diff --git a/keyboards/cannonkeys/tmov2/rules.mk b/keyboards/cannonkeys/tmov2/rules.mk index 9b29e8fd1..294c873ee 100644 --- a/keyboards/cannonkeys/tmov2/rules.mk +++ b/keyboards/cannonkeys/tmov2/rules.mk | |||
@@ -11,7 +11,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
11 | EXTRAKEY_ENABLE = yes # Audio control and System control | 11 | EXTRAKEY_ENABLE = yes # Audio control and System control |
12 | CONSOLE_ENABLE = yes # Console for debug | 12 | CONSOLE_ENABLE = yes # Console for debug |
13 | COMMAND_ENABLE = yes # Commands for debug and configuration | 13 | COMMAND_ENABLE = yes # Commands for debug and configuration |
14 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 14 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
15 | NKRO_ENABLE = yes # USB Nkey Rollover | 15 | NKRO_ENABLE = yes # USB Nkey Rollover |
16 | CUSTOM_MATRIX = no # Custom matrix file | 16 | CUSTOM_MATRIX = no # Custom matrix file |
17 | BACKLIGHT_ENABLE = yes | 17 | BACKLIGHT_ENABLE = yes |
diff --git a/keyboards/cannonkeys/tsukuyomi/rules.mk b/keyboards/cannonkeys/tsukuyomi/rules.mk index ce881f198..4e7791a79 100644 --- a/keyboards/cannonkeys/tsukuyomi/rules.mk +++ b/keyboards/cannonkeys/tsukuyomi/rules.mk | |||
@@ -10,7 +10,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control | |||
10 | CONSOLE_ENABLE = yes # Console for debug | 10 | CONSOLE_ENABLE = yes # Console for debug |
11 | COMMAND_ENABLE = yes # Commands for debug and configuration | 11 | COMMAND_ENABLE = yes # Commands for debug and configuration |
12 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 12 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
13 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 13 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
14 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 14 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
15 | NKRO_ENABLE = yes # USB Nkey Rollover | 15 | NKRO_ENABLE = yes # USB Nkey Rollover |
16 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 16 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality |
diff --git a/keyboards/daji/seis_cinco/rules.mk b/keyboards/daji/seis_cinco/rules.mk index fa34092cd..768e50069 100644 --- a/keyboards/daji/seis_cinco/rules.mk +++ b/keyboards/daji/seis_cinco/rules.mk | |||
@@ -11,7 +11,7 @@ EXTRAKEY_ENABLE = yes # Audio control and System control | |||
11 | CONSOLE_ENABLE = no # Console for debug | 11 | CONSOLE_ENABLE = no # Console for debug |
12 | COMMAND_ENABLE = no # Commands for debug and configuration | 12 | COMMAND_ENABLE = no # Commands for debug and configuration |
13 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 13 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
14 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 14 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
15 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 15 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
16 | NKRO_ENABLE = yes # USB Nkey Rollover | 16 | NKRO_ENABLE = yes # USB Nkey Rollover |
17 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | 17 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality |
diff --git a/keyboards/handwired/ck4x4/rules.mk b/keyboards/handwired/ck4x4/rules.mk index 0709f341b..e5785270b 100644 --- a/keyboards/handwired/ck4x4/rules.mk +++ b/keyboards/handwired/ck4x4/rules.mk | |||
@@ -10,7 +10,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
10 | EXTRAKEY_ENABLE = yes # Audio control and System control | 10 | EXTRAKEY_ENABLE = yes # Audio control and System control |
11 | CONSOLE_ENABLE = yes # Console for debug | 11 | CONSOLE_ENABLE = yes # Console for debug |
12 | COMMAND_ENABLE = yes # Commands for debug and configuration | 12 | COMMAND_ENABLE = yes # Commands for debug and configuration |
13 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 13 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
14 | NKRO_ENABLE = yes # USB Nkey Rollover | 14 | NKRO_ENABLE = yes # USB Nkey Rollover |
15 | CUSTOM_MATRIX = no # Custom matrix file | 15 | CUSTOM_MATRIX = no # Custom matrix file |
16 | 16 | ||
diff --git a/keyboards/handwired/onekey/rules.mk b/keyboards/handwired/onekey/rules.mk index 259050d55..df2ec1ecf 100644 --- a/keyboards/handwired/onekey/rules.mk +++ b/keyboards/handwired/onekey/rules.mk | |||
@@ -7,9 +7,9 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | |||
7 | CONSOLE_ENABLE = yes # Console for debug(+400) | 7 | CONSOLE_ENABLE = yes # Console for debug(+400) |
8 | COMMAND_ENABLE = no # Commands for debug and configuration | 8 | COMMAND_ENABLE = no # Commands for debug and configuration |
9 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 9 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
10 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 10 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
11 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 11 | # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
12 | NKRO_ENABLE = yes # USB Nkey Rollover | 12 | NKRO_ENABLE = yes # USB Nkey Rollover |
13 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default | 13 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default |
14 | RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow | 14 | RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow |
15 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) | 15 | MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config) |
diff --git a/keyboards/projectkb/alice/config.h b/keyboards/projectkb/alice/config.h new file mode 100644 index 000000000..95fb682e1 --- /dev/null +++ b/keyboards/projectkb/alice/config.h | |||
@@ -0,0 +1,3 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #define SLEEP_LED_GPT_DRIVER GPTD1 | ||
diff --git a/keyboards/projectkb/alice/halconf.h b/keyboards/projectkb/alice/halconf.h index b17808ffe..0016e53ba 100644 --- a/keyboards/projectkb/alice/halconf.h +++ b/keyboards/projectkb/alice/halconf.h | |||
@@ -27,5 +27,7 @@ | |||
27 | 27 | ||
28 | #define HAL_USE_SPI TRUE | 28 | #define HAL_USE_SPI TRUE |
29 | 29 | ||
30 | #define HAL_USE_GPT TRUE | ||
31 | |||
30 | #include_next <halconf.h> | 32 | #include_next <halconf.h> |
31 | 33 | ||
diff --git a/keyboards/projectkb/alice/mcuconf.h b/keyboards/projectkb/alice/mcuconf.h index 4bfc7f946..6e0f1a50d 100644 --- a/keyboards/projectkb/alice/mcuconf.h +++ b/keyboards/projectkb/alice/mcuconf.h | |||
@@ -32,3 +32,5 @@ | |||
32 | #undef STM32_SPI_USE_SPI2 | 32 | #undef STM32_SPI_USE_SPI2 |
33 | #define STM32_SPI_USE_SPI2 TRUE | 33 | #define STM32_SPI_USE_SPI2 TRUE |
34 | 34 | ||
35 | #undef STM32_GPT_USE_TIM1 | ||
36 | #define STM32_GPT_USE_TIM1 TRUE | ||
diff --git a/keyboards/projectkb/signature87/rules.mk b/keyboards/projectkb/signature87/rules.mk index fe0d976d1..caad4c83c 100644 --- a/keyboards/projectkb/signature87/rules.mk +++ b/keyboards/projectkb/signature87/rules.mk | |||
@@ -9,7 +9,7 @@ MOUSEKEY_ENABLE = yes # Mouse keys | |||
9 | EXTRAKEY_ENABLE = yes # Audio control and System control | 9 | EXTRAKEY_ENABLE = yes # Audio control and System control |
10 | CONSOLE_ENABLE = yes # Console for debug | 10 | CONSOLE_ENABLE = yes # Console for debug |
11 | COMMAND_ENABLE = yes # Commands for debug and configuration | 11 | COMMAND_ENABLE = yes # Commands for debug and configuration |
12 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 12 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
13 | NKRO_ENABLE = yes # USB Nkey Rollover | 13 | NKRO_ENABLE = yes # USB Nkey Rollover |
14 | BACKLIGHT_ENABLE = no | 14 | BACKLIGHT_ENABLE = no |
15 | 15 | ||
diff --git a/keyboards/ramonimbao/wete/config.h b/keyboards/ramonimbao/wete/config.h index 5d68a7efd..3d8955009 100644 --- a/keyboards/ramonimbao/wete/config.h +++ b/keyboards/ramonimbao/wete/config.h | |||
@@ -46,6 +46,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
46 | #define RGBLED_NUM 24 | 46 | #define RGBLED_NUM 24 |
47 | #define RGBLIGHT_ANIMATIONS | 47 | #define RGBLIGHT_ANIMATIONS |
48 | 48 | ||
49 | #define SLEEP_LED_GPT_DRIVER GPTD1 | ||
50 | |||
49 | /* define if matrix has ghost */ | 51 | /* define if matrix has ghost */ |
50 | //#define MATRIX_HAS_GHOST | 52 | //#define MATRIX_HAS_GHOST |
51 | 53 | ||
diff --git a/keyboards/ramonimbao/wete/halconf.h b/keyboards/ramonimbao/wete/halconf.h index c43440a45..b3de873be 100644 --- a/keyboards/ramonimbao/wete/halconf.h +++ b/keyboards/ramonimbao/wete/halconf.h | |||
@@ -23,5 +23,7 @@ | |||
23 | 23 | ||
24 | #define HAL_USE_PWM TRUE | 24 | #define HAL_USE_PWM TRUE |
25 | 25 | ||
26 | #define HAL_USE_GPT TRUE | ||
27 | |||
26 | #include_next <halconf.h> | 28 | #include_next <halconf.h> |
27 | 29 | ||
diff --git a/keyboards/ramonimbao/wete/mcuconf.h b/keyboards/ramonimbao/wete/mcuconf.h index b7f2c481c..7a2e87776 100644 --- a/keyboards/ramonimbao/wete/mcuconf.h +++ b/keyboards/ramonimbao/wete/mcuconf.h | |||
@@ -35,3 +35,5 @@ | |||
35 | #undef STM32_SPI_USE_SPI2 | 35 | #undef STM32_SPI_USE_SPI2 |
36 | #define STM32_SPI_USE_SPI2 TRUE | 36 | #define STM32_SPI_USE_SPI2 TRUE |
37 | 37 | ||
38 | #undef STM32_GPT_USE_TIM1 | ||
39 | #define STM32_GPT_USE_TIM1 TRUE | ||
diff --git a/keyboards/westfoxtrot/prophet/config.h b/keyboards/westfoxtrot/prophet/config.h index 4f447e4ca..0f2ddc1dc 100644 --- a/keyboards/westfoxtrot/prophet/config.h +++ b/keyboards/westfoxtrot/prophet/config.h | |||
@@ -30,3 +30,5 @@ | |||
30 | #define LOCKING_SUPPORT_ENABLE | 30 | #define LOCKING_SUPPORT_ENABLE |
31 | /* Locking resynchronize hack */ | 31 | /* Locking resynchronize hack */ |
32 | #define LOCKING_RESYNC_ENABLE | 32 | #define LOCKING_RESYNC_ENABLE |
33 | |||
34 | #define SLEEP_LED_GPT_DRIVER GPTD1 | ||
diff --git a/keyboards/westfoxtrot/prophet/halconf.h b/keyboards/westfoxtrot/prophet/halconf.h new file mode 100644 index 000000000..cbfd1307f --- /dev/null +++ b/keyboards/westfoxtrot/prophet/halconf.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* Copyright 2020 QMK | ||
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 | * This file was auto-generated by: | ||
19 | * `qmk chibios-confmigrate -i keyboards/projectkb/alice/halconf.h -r platforms/chibios/common/configs/halconf.h` | ||
20 | */ | ||
21 | |||
22 | #pragma once | ||
23 | |||
24 | #define HAL_USE_GPT TRUE | ||
25 | |||
26 | #include_next <halconf.h> | ||
27 | |||
diff --git a/keyboards/westfoxtrot/prophet/mcuconf.h b/keyboards/westfoxtrot/prophet/mcuconf.h index 2665f9c9e..550141af6 100644 --- a/keyboards/westfoxtrot/prophet/mcuconf.h +++ b/keyboards/westfoxtrot/prophet/mcuconf.h | |||
@@ -23,6 +23,5 @@ | |||
23 | 23 | ||
24 | #include_next <mcuconf.h> | 24 | #include_next <mcuconf.h> |
25 | 25 | ||
26 | #undef STM32_PWM_USE_TIM3 | 26 | #undef STM32_GPT_USE_TIM1 |
27 | #define STM32_PWM_USE_TIM3 TRUE | 27 | #define STM32_GPT_USE_TIM1 TRUE |
28 | |||
diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h new file mode 100644 index 000000000..959750178 --- /dev/null +++ b/quantum/bootmagic/bootmagic.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | #if defined(BOOTMAGIC_ENABLE) | ||
19 | # include "bootmagic_full.h" | ||
20 | #elif defined(BOOTMAGIC_LITE) | ||
21 | # include "bootmagic_lite.h" | ||
22 | #endif | ||
23 | |||
24 | void bootmagic(void); | ||
diff --git a/tmk_core/common/bootmagic.c b/quantum/bootmagic/bootmagic_full.c index c1b3adf94..a7a0dcfcb 100644 --- a/tmk_core/common/bootmagic.c +++ b/quantum/bootmagic/bootmagic_full.c | |||
@@ -1,3 +1,18 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | */ | ||
1 | #include <stdint.h> | 16 | #include <stdint.h> |
2 | #include <stdbool.h> | 17 | #include <stdbool.h> |
3 | #include "wait.h" | 18 | #include "wait.h" |
@@ -10,18 +25,35 @@ | |||
10 | #include "eeconfig.h" | 25 | #include "eeconfig.h" |
11 | #include "bootmagic.h" | 26 | #include "bootmagic.h" |
12 | 27 | ||
13 | keymap_config_t keymap_config; | 28 | /** \brief Scan Keycode |
14 | |||
15 | /** \brief Bootmagic | ||
16 | * | 29 | * |
17 | * FIXME: needs doc | 30 | * FIXME: needs doc |
18 | */ | 31 | */ |
19 | void bootmagic(void) { | 32 | static bool scan_keycode(uint8_t keycode) { |
20 | /* check signature */ | 33 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { |
21 | if (!eeconfig_is_enabled()) { | 34 | matrix_row_t matrix_row = matrix_get_row(r); |
22 | eeconfig_init(); | 35 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
36 | if (matrix_row & ((matrix_row_t)1 << c)) { | ||
37 | if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) { | ||
38 | return true; | ||
39 | } | ||
40 | } | ||
41 | } | ||
23 | } | 42 | } |
43 | return false; | ||
44 | } | ||
45 | |||
46 | /** \brief Bootmagic Scan Keycode | ||
47 | * | ||
48 | * FIXME: needs doc | ||
49 | */ | ||
50 | static bool bootmagic_scan_keycode(uint8_t keycode) { | ||
51 | if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false; | ||
52 | |||
53 | return scan_keycode(keycode); | ||
54 | } | ||
24 | 55 | ||
56 | void bootmagic(void) { | ||
25 | /* do scans in case of bounce */ | 57 | /* do scans in case of bounce */ |
26 | print("bootmagic scan: ... "); | 58 | print("bootmagic scan: ... "); |
27 | uint8_t scan = 100; | 59 | uint8_t scan = 100; |
@@ -46,8 +78,6 @@ void bootmagic(void) { | |||
46 | bootloader_jump(); | 78 | bootloader_jump(); |
47 | } | 79 | } |
48 | 80 | ||
49 | /* debug enable */ | ||
50 | debug_config.raw = eeconfig_read_debug(); | ||
51 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { | 81 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { |
52 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { | 82 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { |
53 | debug_config.matrix = !debug_config.matrix; | 83 | debug_config.matrix = !debug_config.matrix; |
@@ -61,8 +91,6 @@ void bootmagic(void) { | |||
61 | } | 91 | } |
62 | eeconfig_update_debug(debug_config.raw); | 92 | eeconfig_update_debug(debug_config.raw); |
63 | 93 | ||
64 | /* keymap config */ | ||
65 | keymap_config.raw = eeconfig_read_keymap(); | ||
66 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { | 94 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { |
67 | keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; | 95 | keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; |
68 | } | 96 | } |
@@ -93,71 +121,27 @@ void bootmagic(void) { | |||
93 | uint8_t default_layer = 0; | 121 | uint8_t default_layer = 0; |
94 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { | 122 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { |
95 | default_layer |= (1 << 0); | 123 | default_layer |= (1 << 0); |
96 | } | 124 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { |
97 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { | ||
98 | default_layer |= (1 << 1); | 125 | default_layer |= (1 << 1); |
99 | } | 126 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { |
100 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { | ||
101 | default_layer |= (1 << 2); | 127 | default_layer |= (1 << 2); |
102 | } | 128 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { |
103 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { | ||
104 | default_layer |= (1 << 3); | 129 | default_layer |= (1 << 3); |
105 | } | 130 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { |
106 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { | ||
107 | default_layer |= (1 << 4); | 131 | default_layer |= (1 << 4); |
108 | } | 132 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { |
109 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { | ||
110 | default_layer |= (1 << 5); | 133 | default_layer |= (1 << 5); |
111 | } | 134 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { |
112 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { | ||
113 | default_layer |= (1 << 6); | 135 | default_layer |= (1 << 6); |
114 | } | 136 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { |
115 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { | ||
116 | default_layer |= (1 << 7); | 137 | default_layer |= (1 << 7); |
117 | } | 138 | } |
118 | if (default_layer) { | 139 | eeconfig_update_default_layer(default_layer); |
119 | eeconfig_update_default_layer(default_layer); | ||
120 | default_layer_set((layer_state_t)default_layer); | ||
121 | } else { | ||
122 | default_layer = eeconfig_read_default_layer(); | ||
123 | default_layer_set((layer_state_t)default_layer); | ||
124 | } | ||
125 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
126 | layer_state_set_kb((layer_state_t)layer_state); | ||
127 | 140 | ||
128 | /* EE_HANDS handedness */ | 141 | /* EE_HANDS handedness */ |
129 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { | 142 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { |
130 | eeconfig_update_handedness(true); | 143 | eeconfig_update_handedness(true); |
131 | } | 144 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) { |
132 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) { | ||
133 | eeconfig_update_handedness(false); | 145 | eeconfig_update_handedness(false); |
134 | } | 146 | } |
135 | } | 147 | } |
136 | |||
137 | /** \brief Scan Keycode | ||
138 | * | ||
139 | * FIXME: needs doc | ||
140 | */ | ||
141 | static bool scan_keycode(uint8_t keycode) { | ||
142 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | ||
143 | matrix_row_t matrix_row = matrix_get_row(r); | ||
144 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | ||
145 | if (matrix_row & ((matrix_row_t)1 << c)) { | ||
146 | if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) { | ||
147 | return true; | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | return false; | ||
153 | } | ||
154 | |||
155 | /** \brief Bootmagic Scan Keycode | ||
156 | * | ||
157 | * FIXME: needs doc | ||
158 | */ | ||
159 | bool bootmagic_scan_keycode(uint8_t keycode) { | ||
160 | if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false; | ||
161 | |||
162 | return scan_keycode(keycode); | ||
163 | } | ||
diff --git a/tmk_core/common/bootmagic.h b/quantum/bootmagic/bootmagic_full.h index 8209d0194..28f914c1b 100644 --- a/tmk_core/common/bootmagic.h +++ b/quantum/bootmagic/bootmagic_full.h | |||
@@ -1,3 +1,19 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | |||
1 | #pragma once | 17 | #pragma once |
2 | 18 | ||
3 | /* FIXME: Add special doxygen comments for defines here. */ | 19 | /* FIXME: Add special doxygen comments for defines here. */ |
@@ -96,7 +112,4 @@ | |||
96 | #endif | 112 | #endif |
97 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7 | 113 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7 |
98 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 | 114 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 |
99 | #endif | 115 | #endif \ No newline at end of file |
100 | |||
101 | void bootmagic(void); | ||
102 | bool bootmagic_scan_keycode(uint8_t keycode); | ||
diff --git a/tmk_core/common/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c index cbf756a17..9cbdcb0bb 100644 --- a/tmk_core/common/bootmagic_lite.c +++ b/quantum/bootmagic/bootmagic_lite.c | |||
@@ -1,3 +1,18 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | */ | ||
1 | #include "quantum.h" | 16 | #include "quantum.h" |
2 | 17 | ||
3 | /** \brief Reset eeprom | 18 | /** \brief Reset eeprom |
@@ -47,3 +62,5 @@ __attribute__((weak)) void bootmagic_lite(void) { | |||
47 | bootloader_jump(); | 62 | bootloader_jump(); |
48 | } | 63 | } |
49 | } | 64 | } |
65 | |||
66 | void bootmagic(void) { bootmagic_lite(); } | ||
diff --git a/quantum/bootmagic/bootmagic_lite.h b/quantum/bootmagic/bootmagic_lite.h new file mode 100644 index 000000000..17777e6b4 --- /dev/null +++ b/quantum/bootmagic/bootmagic_lite.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | #ifndef BOOTMAGIC_LITE_COLUMN | ||
19 | # define BOOTMAGIC_LITE_COLUMN 0 | ||
20 | #endif | ||
21 | #ifndef BOOTMAGIC_LITE_ROW | ||
22 | # define BOOTMAGIC_LITE_ROW 0 | ||
23 | #endif | ||
24 | |||
25 | void bootmagic_lite(void); | ||
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c new file mode 100644 index 000000000..f1cb11c39 --- /dev/null +++ b/quantum/bootmagic/magic.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 <stdint.h> | ||
17 | #include <stdbool.h> | ||
18 | #include "wait.h" | ||
19 | #include "matrix.h" | ||
20 | #include "bootloader.h" | ||
21 | #include "debug.h" | ||
22 | #include "keymap.h" | ||
23 | #include "host.h" | ||
24 | #include "action_layer.h" | ||
25 | #include "eeconfig.h" | ||
26 | #include "bootmagic.h" | ||
27 | |||
28 | keymap_config_t keymap_config; | ||
29 | |||
30 | __attribute__((weak)) void bootmagic(void) {} | ||
31 | |||
32 | /** \brief Magic | ||
33 | * | ||
34 | * FIXME: Needs doc | ||
35 | */ | ||
36 | void magic(void) { | ||
37 | /* check signature */ | ||
38 | if (!eeconfig_is_enabled()) { | ||
39 | eeconfig_init(); | ||
40 | } | ||
41 | |||
42 | /* init globals */ | ||
43 | debug_config.raw = eeconfig_read_debug(); | ||
44 | keymap_config.raw = eeconfig_read_keymap(); | ||
45 | |||
46 | bootmagic(); | ||
47 | |||
48 | /* read here just incase bootmagic process changed its value */ | ||
49 | layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer(); | ||
50 | default_layer_set(default_layer); | ||
51 | |||
52 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
53 | layer_state_set_kb((layer_state_t)layer_state); | ||
54 | } | ||
diff --git a/quantum/bootmagic/magic.h b/quantum/bootmagic/magic.h new file mode 100644 index 000000000..2c3969b85 --- /dev/null +++ b/quantum/bootmagic/magic.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | void magic(void); | ||
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index f878168c5..d7e334fdc 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h | |||
@@ -37,6 +37,7 @@ typedef union { | |||
37 | bool nkro : 1; | 37 | bool nkro : 1; |
38 | bool swap_lctl_lgui : 1; | 38 | bool swap_lctl_lgui : 1; |
39 | bool swap_rctl_rgui : 1; | 39 | bool swap_rctl_rgui : 1; |
40 | bool oneshot_disable : 1; | ||
40 | }; | 41 | }; |
41 | } keymap_config_t; | 42 | } keymap_config_t; |
42 | 43 | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 80c4e8f00..78601ce6b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -15,6 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "quantum.h" | 17 | #include "quantum.h" |
18 | #include "magic.h" | ||
18 | 19 | ||
19 | #ifdef BLUETOOTH_ENABLE | 20 | #ifdef BLUETOOTH_ENABLE |
20 | # include "outputselect.h" | 21 | # include "outputselect.h" |
@@ -318,6 +319,17 @@ bool process_record_quantum(keyrecord_t *record) { | |||
318 | set_output(OUTPUT_BLUETOOTH); | 319 | set_output(OUTPUT_BLUETOOTH); |
319 | return false; | 320 | return false; |
320 | #endif | 321 | #endif |
322 | #ifndef NO_ACTION_ONESHOT | ||
323 | case ONESHOT_TOGGLE: | ||
324 | oneshot_toggle(); | ||
325 | break; | ||
326 | case ONESHOT_ENABLE: | ||
327 | oneshot_enable(); | ||
328 | break; | ||
329 | case ONESHOT_DISABLE: | ||
330 | oneshot_disable(); | ||
331 | break; | ||
332 | #endif | ||
321 | } | 333 | } |
322 | } | 334 | } |
323 | 335 | ||
@@ -369,12 +381,7 @@ void tap_random_base64(void) { | |||
369 | } | 381 | } |
370 | 382 | ||
371 | void matrix_init_quantum() { | 383 | void matrix_init_quantum() { |
372 | #ifdef BOOTMAGIC_LITE | 384 | magic(); |
373 | bootmagic_lite(); | ||
374 | #endif | ||
375 | if (!eeconfig_is_enabled()) { | ||
376 | eeconfig_init(); | ||
377 | } | ||
378 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) | 385 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) |
379 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef | 386 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef |
380 | led_init_ports(); | 387 | led_init_ports(); |
diff --git a/quantum/quantum.h b/quantum/quantum.h index b1600dd72..070bd0131 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -52,6 +52,7 @@ | |||
52 | #include "action_layer.h" | 52 | #include "action_layer.h" |
53 | #include "eeconfig.h" | 53 | #include "eeconfig.h" |
54 | #include "bootloader.h" | 54 | #include "bootloader.h" |
55 | #include "bootmagic.h" | ||
55 | #include "timer.h" | 56 | #include "timer.h" |
56 | #include "sync_timer.h" | 57 | #include "sync_timer.h" |
57 | #include "config_common.h" | 58 | #include "config_common.h" |
@@ -258,15 +259,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record); | |||
258 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); | 259 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); |
259 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); | 260 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); |
260 | 261 | ||
261 | #ifndef BOOTMAGIC_LITE_COLUMN | ||
262 | # define BOOTMAGIC_LITE_COLUMN 0 | ||
263 | #endif | ||
264 | #ifndef BOOTMAGIC_LITE_ROW | ||
265 | # define BOOTMAGIC_LITE_ROW 0 | ||
266 | #endif | ||
267 | |||
268 | void bootmagic_lite(void); | ||
269 | |||
270 | void reset_keyboard(void); | 262 | void reset_keyboard(void); |
271 | 263 | ||
272 | void startup_user(void); | 264 | void startup_user(void); |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index e0f5dbc61..5eba218c9 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -578,6 +578,10 @@ enum quantum_keycodes { | |||
578 | 578 | ||
579 | #endif | 579 | #endif |
580 | 580 | ||
581 | ONESHOT_ENABLE, | ||
582 | ONESHOT_DISABLE, | ||
583 | ONESHOT_TOGGLE, | ||
584 | |||
581 | // always leave at the end | 585 | // always leave at the end |
582 | SAFE_RANGE | 586 | SAFE_RANGE |
583 | }; | 587 | }; |
@@ -885,3 +889,8 @@ enum quantum_keycodes { | |||
885 | #define DM_RSTP DYN_REC_STOP | 889 | #define DM_RSTP DYN_REC_STOP |
886 | #define DM_PLY1 DYN_MACRO_PLAY1 | 890 | #define DM_PLY1 DYN_MACRO_PLAY1 |
887 | #define DM_PLY2 DYN_MACRO_PLAY2 | 891 | #define DM_PLY2 DYN_MACRO_PLAY2 |
892 | |||
893 | // One Shot toggle | ||
894 | #define OS_TOGG ONESHOT_TOGGLE | ||
895 | #define OS_ON ONESHOT_ENABLE | ||
896 | #define OS_OFF ONESHOT_DISABLE | ||
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 2ae44e6e1..9e75e19ce 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
@@ -1,3 +1,18 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | */ | ||
1 | #include "split_util.h" | 16 | #include "split_util.h" |
2 | #include "matrix.h" | 17 | #include "matrix.h" |
3 | #include "keyboard.h" | 18 | #include "keyboard.h" |
@@ -6,14 +21,7 @@ | |||
6 | #include "transport.h" | 21 | #include "transport.h" |
7 | #include "quantum.h" | 22 | #include "quantum.h" |
8 | #include "wait.h" | 23 | #include "wait.h" |
9 | 24 | #include "usb_util.h" | |
10 | #ifdef PROTOCOL_LUFA | ||
11 | # include <LUFA/Drivers/USB/USB.h> | ||
12 | #endif | ||
13 | |||
14 | #ifdef PROTOCOL_VUSB | ||
15 | # include <usbdrv/usbdrv.h> | ||
16 | #endif | ||
17 | 25 | ||
18 | #ifdef EE_HANDS | 26 | #ifdef EE_HANDS |
19 | # include "eeconfig.h" | 27 | # include "eeconfig.h" |
@@ -31,56 +39,21 @@ | |||
31 | # define SPLIT_USB_TIMEOUT_POLL 10 | 39 | # define SPLIT_USB_TIMEOUT_POLL 10 |
32 | #endif | 40 | #endif |
33 | 41 | ||
34 | #ifdef PROTOCOL_CHIBIOS | ||
35 | # define SPLIT_USB_DETECT // Force this on for now | ||
36 | #endif | ||
37 | |||
38 | volatile bool isLeftHand = true; | 42 | volatile bool isLeftHand = true; |
39 | 43 | ||
40 | #if defined(SPLIT_USB_DETECT) | 44 | #if defined(SPLIT_USB_DETECT) |
41 | # if defined(PROTOCOL_LUFA) | 45 | static bool usbIsActive(void) { |
42 | static inline bool usbHasActiveConnection(void) { return USB_Device_IsAddressSet(); } | ||
43 | static inline void usbDisable(void) { | ||
44 | USB_Disable(); | ||
45 | USB_DeviceState = DEVICE_STATE_Unattached; | ||
46 | } | ||
47 | # elif defined(PROTOCOL_CHIBIOS) | ||
48 | static inline bool usbHasActiveConnection(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } | ||
49 | static inline void usbDisable(void) { usbStop(&USBD1); } | ||
50 | # elif defined(PROTOCOL_VUSB) | ||
51 | static inline bool usbHasActiveConnection(void) { | ||
52 | usbPoll(); | ||
53 | return usbConfiguration; | ||
54 | } | ||
55 | static inline void usbDisable(void) { usbDeviceDisconnect(); } | ||
56 | # else | ||
57 | static inline bool usbHasActiveConnection(void) { return true; } | ||
58 | static inline void usbDisable(void) {} | ||
59 | # endif | ||
60 | |||
61 | bool usbIsActive(void) { | ||
62 | for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { | 46 | for (uint8_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { |
63 | // This will return true if a USB connection has been established | 47 | // This will return true if a USB connection has been established |
64 | if (usbHasActiveConnection()) { | 48 | if (usb_connected_state()) { |
65 | return true; | 49 | return true; |
66 | } | 50 | } |
67 | wait_ms(SPLIT_USB_TIMEOUT_POLL); | 51 | wait_ms(SPLIT_USB_TIMEOUT_POLL); |
68 | } | 52 | } |
69 | |||
70 | // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow | ||
71 | usbDisable(); | ||
72 | |||
73 | return false; | 53 | return false; |
74 | } | 54 | } |
75 | #elif defined(PROTOCOL_LUFA) && defined(OTGPADE) | ||
76 | static inline bool usbIsActive(void) { | ||
77 | USB_OTGPAD_On(); // enables VBUS pad | ||
78 | wait_us(5); | ||
79 | |||
80 | return USB_VBUS_GetStatus(); // checks state of VBUS | ||
81 | } | ||
82 | #else | 55 | #else |
83 | static inline bool usbIsActive(void) { return true; } | 56 | static inline bool usbIsActive(void) { return usb_vbus_state(); } |
84 | #endif | 57 | #endif |
85 | 58 | ||
86 | #ifdef SPLIT_HAND_MATRIX_GRID | 59 | #ifdef SPLIT_HAND_MATRIX_GRID |
@@ -126,6 +99,11 @@ __attribute__((weak)) bool is_keyboard_master(void) { | |||
126 | // only check once, as this is called often | 99 | // only check once, as this is called often |
127 | if (usbstate == UNKNOWN) { | 100 | if (usbstate == UNKNOWN) { |
128 | usbstate = usbIsActive() ? MASTER : SLAVE; | 101 | usbstate = usbIsActive() ? MASTER : SLAVE; |
102 | |||
103 | // Avoid NO_USB_STARTUP_CHECK - Disable USB as the previous checks seem to enable it somehow | ||
104 | if (usbstate == SLAVE) { | ||
105 | usb_disable(); | ||
106 | } | ||
129 | } | 107 | } |
130 | 108 | ||
131 | return (usbstate == MASTER); | 109 | return (usbstate == MASTER); |
@@ -9,6 +9,12 @@ | |||
9 | 9 | ||
10 | This is a keyboard firmware based on the [tmk\_keyboard firmware](https://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR and ARM controllers, and more specifically, the [OLKB product line](https://olkb.com), the [ErgoDox EZ](https://ergodox-ez.com) keyboard, and the [Clueboard product line](https://clueboard.co). | 10 | This is a keyboard firmware based on the [tmk\_keyboard firmware](https://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR and ARM controllers, and more specifically, the [OLKB product line](https://olkb.com), the [ErgoDox EZ](https://ergodox-ez.com) keyboard, and the [Clueboard product line](https://clueboard.co). |
11 | 11 | ||
12 | # THIS IS THE DEVELOP BRANCH | ||
13 | |||
14 | Warning- This is the `develop` branch of QMK Firmware. You may encounter broken code here. Please see [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) for more information. | ||
15 | |||
16 | # Original readme continues | ||
17 | |||
12 | ## Documentation | 18 | ## Documentation |
13 | 19 | ||
14 | * [See the official documentation on docs.qmk.fm](https://docs.qmk.fm) | 20 | * [See the official documentation on docs.qmk.fm](https://docs.qmk.fm) |
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 238b3c69f..2f8f81126 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
@@ -12,6 +12,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ | |||
12 | $(COMMON_DIR)/sendchar_null.c \ | 12 | $(COMMON_DIR)/sendchar_null.c \ |
13 | $(COMMON_DIR)/eeconfig.c \ | 13 | $(COMMON_DIR)/eeconfig.c \ |
14 | $(COMMON_DIR)/report.c \ | 14 | $(COMMON_DIR)/report.c \ |
15 | $(COMMON_DIR)/usb_util.c \ | ||
15 | $(PLATFORM_COMMON_DIR)/suspend.c \ | 16 | $(PLATFORM_COMMON_DIR)/suspend.c \ |
16 | $(PLATFORM_COMMON_DIR)/timer.c \ | 17 | $(PLATFORM_COMMON_DIR)/timer.c \ |
17 | $(COMMON_DIR)/sync_timer.c \ | 18 | $(COMMON_DIR)/sync_timer.c \ |
@@ -24,28 +25,6 @@ else | |||
24 | include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk | 25 | include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk |
25 | endif | 26 | endif |
26 | 27 | ||
27 | # Option modules | ||
28 | BOOTMAGIC_ENABLE ?= no | ||
29 | VALID_MAGIC_TYPES := yes full lite | ||
30 | ifneq ($(strip $(BOOTMAGIC_ENABLE)), no) | ||
31 | ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),) | ||
32 | $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic) | ||
33 | endif | ||
34 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) | ||
35 | TMK_COMMON_DEFS += -DBOOTMAGIC_LITE | ||
36 | TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c | ||
37 | |||
38 | TMK_COMMON_DEFS += -DMAGIC_ENABLE | ||
39 | TMK_COMMON_SRC += $(COMMON_DIR)/magic.c | ||
40 | else | ||
41 | TMK_COMMON_DEFS += -DBOOTMAGIC_ENABLE | ||
42 | TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic.c | ||
43 | endif | ||
44 | else | ||
45 | TMK_COMMON_DEFS += -DMAGIC_ENABLE | ||
46 | TMK_COMMON_SRC += $(COMMON_DIR)/magic.c | ||
47 | endif | ||
48 | |||
49 | SHARED_EP_ENABLE = no | 28 | SHARED_EP_ENABLE = no |
50 | MOUSE_SHARED_EP ?= yes | 29 | MOUSE_SHARED_EP ?= yes |
51 | ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes) | 30 | ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes) |
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 000503b08..a57c8bf66 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
@@ -147,12 +147,16 @@ void clear_oneshot_swaphands(void) { | |||
147 | * FIXME: needs doc | 147 | * FIXME: needs doc |
148 | */ | 148 | */ |
149 | void set_oneshot_layer(uint8_t layer, uint8_t state) { | 149 | void set_oneshot_layer(uint8_t layer, uint8_t state) { |
150 | oneshot_layer_data = layer << 3 | state; | 150 | if (!keymap_config.oneshot_disable) { |
151 | layer_on(layer); | 151 | oneshot_layer_data = layer << 3 | state; |
152 | layer_on(layer); | ||
152 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 153 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
153 | oneshot_layer_time = timer_read(); | 154 | oneshot_layer_time = timer_read(); |
154 | # endif | 155 | # endif |
155 | oneshot_layer_changed_kb(get_oneshot_layer()); | 156 | oneshot_layer_changed_kb(get_oneshot_layer()); |
157 | } else { | ||
158 | layer_on(layer); | ||
159 | } | ||
156 | } | 160 | } |
157 | /** \brief Reset oneshot layer | 161 | /** \brief Reset oneshot layer |
158 | * | 162 | * |
@@ -172,7 +176,7 @@ void reset_oneshot_layer(void) { | |||
172 | void clear_oneshot_layer_state(oneshot_fullfillment_t state) { | 176 | void clear_oneshot_layer_state(oneshot_fullfillment_t state) { |
173 | uint8_t start_state = oneshot_layer_data; | 177 | uint8_t start_state = oneshot_layer_data; |
174 | oneshot_layer_data &= ~state; | 178 | oneshot_layer_data &= ~state; |
175 | if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) { | 179 | if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) || keymap_config.oneshot_disable) { |
176 | layer_off(get_oneshot_layer()); | 180 | layer_off(get_oneshot_layer()); |
177 | reset_oneshot_layer(); | 181 | reset_oneshot_layer(); |
178 | } | 182 | } |
@@ -182,6 +186,39 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state) { | |||
182 | * FIXME: needs doc | 186 | * FIXME: needs doc |
183 | */ | 187 | */ |
184 | bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); } | 188 | bool is_oneshot_layer_active(void) { return get_oneshot_layer_state(); } |
189 | |||
190 | /** \brief set oneshot | ||
191 | * | ||
192 | * FIXME: needs doc | ||
193 | */ | ||
194 | void oneshot_set(bool active) { | ||
195 | if (keymap_config.oneshot_disable != active) { | ||
196 | keymap_config.oneshot_disable = active; | ||
197 | eeconfig_update_keymap(keymap_config.raw); | ||
198 | dprintf("Oneshot: active: %d\n", active); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | /** \brief toggle oneshot | ||
203 | * | ||
204 | * FIXME: needs doc | ||
205 | */ | ||
206 | void oneshot_toggle(void) { oneshot_set(!keymap_config.oneshot_disable); } | ||
207 | |||
208 | /** \brief enable oneshot | ||
209 | * | ||
210 | * FIXME: needs doc | ||
211 | */ | ||
212 | void oneshot_enable(void) { oneshot_set(true); } | ||
213 | |||
214 | /** \brief disable oneshot | ||
215 | * | ||
216 | * FIXME: needs doc | ||
217 | */ | ||
218 | void oneshot_disable(void) { oneshot_set(false); } | ||
219 | |||
220 | bool is_oneshot_enabled(void) { return keymap_config.oneshot_disable; } | ||
221 | |||
185 | #endif | 222 | #endif |
186 | 223 | ||
187 | /** \brief Send keyboard report | 224 | /** \brief Send keyboard report |
@@ -321,14 +358,17 @@ void del_oneshot_mods(uint8_t mods) { | |||
321 | * FIXME: needs doc | 358 | * FIXME: needs doc |
322 | */ | 359 | */ |
323 | void set_oneshot_mods(uint8_t mods) { | 360 | void set_oneshot_mods(uint8_t mods) { |
324 | if (oneshot_mods != mods) { | 361 | if (!keymap_config.oneshot_disable) { |
362 | if (oneshot_mods != mods) { | ||
325 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) | 363 | # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) |
326 | oneshot_time = timer_read(); | 364 | oneshot_time = timer_read(); |
327 | # endif | 365 | # endif |
328 | oneshot_mods = mods; | 366 | oneshot_mods = mods; |
329 | oneshot_mods_changed_kb(mods); | 367 | oneshot_mods_changed_kb(mods); |
368 | } | ||
330 | } | 369 | } |
331 | } | 370 | } |
371 | |||
332 | /** \brief clear oneshot mods | 372 | /** \brief clear oneshot mods |
333 | * | 373 | * |
334 | * FIXME: needs doc | 374 | * FIXME: needs doc |
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h index ff29f79b0..f2b3897ae 100644 --- a/tmk_core/common/action_util.h +++ b/tmk_core/common/action_util.h | |||
@@ -85,6 +85,11 @@ void oneshot_mods_changed_kb(uint8_t mods); | |||
85 | void oneshot_layer_changed_user(uint8_t layer); | 85 | void oneshot_layer_changed_user(uint8_t layer); |
86 | void oneshot_layer_changed_kb(uint8_t layer); | 86 | void oneshot_layer_changed_kb(uint8_t layer); |
87 | 87 | ||
88 | void oneshot_toggle(void); | ||
89 | void oneshot_enable(void); | ||
90 | void oneshot_disable(void); | ||
91 | bool is_oneshot_enabled(void); | ||
92 | |||
88 | /* inspect */ | 93 | /* inspect */ |
89 | uint8_t has_anymod(void); | 94 | uint8_t has_anymod(void); |
90 | 95 | ||
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h index b4d96465d..bebf026de 100644 --- a/tmk_core/common/chibios/chibios_config.h +++ b/tmk_core/common/chibios/chibios_config.h | |||
@@ -15,6 +15,8 @@ | |||
15 | */ | 15 | */ |
16 | #pragma once | 16 | #pragma once |
17 | 17 | ||
18 | #define SPLIT_USB_DETECT // Force this on for now | ||
19 | |||
18 | #if defined(STM32F1XX) | 20 | #if defined(STM32F1XX) |
19 | # define USE_GPIOV1 | 21 | # define USE_GPIOV1 |
20 | #endif | 22 | #endif |
diff --git a/tmk_core/common/chibios/sleep_led.c b/tmk_core/common/chibios/sleep_led.c index 5595eec0e..477056a45 100644 --- a/tmk_core/common/chibios/sleep_led.c +++ b/tmk_core/common/chibios/sleep_led.c | |||
@@ -9,21 +9,13 @@ | |||
9 | * Use LP timer on Kinetises, TIM14 on STM32F0. | 9 | * Use LP timer on Kinetises, TIM14 on STM32F0. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #if defined(KL2x) || defined(K20x) | 12 | #ifndef SLEEP_LED_GPT_DRIVER |
13 | 13 | # if defined(STM32F0XX) | |
14 | /* Use Low Power Timer (LPTMR) */ | 14 | # define SLEEP_LED_GPT_DRIVER GPTD14 |
15 | # define TIMER_INTERRUPT_VECTOR KINETIS_LPTMR0_IRQ_VECTOR | 15 | # endif |
16 | # define RESET_COUNTER LPTMR0->CSR |= LPTMRx_CSR_TCF | ||
17 | |||
18 | #elif defined(STM32F0XX) | ||
19 | |||
20 | /* Use TIM14 manually */ | ||
21 | # define TIMER_INTERRUPT_VECTOR STM32_TIM14_HANDLER | ||
22 | # define RESET_COUNTER STM32_TIM14->SR &= ~STM32_TIM_SR_UIF | ||
23 | |||
24 | #endif | 16 | #endif |
25 | 17 | ||
26 | #if defined(KL2x) || defined(K20x) || defined(STM32F0XX) /* common parts for timers/interrupts */ | 18 | #if defined(KL2x) || defined(K20x) || defined(SLEEP_LED_GPT_DRIVER) /* common parts for timers/interrupts */ |
27 | 19 | ||
28 | /* Breathing Sleep LED brighness(PWM On period) table | 20 | /* Breathing Sleep LED brighness(PWM On period) table |
29 | * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle | 21 | * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle |
@@ -33,10 +25,7 @@ | |||
33 | */ | 25 | */ |
34 | static const uint8_t breathing_table[64] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, 255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | 26 | static const uint8_t breathing_table[64] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, 255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
35 | 27 | ||
36 | /* interrupt handler */ | 28 | void sleep_led_timer_callback(void) { |
37 | OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) { | ||
38 | OSAL_IRQ_PROLOGUE(); | ||
39 | |||
40 | /* Software PWM | 29 | /* Software PWM |
41 | * timer:1111 1111 1111 1111 | 30 | * timer:1111 1111 1111 1111 |
42 | * \_____/\/ \_______/____ count(0-255) | 31 | * \_____/\/ \_______/____ count(0-255) |
@@ -64,17 +53,16 @@ OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) { | |||
64 | if (timer.pwm.count == breathing_table[timer.pwm.index]) { | 53 | if (timer.pwm.count == breathing_table[timer.pwm.index]) { |
65 | led_set(0); | 54 | led_set(0); |
66 | } | 55 | } |
67 | |||
68 | /* Reset the counter */ | ||
69 | RESET_COUNTER; | ||
70 | |||
71 | OSAL_IRQ_EPILOGUE(); | ||
72 | } | 56 | } |
73 | 57 | ||
74 | #endif /* common parts for known platforms */ | 58 | #endif /* common parts for known platforms */ |
75 | 59 | ||
76 | #if defined(KL2x) || defined(K20x) /* platform selection: familiar Kinetis chips */ | 60 | #if defined(KL2x) || defined(K20x) /* platform selection: familiar Kinetis chips */ |
77 | 61 | ||
62 | /* Use Low Power Timer (LPTMR) */ | ||
63 | # define TIMER_INTERRUPT_VECTOR KINETIS_LPTMR0_IRQ_VECTOR | ||
64 | # define RESET_COUNTER LPTMR0->CSR |= LPTMRx_CSR_TCF | ||
65 | |||
78 | /* LPTMR clock options */ | 66 | /* LPTMR clock options */ |
79 | # define LPTMR_CLOCK_MCGIRCLK 0 /* 4MHz clock */ | 67 | # define LPTMR_CLOCK_MCGIRCLK 0 /* 4MHz clock */ |
80 | # define LPTMR_CLOCK_LPO 1 /* 1kHz clock */ | 68 | # define LPTMR_CLOCK_LPO 1 /* 1kHz clock */ |
@@ -86,6 +74,18 @@ OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) { | |||
86 | # define SIM_SCGC5_LPTMR SIM_SCGC5_LPTIMER | 74 | # define SIM_SCGC5_LPTMR SIM_SCGC5_LPTIMER |
87 | # endif | 75 | # endif |
88 | 76 | ||
77 | /* interrupt handler */ | ||
78 | OSAL_IRQ_HANDLER(TIMER_INTERRUPT_VECTOR) { | ||
79 | OSAL_IRQ_PROLOGUE(); | ||
80 | |||
81 | sleep_led_timer_callback(); | ||
82 | |||
83 | /* Reset the counter */ | ||
84 | RESET_COUNTER; | ||
85 | |||
86 | OSAL_IRQ_EPILOGUE(); | ||
87 | } | ||
88 | |||
89 | /* Initialise the timer */ | 89 | /* Initialise the timer */ |
90 | void sleep_led_init(void) { | 90 | void sleep_led_init(void) { |
91 | /* Make sure the clock to the LPTMR is enabled */ | 91 | /* Make sure the clock to the LPTMR is enabled */ |
@@ -159,45 +159,23 @@ void sleep_led_toggle(void) { | |||
159 | LPTMR0->CSR ^= LPTMRx_CSR_TEN; | 159 | LPTMR0->CSR ^= LPTMRx_CSR_TEN; |
160 | } | 160 | } |
161 | 161 | ||
162 | #elif defined(STM32F0XX) /* platform selection: STM32F0XX */ | 162 | #elif defined(SLEEP_LED_GPT_DRIVER) |
163 | |||
164 | /* Initialise the timer */ | ||
165 | void sleep_led_init(void) { | ||
166 | /* enable clock */ | ||
167 | rccEnableTIM14(FALSE); /* low power enable = FALSE */ | ||
168 | rccResetTIM14(); | ||
169 | |||
170 | /* prescale */ | ||
171 | /* Assuming 48MHz internal clock */ | ||
172 | /* getting cca 65484 irqs/sec */ | ||
173 | STM32_TIM14->PSC = 733; | ||
174 | 163 | ||
175 | /* auto-reload */ | 164 | static void gptTimerCallback(GPTDriver *gptp) { |
176 | /* 0 => interrupt every time */ | 165 | (void)gptp; |
177 | STM32_TIM14->ARR = 3; | 166 | sleep_led_timer_callback(); |
167 | } | ||
178 | 168 | ||
179 | /* enable counter update event interrupt */ | 169 | static const GPTConfig gptcfg = {1000000, gptTimerCallback, 0, 0}; |
180 | STM32_TIM14->DIER |= STM32_TIM_DIER_UIE; | ||
181 | 170 | ||
182 | /* register interrupt vector */ | 171 | /* Initialise the timer */ |
183 | nvicEnableVector(STM32_TIM14_NUMBER, 2); /* vector, priority */ | 172 | void sleep_led_init(void) { gptStart(&SLEEP_LED_GPT_DRIVER, &gptcfg); } |
184 | } | ||
185 | 173 | ||
186 | void sleep_led_enable(void) { | 174 | void sleep_led_enable(void) { gptStartContinuous(&SLEEP_LED_GPT_DRIVER, gptcfg.frequency / 0xFFFF); } |
187 | /* Enable the timer */ | ||
188 | STM32_TIM14->CR1 = STM32_TIM_CR1_CEN | STM32_TIM_CR1_URS; | ||
189 | /* URS => update event only on overflow; setting UG bit disabled */ | ||
190 | } | ||
191 | 175 | ||
192 | void sleep_led_disable(void) { | 176 | void sleep_led_disable(void) { gptStopTimer(&SLEEP_LED_GPT_DRIVER); } |
193 | /* Disable the timer */ | ||
194 | STM32_TIM14->CR1 = 0; | ||
195 | } | ||
196 | 177 | ||
197 | void sleep_led_toggle(void) { | 178 | void sleep_led_toggle(void) { (SLEEP_LED_GPT_DRIVER.state == GPT_READY) ? sleep_led_enable() : sleep_led_disable(); } |
198 | /* Toggle the timer */ | ||
199 | STM32_TIM14->CR1 ^= STM32_TIM_CR1_CEN; | ||
200 | } | ||
201 | 179 | ||
202 | #else /* platform selection: not on familiar chips */ | 180 | #else /* platform selection: not on familiar chips */ |
203 | 181 | ||
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index ce3255c06..65d9e00c7 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
@@ -34,11 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
34 | #ifdef BACKLIGHT_ENABLE | 34 | #ifdef BACKLIGHT_ENABLE |
35 | # include "backlight.h" | 35 | # include "backlight.h" |
36 | #endif | 36 | #endif |
37 | #ifdef BOOTMAGIC_ENABLE | ||
38 | # include "bootmagic.h" | ||
39 | #else | ||
40 | # include "magic.h" | ||
41 | #endif | ||
42 | #ifdef MOUSEKEY_ENABLE | 37 | #ifdef MOUSEKEY_ENABLE |
43 | # include "mousekey.h" | 38 | # include "mousekey.h" |
44 | #endif | 39 | #endif |
@@ -296,11 +291,6 @@ void keyboard_init(void) { | |||
296 | #ifdef ADB_MOUSE_ENABLE | 291 | #ifdef ADB_MOUSE_ENABLE |
297 | adb_mouse_init(); | 292 | adb_mouse_init(); |
298 | #endif | 293 | #endif |
299 | #ifdef BOOTMAGIC_ENABLE | ||
300 | bootmagic(); | ||
301 | #else | ||
302 | magic(); | ||
303 | #endif | ||
304 | #ifdef BACKLIGHT_ENABLE | 294 | #ifdef BACKLIGHT_ENABLE |
305 | backlight_init(); | 295 | backlight_init(); |
306 | #endif | 296 | #endif |
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c deleted file mode 100644 index e14994164..000000000 --- a/tmk_core/common/magic.c +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | #include <stdint.h> | ||
2 | #include <stdbool.h> | ||
3 | #if defined(__AVR__) | ||
4 | # include <util/delay.h> | ||
5 | #endif | ||
6 | #include "matrix.h" | ||
7 | #include "bootloader.h" | ||
8 | #include "debug.h" | ||
9 | #include "keymap.h" | ||
10 | #include "host.h" | ||
11 | #include "action_layer.h" | ||
12 | #include "eeconfig.h" | ||
13 | #include "magic.h" | ||
14 | |||
15 | keymap_config_t keymap_config; | ||
16 | |||
17 | /** \brief Magic | ||
18 | * | ||
19 | * FIXME: Needs doc | ||
20 | */ | ||
21 | void magic(void) { | ||
22 | /* check signature */ | ||
23 | if (!eeconfig_is_enabled()) { | ||
24 | eeconfig_init(); | ||
25 | } | ||
26 | |||
27 | /* debug enable */ | ||
28 | debug_config.raw = eeconfig_read_debug(); | ||
29 | |||
30 | /* keymap config */ | ||
31 | keymap_config.raw = eeconfig_read_keymap(); | ||
32 | |||
33 | uint8_t default_layer = 0; | ||
34 | default_layer = eeconfig_read_default_layer(); | ||
35 | default_layer_set((layer_state_t)default_layer); | ||
36 | |||
37 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
38 | layer_state_set_kb((layer_state_t)layer_state); | ||
39 | } | ||
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h deleted file mode 100644 index a6552c04d..000000000 --- a/tmk_core/common/magic.h +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | void magic(void); | ||
diff --git a/tmk_core/common/usb_util.c b/tmk_core/common/usb_util.c new file mode 100644 index 000000000..e4c50fcb1 --- /dev/null +++ b/tmk_core/common/usb_util.c | |||
@@ -0,0 +1,29 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 "usb_util.h" | ||
17 | #include "wait.h" | ||
18 | |||
19 | __attribute__((weak)) void usb_disable(void) {} | ||
20 | __attribute__((weak)) bool usb_connected_state(void) { return true; } | ||
21 | __attribute__((weak)) bool usb_vbus_state(void) { | ||
22 | #ifdef USB_VBUS_PIN | ||
23 | setPinInput(USB_VBUS_PIN); | ||
24 | wait_us(5); | ||
25 | return readPin(USB_VBUS_PIN); | ||
26 | #else | ||
27 | return true; | ||
28 | #endif | ||
29 | } | ||
diff --git a/tmk_core/common/usb_util.h b/tmk_core/common/usb_util.h new file mode 100644 index 000000000..4ebedb1e7 --- /dev/null +++ b/tmk_core/common/usb_util.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 | #include <stdbool.h> | ||
19 | |||
20 | void usb_disable(void); | ||
21 | bool usb_connected_state(void); | ||
22 | bool usb_vbus_state(void); | ||
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 0c41642b9..cc87e8347 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk | |||
@@ -54,5 +54,9 @@ ifeq ($(strip $(XT_ENABLE)), yes) | |||
54 | OPT_DEFS += -DXT_ENABLE | 54 | OPT_DEFS += -DXT_ENABLE |
55 | endif | 55 | endif |
56 | 56 | ||
57 | ifeq ($(strip $(USB_HID_ENABLE)), yes) | ||
58 | include $(TMK_DIR)/protocol/usb_hid.mk | ||
59 | endif | ||
60 | |||
57 | # Search Path | 61 | # Search Path |
58 | VPATH += $(TMK_DIR)/protocol | 62 | VPATH += $(TMK_DIR)/protocol |
diff --git a/tmk_core/protocol/chibios.mk b/tmk_core/protocol/chibios.mk index 80554abb3..d01697835 100644 --- a/tmk_core/protocol/chibios.mk +++ b/tmk_core/protocol/chibios.mk | |||
@@ -6,6 +6,7 @@ SRC += $(CHIBIOS_DIR)/usb_main.c | |||
6 | SRC += $(CHIBIOS_DIR)/main.c | 6 | SRC += $(CHIBIOS_DIR)/main.c |
7 | SRC += usb_descriptor.c | 7 | SRC += usb_descriptor.c |
8 | SRC += $(CHIBIOS_DIR)/usb_driver.c | 8 | SRC += $(CHIBIOS_DIR)/usb_driver.c |
9 | SRC += $(CHIBIOS_DIR)/usb_util.c | ||
9 | SRC += $(LIBSRC) | 10 | SRC += $(LIBSRC) |
10 | 11 | ||
11 | VPATH += $(TMK_PATH)/$(PROTOCOL_DIR) | 12 | VPATH += $(TMK_PATH)/$(PROTOCOL_DIR) |
diff --git a/tmk_core/protocol/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c new file mode 100644 index 000000000..5945e8a8d --- /dev/null +++ b/tmk_core/protocol/chibios/usb_util.c | |||
@@ -0,0 +1,21 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 <hal.h> | ||
17 | #include "usb_util.h" | ||
18 | |||
19 | void usb_disable(void) { usbStop(&USBD1); } | ||
20 | |||
21 | bool usb_connected_state(void) { return usbGetDriverStateI(&USBD1) == USB_ACTIVE; } | ||
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index 1cc1fa04e..9d9fb728b 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk | |||
@@ -44,6 +44,7 @@ ifeq ($(strip $(VIRTSER_ENABLE)), yes) | |||
44 | endif | 44 | endif |
45 | 45 | ||
46 | SRC += $(LUFA_SRC) | 46 | SRC += $(LUFA_SRC) |
47 | SRC += $(LUFA_DIR)/usb_util.c | ||
47 | 48 | ||
48 | # Search Path | 49 | # Search Path |
49 | VPATH += $(TMK_PATH)/$(LUFA_DIR) | 50 | VPATH += $(TMK_PATH)/$(LUFA_DIR) |
diff --git a/tmk_core/protocol/lufa/usb_util.c b/tmk_core/protocol/lufa/usb_util.c new file mode 100644 index 000000000..9e943a21b --- /dev/null +++ b/tmk_core/protocol/lufa/usb_util.c | |||
@@ -0,0 +1,34 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 <LUFA/Drivers/USB/USB.h> | ||
17 | #include "usb_util.h" | ||
18 | #include "wait.h" | ||
19 | |||
20 | void usb_disable(void) { | ||
21 | USB_Disable(); | ||
22 | USB_DeviceState = DEVICE_STATE_Unattached; | ||
23 | } | ||
24 | |||
25 | bool usb_connected_state(void) { return USB_Device_IsAddressSet(); } | ||
26 | |||
27 | #if defined(OTGPADE) | ||
28 | bool usb_vbus_state(void) { | ||
29 | USB_OTGPAD_On(); // enables VBUS pad | ||
30 | wait_us(5); | ||
31 | |||
32 | return USB_VBUS_GetStatus(); // checks state of VBUS | ||
33 | } | ||
34 | #endif | ||
diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk index 1de600308..e4d013b38 100644 --- a/tmk_core/protocol/vusb.mk +++ b/tmk_core/protocol/vusb.mk | |||
@@ -5,6 +5,7 @@ VUSB_PATH = $(LIB_PATH)/vusb | |||
5 | 5 | ||
6 | SRC += $(VUSB_DIR)/main.c \ | 6 | SRC += $(VUSB_DIR)/main.c \ |
7 | $(VUSB_DIR)/vusb.c \ | 7 | $(VUSB_DIR)/vusb.c \ |
8 | $(VUSB_DIR)/usb_util.c \ | ||
8 | $(VUSB_PATH)/usbdrv/usbdrv.c \ | 9 | $(VUSB_PATH)/usbdrv/usbdrv.c \ |
9 | $(VUSB_PATH)/usbdrv/usbdrvasm.S \ | 10 | $(VUSB_PATH)/usbdrv/usbdrvasm.S \ |
10 | $(VUSB_PATH)/usbdrv/oddebug.c | 11 | $(VUSB_PATH)/usbdrv/oddebug.c |
diff --git a/tmk_core/protocol/vusb/usb_util.c b/tmk_core/protocol/vusb/usb_util.c new file mode 100644 index 000000000..602854dbe --- /dev/null +++ b/tmk_core/protocol/vusb/usb_util.c | |||
@@ -0,0 +1,24 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 3 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 <usbdrv/usbdrv.h> | ||
17 | #include "usb_util.h" | ||
18 | |||
19 | void usb_disable(void) { usbDeviceDisconnect(); } | ||
20 | |||
21 | bool usb_connected_state(void) { | ||
22 | usbPoll(); | ||
23 | return usbConfiguration; | ||
24 | } | ||