diff options
author | Stefan Kerkmann <karlk90@pm.me> | 2023-08-03 00:42:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 23:42:57 +0100 |
commit | e8e989fd7ad7c10e725e50ae8b0a4426e09f7f30 (patch) | |
tree | 4f2f784c81505034f54f854e85aa478cc610782c /tmk_core/protocol/chibios/usb_main.c | |
parent | d232f60c01f818535166494bb674565236bc131e (diff) |
[Bug] Restore usb suspend wakeup delay (#21676)
* Respect USB_SUSPEND_WAKEUP_DELAY on wakeup
This delay wasn't honored after removing `restart_usb_driver` from the
suspend and wakeup handling. It is now re-introduced in the appropriate
spot, namely after issuing a remote wakeup to a sleeping host.
* Remove old, unused and commented testing code
Diffstat (limited to 'tmk_core/protocol/chibios/usb_main.c')
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index b14ca30c1a..e1327f065c 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -784,34 +784,19 @@ void init_usb_driver(USBDriver *usbp) { #endif } - /* - * 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); + restart_usb_driver(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); - -#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 - + wait_ms(50); usbStart(usbp, &usbcfg); usbConnectBus(usbp); } |