-
-
Notifications
You must be signed in to change notification settings - Fork 42.4k
Added power tracking api #12691
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
Added power tracking api #12691
Conversation
|
Tested on STM32F446, and atmega32u4, and atmega32u2. |
7a5fcda to
7667026
Compare
|
While the code looks good, "power tracking" doesn't sound right to me. The point is getting the status from USB, correct? Then maybe "USB Power State" would be more accurate, maybe? That said, I know that naming stuff is hard. I have some truly atrociously named stuff that has made it into core, so I definitely understand that. |
|
Thank you for your contribution! |
74f3fc8 to
c084d5a
Compare
|
@drashna Let me know if any further changes are needed. |
|
Honestly, i'm still not too happy with the naming, as it doesn't really reflect what it is.
|
|
@drashna Renamed as you suggested. |
|
I re-tested the current version of a branch on an STM32F446-based keyboard. On the computer suspending I observed: On the computer exiting suspend I observed: On the 1Amp port of a 'powerzilla' power bank I observed: USB_DEVICE_STATE_INIT -> USB_DEVICE_STATE_SUSPEND Note: since I didn't analyze this with a logical analyzer, in theory there could be super fast state transitions that I missed with my eyes. |
Co-authored-by: Drashna Jaelre <drashna@live.com>
7aadee6 to
e4e7de9
Compare
|
Rebased (not cause this PR needed it, but because the dependent 12692 PR had a conflict) |
|
Can you explain the unused |
|
@tzarc In general, the configuration number matters to how much power the USB device is allowed to consume, because each USB device could have multiple configurations, only one of which is selected at any point in time (or none if not configured). One possible usecase in the future would be, if a keyboard has a 500mA-using solenoid driver, it could have one configuration to select 500mA, and another one to select 100mA, and disable the solenoid driver automatically, or set it into a 100mA current-limited mode. So when you plug the keyboard into a normal USB port, or powered hub, you get full solenoid operation, but in an unpowered usb hub, the solenoid is automatically disabled, or in slower current-limited mode. Or in case of keyboards with high current-consumption backlights, it could throttle the backlight intensity when plugged into a 100mA-only port. I'm not 100% sure if default HID operating system drivers are smart enough to select the alternative 100mA configuration, when they can't enable the 500mA one, or if they will just disable the USB device, so my specific example may not be a good one, but it's still worth keeping the interface, even if my example doesn't actually work in the real world, just in case we will add multiple-configuration support in the future for other reasons. |
* Add power tracking API to lufa and chibios targets * power.c: Pass through power state to the notify function * power: added notify_power_state_change_user too. * making it pass the PR linter * Add a POWER_STATE_NO_INIT state, that we start in before calling power_init(); * Rename *power* to *usb_power* * removing stray newline * Rename usb_power* to usb_device_state* * Update quantum/usb_device_state.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Fix comment * usb_device_state.h: Don't include quantum.h, only the necessary headers. Co-authored-by: Drashna Jaelre <drashna@live.com>
* Add power tracking API to lufa and chibios targets * power.c: Pass through power state to the notify function * power: added notify_power_state_change_user too. * making it pass the PR linter * Add a POWER_STATE_NO_INIT state, that we start in before calling power_init(); * Rename *power* to *usb_power* * removing stray newline * Rename usb_power* to usb_device_state* * Update quantum/usb_device_state.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Fix comment * usb_device_state.h: Don't include quantum.h, only the necessary headers. Co-authored-by: Drashna Jaelre <drashna@live.com>
Description
This has now been tested on chibios, running on an STM32F446, and atmega32u4, and atmega32u2.
Types of Changes
Issues Fixed or Closed by This PR
Checklist