summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/chibios/usb_main.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2023-08-26 19:52:12 -0700
committerGitHub <noreply@github.com>2023-08-27 03:52:12 +0100
commit25331be3164ca609ebecbfcc727ce904e3676594 (patch)
treecd82b1dc06085a977c1ccb9a6c6ba5752a037bc7 /tmk_core/protocol/chibios/usb_main.c
parent736451558e3c66d10838625a30c904cfa30b170c (diff)
Revert changes to ChibiOS Suspend Code (#21830)
* Partially revert #19780 * Finish * Get teensy 3.5/3.6 board files too * fix lint issue * Revert "[Bug] Restore usb suspend wakeup delay (#21676)" This reverts commit e8e989fd7ad7c10e725e50ae8b0a4426e09f7f30. * Apply suggestions from code review Co-authored-by: Joel Challis <git@zvecr.com> --------- Co-authored-by: Joel Challis <git@zvecr.com>
Diffstat (limited to 'tmk_core/protocol/chibios/usb_main.c')
-rw-r--r--tmk_core/protocol/chibios/usb_main.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index e1327f065c..b14ca30c1a 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -784,19 +784,34 @@ void init_usb_driver(USBDriver *usbp) {
#endif
}
- restart_usb_driver(usbp);
+ /*
+ * Activates the USB driver and then the USB bus pull-up on D+.
+ * Note, a delay is inserted in order to not have to disconnect the cable
+ * after a reset.
+ */
+ usbDisconnectBus(usbp);
+ usbStop(usbp);
+ wait_ms(50);
+ usbStart(usbp, &usbcfg);
+ usbConnectBus(usbp);
chVTObjectInit(&keyboard_idle_timer);
}
-/** @brief Restarts the USB driver and emulates a physical bus reconnection.
- * Note that the bus reconnection is MCU and even board specific, so it might
- * be a NOP on some hardware platforms.
- */
__attribute__((weak)) void restart_usb_driver(USBDriver *usbp) {
usbDisconnectBus(usbp);
usbStop(usbp);
- wait_ms(50);
+
+#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
+
usbStart(usbp, &usbcfg);
usbConnectBus(usbp);
}