1use crate::pac::{RCC, USB};
8use crate::rcc::{Enable, Reset};
9use stm32_usbd::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_2X16: bool = false;
29
30 fn enable() {
31 unsafe {
32 let rcc = &*RCC::ptr();
33
34 USB::enable(rcc);
36 USB::reset(rcc);
38 }
39 }
40
41 fn startup_delay() {
42 cortex_m::asm::delay(72);
45 }
46}
47
48pub type UsbBusType = UsbBus<Peripheral>;