From f43d57846e010459b8eafcf16ec826cbbf8669e9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 19 May 2023 15:20:37 +0200 Subject: [PATCH] stm32/usb: do not require embassy-time. Fixes #1466 --- embassy-stm32/src/lib.rs | 2 +- embassy-stm32/src/usb/usb.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 1b6f83c3..3283c406 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -58,7 +58,7 @@ pub mod spi; pub mod tl_mbox; #[cfg(usart)] pub mod usart; -#[cfg(all(usb, feature = "time"))] +#[cfg(usb)] pub mod usb; #[cfg(otg)] pub mod usb_otg; diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index ad68eaba..56c46476 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs @@ -7,7 +7,6 @@ use core::task::Poll; use embassy_hal_common::into_ref; use embassy_sync::waitqueue::AtomicWaker; -use embassy_time::{block_for, Duration}; use embassy_usb_driver as driver; use embassy_usb_driver::{ Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, @@ -200,7 +199,10 @@ impl<'d, T: Instance> Driver<'d, T> { w.set_fres(true); }); - block_for(Duration::from_millis(100)); + #[cfg(time)] + embassy_time::block_for(embassy_time::Duration::from_millis(100)); + #[cfg(not(time))] + cortex_m::asm::delay(crate::rcc::get_freqs().sys.0 / 10); #[cfg(not(usb_v4))] regs.btable().write(|w| w.set_btable(0));