Skip to content
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

Add suspend, resume and remote wakeup support. #406

Merged
merged 1 commit into from
Jul 31, 2022

Conversation

ithinuel
Copy link
Member

Every thing is in the title :)

Although, it's worth noting that due to a bug in the currently published version of usb-device (0.2.8) this won't work properly.
A fix has been merged already so until it's published on crates.io one has to

[patch.crates-io]
usb-device = { git="https://github.com/rust-embedded-community/usb-device" }

Copy link
Member

@9names 9names left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm.
Will probably want to move all interrupt::free to critical-section::with at some point (conditionally) as Jannic has done, but in practice I don't think it's sensible to call the USB driver from 2 cores anyway

@9names
Copy link
Member

9names commented Jul 30, 2022

On second thought, adding the atomic aliases and removing the critical sections altogether is a better choice.

@jannic
Copy link
Member

jannic commented Jul 31, 2022

What's the point of those suspend/resume operations? Isn't it meant to be some kind of power saving operation?
If so, shouldn't the firmware actually somehow change it's behaviour when in suspend more? So there should be some way for the driver to signal that to the rest of the firmware.
Or am I misunderstanding what this suspend mode is trying to achieve and it's all about suspending the USB communication itself?

@ithinuel
Copy link
Member Author

ithinuel commented Jul 31, 2022

The usb-device stack has a fn state(&self) -> UsbDeviceState member that the application should monitor for changes to and from suspended.

EDIT:
For example, this is how I use it in my keyboard firmware to wakeup the host when a key is pressed while suspended:
https://github.com/ithinuel/wilskeeb/blob/main/firmware/src/main.rs#L436-L441

@jannic jannic merged commit b1fcb7e into rp-rs:main Jul 31, 2022
@ithinuel ithinuel deleted the add-suspend-and-remote-wakeup-support branch August 2, 2022 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants