fix selective suspend on RP2040

the tmk_core chibios protocol_pre_task does not
process any usb events when the host is in suspend.

I think there is a race condition where the usb_event_queue_task
will not be processed depending on when usb goes to sleep.
so we may fall into the
while (USB_DRIVER.state == USB_SUSPENDED) {
which comes directly from the hardware interrupt.
and never process pending events in
usb_event_queue_task();

Signed-off-by: Kieran Levin <ktl@frame.work>
This commit is contained in:
Kieran Levin 2023-11-14 22:39:49 -06:00 committed by Daniel Schaefer
parent 0c31aa0d00
commit 385ed1a291
2 changed files with 2 additions and 1 deletions

View File

@ -22,7 +22,7 @@ void suspend_power_down(void) {
// on AVR, this enables the watchdog for 15ms (max), and goes to
// SLEEP_MODE_PWR_DOWN
wait_ms(17);
wait_ms(5);
}
/** \brief suspend wakeup condition

View File

@ -190,6 +190,7 @@ void protocol_pre_task(void) {
* the bus and get our keyboard out of suspension. */
usbWakeupHost(&USB_DRIVER);
}
usb_event_queue_task();
}
/* after a successful wakeup a USB_EVENT_WAKEUP is signaled to QMK by
* ChibiOS, which triggers a wakeup callback that restores the state of