diff options
author | Purdea Andrei <andrei@purdea.ro> | 2023-06-26 11:36:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 10:36:32 +0200 |
commit | 3ebdb1258bce5cd486ca5e76ba56084cc1a0a1ac (patch) | |
tree | 8ec6118be71ed209229e0d58f64b4b10740a9194 | |
parent | 2f9f555add827bbc6b7e6e4a08b830b9825ada4f (diff) |
Chibios USB: Take into account if host wants remote wakeup or not (#21287)
According to the USB 2.0 spec, remote wakeup should be disabled by
default, and should only be enabled if the host explicitly requests
it. The chibios driver code already takes care of storing this
information, and returning it on GET_STATUS requests. However our
application code has been ignoring it so far.
This is a USB compliance issue, but also a bug that causes trouble
in some cases: On RP2040 targets this has been causing problems if
a key is held down while the keyboard is plugged in. The keyboard
would fail to enumerate until all keys are released. With this
change that behavior is fixed.
Note that for LUFA targets this is already done correctly.
-rw-r--r-- | tmk_core/protocol/chibios/chibios.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index 10a976608a..52aea241ff 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -49,6 +49,8 @@ #include "suspend.h" #include "wait.h" +#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED (2U) + /* ------------------------- * TMK host driver defs * ------------------------- @@ -187,7 +189,7 @@ void protocol_pre_task(void) { /* Do this in the suspended state */ suspend_power_down(); // on AVR this deep sleeps for 15ms /* Remote wakeup */ - if (suspend_wakeup_condition()) { + if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) { usbWakeupHost(&USB_DRIVER); restart_usb_driver(&USB_DRIVER); } |