aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/chibios/chibios.c
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2024-05-28 14:39:23 +1000
committerNick Brassel <nick@tzarc.org>2024-05-28 14:39:23 +1000
commitf76cc320fd9f3365a80cc0d8af2990bc28d76bde (patch)
tree3c5330bbc9ab254424ac57335510de341b4ada11 /tmk_core/protocol/chibios/chibios.c
parent7620c64b99dc5bec480bfaa2708cb3fae709e2b3 (diff)
parent465ab5a20643722c9b712c6b6924472b7345dd64 (diff)
Merge branch 'develop'
Diffstat (limited to 'tmk_core/protocol/chibios/chibios.c')
-rw-r--r--tmk_core/protocol/chibios/chibios.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 91bb252c7c..a249af8d38 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -51,6 +51,11 @@
#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED (2U)
+#ifdef WAIT_FOR_USB
+// TODO: Remove backwards compatibility with old define
+# define USB_WAIT_FOR_ENUMERATION
+#endif
+
/* -------------------------
* TMK host driver defs
* -------------------------
@@ -70,17 +75,6 @@ host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_nkro, send_mo
void virtser_task(void);
#endif
-#ifdef RAW_ENABLE
-void raw_hid_task(void);
-#endif
-
-#ifdef CONSOLE_ENABLE
-void console_task(void);
-#endif
-#ifdef MIDI_ENABLE
-void midi_ep_task(void);
-#endif
-
/* TESTING
* Amber LED blinker thread, times are in milliseconds.
*/
@@ -154,7 +148,7 @@ void protocol_pre_init(void) {
/* Wait until USB is active */
while (true) {
-#if defined(WAIT_FOR_USB)
+#if defined(USB_WAIT_FOR_ENUMERATION)
if (USB_DRIVER.state == USB_ACTIVE) {
driver = &chibios_driver;
break;
@@ -192,30 +186,25 @@ void protocol_pre_task(void) {
/* Remote wakeup */
if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
usbWakeupHost(&USB_DRIVER);
- restart_usb_driver(&USB_DRIVER);
+# if USB_SUSPEND_WAKEUP_DELAY > 0
+ // Some hubs, kvm switches, and monitors do
+ // weird things, with USB device state bouncing
+ // around wildly on wakeup, yielding race
+ // conditions that can corrupt the keyboard state.
+ //
+ // Pause for a while to let things settle...
+ wait_ms(USB_SUSPEND_WAKEUP_DELAY);
+# endif
}
}
/* Woken up */
- // variables has been already cleared by the wakeup hook
- send_keyboard_report();
-# ifdef MOUSEKEY_ENABLE
- mousekey_send();
-# endif /* MOUSEKEY_ENABLE */
}
#endif
}
void protocol_post_task(void) {
-#ifdef CONSOLE_ENABLE
- console_task();
-#endif
-#ifdef MIDI_ENABLE
- midi_ep_task();
-#endif
#ifdef VIRTSER_ENABLE
virtser_task();
#endif
-#ifdef RAW_ENABLE
- raw_hid_task();
-#endif
+ usb_idle_task();
}