summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorPurdea Andrei <andrei@purdea.ro>2023-06-26 11:36:32 +0300
committerGitHub <noreply@github.com>2023-06-26 10:36:32 +0200
commit3ebdb1258bce5cd486ca5e76ba56084cc1a0a1ac (patch)
tree8ec6118be71ed209229e0d58f64b4b10740a9194 /tmk_core
parent2f9f555add827bbc6b7e6e4a08b830b9825ada4f (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.
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/chibios/chibios.c4
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 @@
49#include "suspend.h" 49#include "suspend.h"
50#include "wait.h" 50#include "wait.h"
51 51
52#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED (2U)
53
52/* ------------------------- 54/* -------------------------
53 * TMK host driver defs 55 * TMK host driver defs
54 * ------------------------- 56 * -------------------------
@@ -187,7 +189,7 @@ void protocol_pre_task(void) {
187 /* Do this in the suspended state */ 189 /* Do this in the suspended state */
188 suspend_power_down(); // on AVR this deep sleeps for 15ms 190 suspend_power_down(); // on AVR this deep sleeps for 15ms
189 /* Remote wakeup */ 191 /* Remote wakeup */
190 if (suspend_wakeup_condition()) { 192 if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
191 usbWakeupHost(&USB_DRIVER); 193 usbWakeupHost(&USB_DRIVER);
192 restart_usb_driver(&USB_DRIVER); 194 restart_usb_driver(&USB_DRIVER);
193 } 195 }