summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
authorJoakim Tufvegren <jocke@barbanet.com>2021-08-03 23:39:34 +0200
committerGitHub <noreply@github.com>2021-08-04 07:39:34 +1000
commit982b782ce30e421f2ad3034bc86efdec58c2ea88 (patch)
treeef5fbec7bc0bcd407b1d044f8e1aab91cb0521ef /tmk_core/protocol
parent1409b368517a8ce9af1320acc75f7a8fbcdfca18 (diff)
downloadqmk_firmware-982b782ce30e421f2ad3034bc86efdec58c2ea88.tar.gz
qmk_firmware-982b782ce30e421f2ad3034bc86efdec58c2ea88.zip
Trigger a wakeup after USB Reset on ChibiOS. (#12831)
After a USB Reset event the device must, according to the spec wake up from any suspend state, so the Configured event that arrives afterwards should be interpreted as an implicit wakeup.
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/chibios/usb_main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 441cfab970..e5edd74dcb 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -415,14 +415,18 @@ static inline void usb_event_wakeup_handler(void) {
#endif /* SLEEP_LED_ENABLE */
}
+bool last_suspend_state = false;
+
void usb_event_queue_task(void) {
usbevent_t event;
while (usb_event_queue_dequeue(&event)) {
switch (event) {
case USB_EVENT_SUSPEND:
+ last_suspend_state = true;
usb_event_suspend_handler();
break;
case USB_EVENT_WAKEUP:
+ last_suspend_state = false;
usb_event_wakeup_handler();
break;
default:
@@ -464,6 +468,9 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
qmkusbConfigureHookI(&drivers.array[i].driver);
}
osalSysUnlockFromISR();
+ if (last_suspend_state) {
+ usb_event_queue_enqueue(USB_EVENT_WAKEUP);
+ }
return;
case USB_EVENT_SUSPEND:
usb_event_queue_enqueue(USB_EVENT_SUSPEND);