1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::rcc::{Enable, Reset};
use crate::stm32::USB;
use stm32_usbd::UsbPeripheral;
use crate::gpio::gpioa::{PA11, PA12};
use crate::gpio::{Alternate, PushPull};
pub use stm32_usbd::UsbBus;
pub struct Peripheral {
pub usb: USB,
pub pin_dm: PA11<Alternate<PushPull, 10>>,
pub pin_dp: PA12<Alternate<PushPull, 10>>,
}
unsafe impl Sync for Peripheral {}
unsafe impl UsbPeripheral for Peripheral {
const REGISTERS: *const () = USB::ptr() as *const ();
const DP_PULL_UP_FEATURE: bool = true;
const EP_MEMORY: *const () = 0x4000_6c00 as _;
const EP_MEMORY_SIZE: usize = 1024;
const EP_MEMORY_ACCESS_2X16: bool = true;
fn enable() {
cortex_m::interrupt::free(|_| unsafe {
USB::enable_unchecked();
USB::reset_unchecked();
});
}
fn startup_delay() {
cortex_m::asm::delay(72);
}
}
pub type UsbBusType = UsbBus<Peripheral>;