diff --git a/embassy-hal-common/src/usb/mod.rs b/embassy-hal-common/src/usb/mod.rs index 70a74bd52..bab72d8b6 100644 --- a/embassy-hal-common/src/usb/mod.rs +++ b/embassy-hal-common/src/usb/mod.rs @@ -11,7 +11,7 @@ pub mod usb_serial; use crate::peripheral::{PeripheralMutex, PeripheralState, StateStorage}; use embassy::interrupt::Interrupt; -use usb_serial::{ReadInterface, UsbSerial, WriteInterface}; +pub use usb_serial::{ReadInterface, UsbSerial, WriteInterface}; /// Marker trait to mark an interrupt to be used with the [`Usb`] abstraction. pub unsafe trait USBInterrupt: Interrupt + Send {} diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 95e3b3e7b..13e7803a8 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -73,21 +73,25 @@ pub(crate) use chip::pac; pub use chip::{peripherals, Peripherals}; -use nrf_usbd::{UsbPeripheral, Usbd}; -use usb_device::bus::UsbBusAllocator; +#[cfg(any(feature = "nrf52820", feature = "nrf52833", feature = "nrf52840"))] +pub mod usb { -pub struct UsbBus; -unsafe impl UsbPeripheral for UsbBus { - const REGISTERS: *const () = pac::USBD::ptr() as *const (); -} + use nrf_usbd::{UsbPeripheral, Usbd}; + use usb_device::bus::UsbBusAllocator; -impl UsbBus { - pub fn new() -> UsbBusAllocator> { - Usbd::new(UsbBus) + pub struct UsbBus; + unsafe impl UsbPeripheral for UsbBus { + const REGISTERS: *const () = crate::pac::USBD::ptr() as *const (); } -} -unsafe impl embassy_hal_common::usb::USBInterrupt for interrupt::USBD {} + impl UsbBus { + pub fn new() -> UsbBusAllocator> { + Usbd::new(UsbBus) + } + } + + unsafe impl embassy_hal_common::usb::USBInterrupt for crate::interrupt::USBD {} +} pub mod interrupt { pub use crate::chip::irqs::*; diff --git a/examples/nrf/src/bin/usb_uart.rs b/examples/nrf/src/bin/usb_uart.rs index b81fd5ee8..383edb348 100644 --- a/examples/nrf/src/bin/usb_uart.rs +++ b/examples/nrf/src/bin/usb_uart.rs @@ -17,7 +17,7 @@ use embassy::executor::Spawner; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy::time::{Duration, Timer}; use embassy_hal_common::usb::{State, Usb, UsbSerial}; -use embassy_nrf::UsbBus; +use embassy_nrf::usb::UsbBus; use embassy_nrf::{interrupt, Peripherals}; use usb_device::device::{UsbDeviceBuilder, UsbVidPid};