16cca527a6b46c2aa365428d7d1e214509068c4a

Author
Joel Challis <git@zvecr.com>
Committer
GitHub <noreply@github.com>
Date

Message

Fix WAIT_FOR_USB handling (#23598)

Diff

This diff is truncated to protect this page.

  1diff --git a/data/mappings/info_rules.hjson b/data/mappings/info_rules.hjson
  2index 35e2e8dfc0dd4dfd562be28053ccb57972d4e315..5d08be2fc1a440d939aae5a8df8666d5dec33696 100644
  3--- a/data/mappings/info_rules.hjson
  4+++ b/data/mappings/info_rules.hjson
  5@@ -44,7 +44,7 @@
  6     "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "to_c": false},
  7     "STENO_ENABLE": {"info_key": "stenography.enabled", "value_type": "bool"},
  8     "STENO_PROTOCOL": {"info_key": "stenography.protocol"},
  9-    "WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"},
 10+    "USB_WAIT_FOR_ENUMERATION": {"info_key": "usb.wait_for_enumeration", "value_type": "bool"},
 11     "WEAR_LEVELING_DRIVER": {"info_key": "eeprom.wear_leveling.driver"},
 12     "WS2812_DRIVER": {"info_key": "ws2812.driver"},
 13 
 14diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema
 15index f3116fd271070ddc7e684dced10e4f6013f67089..24f7fec9ab3653b6658ea7f7c69bdedef134578a 100644
 16--- a/data/schemas/keyboard.jsonschema
 17+++ b/data/schemas/keyboard.jsonschema
 18@@ -894,7 +894,7 @@
 19                     }
 20                 },
 21                 "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"},
 22-                "wait_for": {"type": "boolean"}
 23+                "wait_for_enumeration": {"type": "boolean"}
 24             }
 25         },
 26         "qmk": {
 27diff --git a/docs/config_options.md b/docs/config_options.md
 28index 045d9c07479df42961a4d71271e8a17a8195f0d9..fca80e54fde5efb11dcfc5ff27f1d2e23717f10c 100644
 29--- a/docs/config_options.md
 30+++ b/docs/config_options.md
 31@@ -446,7 +446,7 @@ Use these to enable or disable building certain features. The more you have enab
 32   * Allows replacing the standard matrix scanning routine with a custom one.
 33 * `DEBOUNCE_TYPE`
 34   * Allows replacing the standard key debouncing routine with an alternative or custom one.
 35-* `WAIT_FOR_USB`
 36+* `USB_WAIT_FOR_ENUMERATION`
 37   * Forces the keyboard to wait for a USB connection to be established before it starts up
 38 * `NO_USB_STARTUP_CHECK`
 39diff --git a/docs/ja/config_options.md b/docs/ja/config_options.md
 40index a349081d6a2752f442cfccb40b1fa56c6983a806..6cc1b6bfcd7f72b2742c59a01ee878edb9adcbcc 100644
 41--- a/docs/ja/config_options.md
 42+++ b/docs/ja/config_options.md
 43@@ -378,7 +378,7 @@ QMK での全ての利用可能な設定にはデフォルトがあります。
 44   * 標準マトリックス走査ルーチンを独自のものに置き換えることができます。
 45 * `DEBOUNCE_TYPE`
 46   * 標準キーデバウンスルーチンを代替または独自のものに置き換えることができます。
 47-* `WAIT_FOR_USB`
 48+* `USB_WAIT_FOR_ENUMERATION`
 49   * キーボードが起動する前に、USB 接続が確立されるのをキーボードに待機させます
 50 * `NO_USB_STARTUP_CHECK`
 51diff --git a/docs/reference_info_json.md b/docs/reference_info_json.md
 52index e6bc34e79ec1ab1309b2a0492e5e53aa50c70a10..6f0b84c414b760fd284fd3abb6494ce42aa7d741 100644
 53--- a/docs/reference_info_json.md
 54+++ b/docs/reference_info_json.md
 55@@ -833,7 +833,7 @@ Configures the [Stenography](feature_stenography.md) feature.
 56     * `suspend_wakeup_delay`
 57         * The amount of time to wait after sending a wakeup packet, in milliseconds.
 58         * Default: `0` (disabled)
 59-    * `wait_for`
 60+    * `wait_for_enumeration`
 61         * Force the keyboard to wait for USB enumeration before starting up.
 62         * Default: `false`
 63 
 64diff --git a/keyboards/converter/hp_46010a/keyboard.json b/keyboards/converter/hp_46010a/keyboard.json
 65index 0296bda5e98fe3a7ffe4f707f85490a3252a59de..45193069813d938e3fde307139f1926cdb1a6802 100644
 66--- a/keyboards/converter/hp_46010a/keyboard.json
 67+++ b/keyboards/converter/hp_46010a/keyboard.json
 68@@ -6,7 +6,8 @@
 69   "usb": {
 70     "vid": "0xFEED",
 71     "pid": "0x6060",
 72-    "device_version": "0.0.1"
 73+    "device_version": "0.0.1",
 74+    "wait_for_enumeration": true
 75   },
 76   "processor": "atmega32u4",
 77   "bootloader": "halfkay",
 78diff --git a/keyboards/converter/hp_46010a/rules.mk b/keyboards/converter/hp_46010a/rules.mk
 79index 3c6124d20abc049c9d90b47b5c6dafb451c74f7a..857395fb4049495fa90dc080cf5c908a85d6f1bc 100644
 80--- a/keyboards/converter/hp_46010a/rules.mk
 81+++ b/keyboards/converter/hp_46010a/rules.mk
 82@@ -1,4 +1,3 @@
 83-WAIT_FOR_USB = yes
 84 CUSTOM_MATRIX = yes
 85 
 86 SRC = matrix.c
 87diff --git a/keyboards/geekboards/macropad_v2/config.h b/keyboards/geekboards/macropad_v2/config.h
 88index dca98f0c954e91e65f2fc814e2c60ea945555ac8..e452c886f69f3a3c4342fcd77e4568d15879a2b9 100644
 89--- a/keyboards/geekboards/macropad_v2/config.h
 90+++ b/keyboards/geekboards/macropad_v2/config.h
 91@@ -21,5 +21,3 @@
 92 #define WS2812_PWM_PAL_MODE 1
 93 #define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM3
 94 #define WS2812_PWM_DMA_CHANNEL 3
 95-
 96-#define WAIT_FOR_USB
 97diff --git a/keyboards/geekboards/macropad_v2/keyboard.json b/keyboards/geekboards/macropad_v2/keyboard.json
 98index 035a83c157d74b54bde9b7e9609332ff5e1baeb2..54d779570a659f165c64b0f36bf3869b784c75fa 100644
 99--- a/keyboards/geekboards/macropad_v2/keyboard.json
100+++ b/keyboards/geekboards/macropad_v2/keyboard.json
101@@ -6,7 +6,8 @@
102   "usb": {
103     "vid": "0x0483",
104     "pid": "0xA372",
105-    "device_version": "0.0.2"
106+    "device_version": "0.0.2",
107+    "wait_for_enumeration": true
108   },
109   "qmk": {
110     "tap_keycode_delay": 10
111diff --git a/keyboards/ristretto/keyboard.json b/keyboards/ristretto/keyboard.json
112index b28f3c1dc1091b2cc519f74f18aa5a6372a298b2..e8e812b7d2f57a55d6fdae64175611ef4eed9399 100644
113--- a/keyboards/ristretto/keyboard.json
114+++ b/keyboards/ristretto/keyboard.json
115@@ -6,7 +6,8 @@
116     "usb": {
117         "vid": "0x666B",
118         "pid": "0x7273",
119-        "device_version": "0.0.1"
120+        "device_version": "0.0.1",
121+        "wait_for_enumeration": true
122     },
123     "features": {
124         "bootmagic": false,
125diff --git a/keyboards/ristretto/rules.mk b/keyboards/ristretto/rules.mk
126deleted file mode 100644
127index 908e5e972ec83d9e8bf9d0065418549c088aacf5..0000000000000000000000000000000000000000
128--- a/keyboards/ristretto/rules.mk
129+++ /dev/null
130@@ -1 +0,0 @@
131-WAIT_FOR_USB = yes
132diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
133index fd5342d637e91ccf56f6e34f13ed2d0b6e493bfb..796b4e878713855218eb2ffed0b558a8ba6799fc 100644
134--- a/tmk_core/protocol.mk
135+++ b/tmk_core/protocol.mk
136@@ -66,6 +66,10 @@ ifeq ($(strip $(NO_USB_STARTUP_CHECK)), yes)
137     OPT_DEFS += -DNO_USB_STARTUP_CHECK
138 endif
139 
140+ifeq ($(strip $(USB_WAIT_FOR_ENUMERATION)), yes)
141+    OPT_DEFS += -DUSB_WAIT_FOR_ENUMERATION
142+endif
143+
144 ifeq ($(strip $(JOYSTICK_SHARED_EP)), yes)
145     OPT_DEFS += -DJOYSTICK_SHARED_EP
146     SHARED_EP_ENABLE = yes
147diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
148index a02097785f4d5ed96980f08b3768430c07b7aabc..a249af8d38cca63d0afdf03c0225d59fcb94c7ac 100644
149--- a/tmk_core/protocol/chibios/chibios.c
150+++ b/tmk_core/protocol/chibios/chibios.c
151@@ -51,6 +51,11 @@
152 
153 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED (2U)
154 
155+#ifdef WAIT_FOR_USB
156+// TODO: Remove backwards compatibility with old define
157+#    define USB_WAIT_FOR_ENUMERATION
158+#endif
159+
160 /* -------------------------
161  *   TMK host driver defs
162  * -------------------------
163@@ -143,7 +148,7 @@ void protocol_pre_init(void) {
164 
165     /* Wait until USB is active */
166     while (true) {
167-#if defined(WAIT_FOR_USB)
168+#if defined(USB_WAIT_FOR_ENUMERATION)
169         if (USB_DRIVER.state == USB_ACTIVE) {
170             driver = &chibios_driver;
171             break;
172diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
173index d6f0c69b6b0db0f95ace69bff1ae016f9c1e2004..2142b04460a15c79795cf47b5d759302157fe497 100644
174--- a/tmk_core/protocol/lufa/lufa.c
175+++ b/tmk_core/protocol/lufa/lufa.c
176@@ -67,6 +67,11 @@
177 #    include "raw_hid.h"
178 #endif
179 
180+#ifdef WAIT_FOR_USB
181+// TODO: Remove backwards compatibility with old define
182+#    define USB_WAIT_FOR_ENUMERATION
183+#endif
184+
185 uint8_t keyboard_idle = 0;
186 /* 0: Boot Protocol, 1: Report Protocol(default) */
187 uint8_t        keyboard_protocol  = 1;
188@@ -807,7 +812,7 @@ void protocol_pre_init(void) {
189 
190     /* wait for USB startup & debug output */
191 
192-#ifdef WAIT_FOR_USB
193+#ifdef USB_WAIT_FOR_ENUMERATION
194     while (USB_DeviceState != DEVICE_STATE_Configured) {
195 #    if defined(INTERRUPT_CONTROL_ENDPOINT)
196         ;