diff options
| author | Jacob Rosenthal <[email protected]> | 2021-12-12 21:32:51 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-12-12 21:39:59 -0700 |
| commit | e5dc63e8e99d1d818ed7ab3b13ffff3ee2c40a3d (patch) | |
| tree | 001cd24b366eab9d88d658d198dfdf3583db0263 /embassy-nrf/src | |
| parent | f430c0e8c2e9703220978d9976b058ecf0117c45 (diff) | |
usb feature gate
Diffstat (limited to 'embassy-nrf/src')
| -rw-r--r-- | embassy-nrf/src/lib.rs | 26 |
1 files changed, 15 insertions, 11 deletions
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; | |||
| 73 | 73 | ||
| 74 | pub use chip::{peripherals, Peripherals}; | 74 | pub use chip::{peripherals, Peripherals}; |
| 75 | 75 | ||
| 76 | use nrf_usbd::{UsbPeripheral, Usbd}; | 76 | #[cfg(any(feature = "nrf52820", feature = "nrf52833", feature = "nrf52840"))] |
| 77 | use usb_device::bus::UsbBusAllocator; | 77 | pub mod usb { |
| 78 | 78 | ||
| 79 | pub struct UsbBus; | 79 | use nrf_usbd::{UsbPeripheral, Usbd}; |
| 80 | unsafe impl UsbPeripheral for UsbBus { | 80 | use usb_device::bus::UsbBusAllocator; |
| 81 | const REGISTERS: *const () = pac::USBD::ptr() as *const (); | ||
| 82 | } | ||
| 83 | 81 | ||
| 84 | impl UsbBus { | 82 | pub struct UsbBus; |
| 85 | pub fn new() -> UsbBusAllocator<Usbd<UsbBus>> { | 83 | unsafe impl UsbPeripheral for UsbBus { |
| 86 | Usbd::new(UsbBus) | 84 | const REGISTERS: *const () = crate::pac::USBD::ptr() as *const (); |
| 85 | } | ||
| 86 | |||
| 87 | impl UsbBus { | ||
| 88 | pub fn new() -> UsbBusAllocator<Usbd<UsbBus>> { | ||
| 89 | Usbd::new(UsbBus) | ||
| 90 | } | ||
| 87 | } | 91 | } |
| 88 | } | ||
| 89 | 92 | ||
| 90 | unsafe impl embassy_hal_common::usb::USBInterrupt for interrupt::USBD {} | 93 | unsafe impl embassy_hal_common::usb::USBInterrupt for crate::interrupt::USBD {} |
| 94 | } | ||
| 91 | 95 | ||
| 92 | pub mod interrupt { | 96 | pub mod interrupt { |
| 93 | pub use crate::chip::irqs::*; | 97 | pub use crate::chip::irqs::*; |
