-
-
Notifications
You must be signed in to change notification settings - Fork 39.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger a wakeup after USB Reset on ChibiOS #12831
Conversation
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.
To avoid a tiny race condition when the USB interrupt for a new state change comes while
This actually may be even better, because then it's obvious that |
Hmm, true. I mainly added the if statement to avoid calling |
My testing suggests that this would cause e.g. backlight to turn on immediately when data is disconnected but power is still there. Probably not desirable... |
This seems to be behaving well on my split f401, I'm not using a usb switch or hub. The keyboard is directly plugged in at the computer. After suspending the computer the keyboard would suspend correctly but on resume I didn't manage to work out why, instead I resorted to using this bodge to fix my wakeup issue. |
Have you tried using |
Well, it wouldn't have any effect, as I had to comment out the call to (And yes, I tried setting |
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.
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.
Description
I have my keyboard (Ergodox Infinity) connected to a powered USB hub/switch that can be connected to two computers allowing me switch between the computers with a button. Currently, switching between computers (or unplugging the cable from the "active" computer) causes
suspend_power_down()
to be called, butsuspend_wakeup_init()
never gets called afterwards. I suspect the same would happen with keyboards connected to at least some externally powered USB hubs when the hubs get disconnected from the host.Some investigation showed that the device got a reset event when the USB switch was triggered, but retained power. Discussing this on Discord notified me about the fact that the USB specification (section 7.1.7.3) says that "Reset must wake a device from the Suspend state.", so a Reset event (or maybe more fitting, a Configured event) should in some way also be an implicit Wakeup. This is only a problem on ChibiOS as it calls
suspend_wakeup_init()
purely based on events, while the corresponding code for LUFA calls it after exiting the loop that callssuspend_power_down()
since #11450 (both implementations have this kind of loop).This pull request adds a wakeup trigger to the end of handling
USB_EVENT_CONFIGURED
(if the device was suspended prior to the event) on ChibiOS. I must admit I'm in slightly deep water here regarding the specifics, but it does solve my issue. One could argue that the issue could be solved the same way as for LUFA instead (addingsuspend_wakeup_init()
after the suspend loop in tmk_core/protocol/chibios/main.c), but I'm not sure if there's a reason for why that's not done before.Types of Changes
Checklist