mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
add susependable
field to embassy_usb::builder::Config
- allow for optional override of `Suspend` event for a UsbDevice
This commit is contained in:
parent
915423fc63
commit
d596a1091d
@ -94,6 +94,15 @@ pub struct Config<'a> {
|
||||
/// Default: 100mA
|
||||
/// Max: 500mA
|
||||
pub max_power: u16,
|
||||
|
||||
/// Allow the bus to be suspended.
|
||||
///
|
||||
/// If set to `true`, the bus will put itself in the suspended state
|
||||
/// when it receives a `driver::Event::Suspend` bus event. If you wish
|
||||
/// to override this behavior, set this field to `false`.
|
||||
///
|
||||
/// Default: `true`
|
||||
pub suspendable: bool,
|
||||
}
|
||||
|
||||
impl<'a> Config<'a> {
|
||||
@ -114,6 +123,7 @@ impl<'a> Config<'a> {
|
||||
supports_remote_wakeup: false,
|
||||
composite_with_iads: false,
|
||||
max_power: 100,
|
||||
suspendable: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,9 +471,11 @@ impl<'d, D: Driver<'d>> Inner<'d, D> {
|
||||
}
|
||||
Event::Suspend => {
|
||||
trace!("usb: suspend");
|
||||
self.suspended = true;
|
||||
for h in &mut self.handlers {
|
||||
h.suspended(true);
|
||||
if self.config.suspendable {
|
||||
self.suspended = true;
|
||||
for h in &mut self.handlers {
|
||||
h.suspended(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::PowerDetected => {
|
||||
|
Loading…
Reference in New Issue
Block a user