summaryrefslogtreecommitdiff
path: root/embassy-usb
diff options
context:
space:
mode:
authoralexmoon <alex.r.moon@gmail.com>2022-04-12 17:51:50 -0400
committeralexmoon <alex.r.moon@gmail.com>2022-04-13 14:55:02 -0400
commit2915e858baac442e71bac4b565746401deed22bd (patch)
treec4e91cc7de6be24000b9bb39096571d5f26f39df /embassy-usb
parent7fde3abd5d7e04f6d79d325d4454d6eafabebc1f (diff)
downloadembassy-2915e858baac442e71bac4b565746401deed22bd.zip
Make Driver::disable async and fix comment
Diffstat (limited to 'embassy-usb')
-rw-r--r--embassy-usb/src/driver.rs7
-rw-r--r--embassy-usb/src/lib.rs2
2 files changed, 5 insertions, 4 deletions
diff --git a/embassy-usb/src/driver.rs b/embassy-usb/src/driver.rs
index 99610dee..cedd349f 100644
--- a/embassy-usb/src/driver.rs
+++ b/embassy-usb/src/driver.rs
@@ -59,6 +59,9 @@ pub trait Bus {
type EnableFuture<'a>: Future<Output = ()> + 'a
where
Self: 'a;
+ type DisableFuture<'a>: Future<Output = ()> + 'a
+ where
+ Self: 'a;
type PollFuture<'a>: Future<Output = Event> + 'a
where
Self: 'a;
@@ -71,7 +74,7 @@ pub trait Bus {
fn enable(&mut self) -> Self::EnableFuture<'_>;
/// Disables and powers down the USB peripheral.
- fn disable(&mut self);
+ fn disable(&mut self) -> Self::DisableFuture<'_>;
fn poll<'a>(&'a mut self) -> Self::PollFuture<'a>;
@@ -103,8 +106,6 @@ pub trait Bus {
/// Initiates a remote wakeup of the host by the device.
///
- /// The default implementation just returns `Unsupported`.
- ///
/// # Errors
///
/// * [`Unsupported`](crate::UsbError::Unsupported) - This UsbBus implementation doesn't support
diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs
index 210908c2..11561430 100644
--- a/embassy-usb/src/lib.rs
+++ b/embassy-usb/src/lib.rs
@@ -198,7 +198,7 @@ impl<'d, D: Driver<'d>, M: RawMutex> UsbDevice<'d, D, M> {
DeviceCommand::Enable => warn!("usb: Enable command received while enabled."),
DeviceCommand::Disable => {
trace!("usb: disable");
- self.bus.disable();
+ self.bus.disable().await;
self.device_state = UsbDeviceState::Disabled;
if let Some(h) = &self.handler {
h.disabled();