Repository navigation
Conversation
a536074 to
c9aa875
Compare
mattnite
left a comment
There was a problem hiding this comment.
What testing did you do?
|
Compiling any USB example with debug logging is enough to validate that the events are fired when the host suspend/resumes. For waking up I've added to one of the example small snippet of code that called for it to work, w/o this it properly returned an error. I can add extra example for this. |
|
Yes I agree. An example would be great, please include some comments documenting the behaviour, explain some potential applications of this to users. |
cc29bee to
35334ee
Compare
| var usb_device: USB_Device = undefined; | ||
|
|
||
| // Generate a device controller with descriptor and handlers setup for CDC (USB_Serial) and | ||
| // picotool-controlled reset (ResetDriver). |
There was a problem hiding this comment.
How does picotool enter the picture? I thought resetting a device was a standard thing
There was a problem hiding this comment.
picotool has reboot subcommnd which sends special USB packet, ResetDriver implements that. I just copied this from other examples.
| wakeup_deadline = rp2xxx.time.deadline_in_ms(5 * std.time.ms_per_s); | ||
| } | ||
|
|
||
| fn on_resume() void { |
There was a problem hiding this comment.
Add a context pointer to the callbacks please.
There was a problem hiding this comment.
Is there a point in doing that? both are registered in usb_controller which is global variable anyway.
There was a problem hiding this comment.
It's a global variable in your example, but it may not be a global example in user code.
| default_vendor: ?Options.IdStringPair = null, | ||
| default_product: ?Options.IdStringPair = null, | ||
| /// Ports that enable this must also provide the `signal_resume` vtable function. | ||
| supports_remote_wakeup: bool = false, |
There was a problem hiding this comment.
Not neccessary, you can just check if signal_resume is null
| _ = device_itf; | ||
| log.debug("on_suspend", .{}); | ||
|
|
||
| if (!self.is_suspended) { |
There was a problem hiding this comment.
Log message if on_suspend was called while suspened would be nice
| .create(attr.self_powered, true), | ||
| }; | ||
| }; | ||
| return std.mem.asBytes(&S.responses[@intFromBool(self.remote_wakeup_enabled)]); |
There was a problem hiding this comment.
Does a device really need to be self-powered for remote wakeup to work?
| /// Only called when the bus actually enters suspend. | ||
| on_suspend: ?*const fn () void = null, | ||
| /// Only called when the bus actually leaves suspend. | ||
| on_resume: ?*const fn () void = null, |
There was a problem hiding this comment.
I think this should be handled by returning a value from poll rather than with callbacks
Also adds example for rp2xxx.
35334ee to
c7bfd10
Compare
Requires #1130