mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 23:02:30 +00:00
usb feature gate
This commit is contained in:
parent
f430c0e8c2
commit
e5dc63e8e9
@ -11,7 +11,7 @@ pub mod usb_serial;
|
|||||||
|
|
||||||
use crate::peripheral::{PeripheralMutex, PeripheralState, StateStorage};
|
use crate::peripheral::{PeripheralMutex, PeripheralState, StateStorage};
|
||||||
use embassy::interrupt::Interrupt;
|
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.
|
/// Marker trait to mark an interrupt to be used with the [`Usb`] abstraction.
|
||||||
pub unsafe trait USBInterrupt: Interrupt + Send {}
|
pub unsafe trait USBInterrupt: Interrupt + Send {}
|
||||||
|
@ -73,21 +73,25 @@ pub(crate) use chip::pac;
|
|||||||
|
|
||||||
pub use chip::{peripherals, Peripherals};
|
pub use chip::{peripherals, Peripherals};
|
||||||
|
|
||||||
use nrf_usbd::{UsbPeripheral, Usbd};
|
#[cfg(any(feature = "nrf52820", feature = "nrf52833", feature = "nrf52840"))]
|
||||||
use usb_device::bus::UsbBusAllocator;
|
pub mod usb {
|
||||||
|
|
||||||
pub struct UsbBus;
|
use nrf_usbd::{UsbPeripheral, Usbd};
|
||||||
unsafe impl UsbPeripheral for UsbBus {
|
use usb_device::bus::UsbBusAllocator;
|
||||||
const REGISTERS: *const () = pac::USBD::ptr() as *const ();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UsbBus {
|
pub struct UsbBus;
|
||||||
|
unsafe impl UsbPeripheral for UsbBus {
|
||||||
|
const REGISTERS: *const () = crate::pac::USBD::ptr() as *const ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UsbBus {
|
||||||
pub fn new() -> UsbBusAllocator<Usbd<UsbBus>> {
|
pub fn new() -> UsbBusAllocator<Usbd<UsbBus>> {
|
||||||
Usbd::new(UsbBus)
|
Usbd::new(UsbBus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl embassy_hal_common::usb::USBInterrupt for interrupt::USBD {}
|
unsafe impl embassy_hal_common::usb::USBInterrupt for crate::interrupt::USBD {}
|
||||||
|
}
|
||||||
|
|
||||||
pub mod interrupt {
|
pub mod interrupt {
|
||||||
pub use crate::chip::irqs::*;
|
pub use crate::chip::irqs::*;
|
||||||
|
@ -17,7 +17,7 @@ use embassy::executor::Spawner;
|
|||||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy_hal_common::usb::{State, Usb, UsbSerial};
|
use embassy_hal_common::usb::{State, Usb, UsbSerial};
|
||||||
use embassy_nrf::UsbBus;
|
use embassy_nrf::usb::UsbBus;
|
||||||
use embassy_nrf::{interrupt, Peripherals};
|
use embassy_nrf::{interrupt, Peripherals};
|
||||||
use usb_device::device::{UsbDeviceBuilder, UsbVidPid};
|
use usb_device::device::{UsbDeviceBuilder, UsbVidPid};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user