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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::{
pac::{self, RCC},
rcc::HSI48,
};
use stm32_usbd::UsbPeripheral;
use crate::gpio::gpioa::{PA11, PA12};
use crate::gpio::Analog;
pub use stm32_usbd::UsbBus;
pub struct USB(());
impl USB {
pub fn new(
_: pac::USB,
_dm: PA11<Analog>,
_dp: PA12<Analog>,
_: HSI48
)
-> Self
{
Self(())
}
}
unsafe impl Sync for USB {}
unsafe impl UsbPeripheral for USB {
const REGISTERS: *const () = pac::USB::ptr() as *const ();
const DP_PULL_UP_FEATURE: bool = true;
const EP_MEMORY: *const () = 0x4000_6000 as _;
const EP_MEMORY_SIZE: usize = 1024;
fn enable() {
let rcc = unsafe { &*RCC::ptr() };
cortex_m::interrupt::free(|_| {
rcc.apb1enr.modify(|_, w| w.usben().set_bit());
rcc.apb1rstr.modify(|_, w| w.usbrst().set_bit());
rcc.apb1rstr.modify(|_, w| w.usbrst().clear_bit());
});
}
fn startup_delay() {
cortex_m::asm::delay(32);
}
}
pub type UsbBusType = UsbBus<USB>;