1use crate::pac::USB;
8use crate::rcc::{Enable, Reset};
9use stm32_usbd::{MemoryAccess, UsbPeripheral};
10
11use crate::gpio::gpioa::{PA11, PA12};
12use crate::gpio::{Floating, Input};
13pub use stm32_usbd::UsbBus;
14
15pub struct Peripheral {
16 pub usb: USB,
17 pub pin_dm: PA11<Input<Floating>>,
18 pub pin_dp: PA12<Input<Floating>>,
19}
20
21unsafe impl Sync for Peripheral {}
22
23unsafe impl UsbPeripheral for Peripheral {
24 const REGISTERS: *const () = USB::ptr() as *const ();
25 const DP_PULL_UP_FEATURE: bool = false;
26 const EP_MEMORY: *const () = 0x4000_6000 as _;
27 const EP_MEMORY_SIZE: usize = 512;
28 const EP_MEMORY_ACCESS: MemoryAccess = MemoryAccess::Word16x1;
29
30 fn enable() {
31 unsafe {
32 USB::enable_unchecked();
34 USB::reset_unchecked();
36 }
37 }
38
39 fn startup_delay() {
40 cortex_m::asm::delay(72);
43 }
44}
45
46pub type UsbBusType = UsbBus<Peripheral>;