From fd09bcdfd39e9a48b5bfcd19712dffbf52032302 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sun, 9 Jan 2022 18:21:05 +0100 Subject: [PATCH] ChibiOS: shorten USB disconnect state on boot to 50ms A SE0 state for longer then 2.5us signals a device disconnect from the USB bus - according to the USB specs. So the 1500ms are much longer than actually needed and had been copied from the ChibiOS demo code. That code does not state any reason for the long wait. The new 50ms wait was chosen arbitrarily to be barely noticeable, but to be plenty of time for hosts/hubs that do not adhere to the specs. For split keyboards which rely on a fast enumeration for primary / secondary negotiation this shortens the boot up noticeably. Also a soft reset for the USB connection should only be necessary for: * MCUs with fixed pull-ups on the data lines that always signal readiness to establish a USB connection to the host * In situations where a system is reset without a real cable disconnect --- tmk_core/protocol/chibios/usb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index ac46a9312b49..541c44b574e2 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -734,7 +734,7 @@ void init_usb_driver(USBDriver *usbp) { * after a reset. */ usbDisconnectBus(usbp); - wait_ms(1500); + wait_ms(50); usbStart(usbp, &usbcfg); usbConnectBus(usbp);