stm32_usbd/lib.rs
1//! USB peripheral driver for STM32 microcontrollers.
2//!
3//! This also serves as the reference implementation and example repository for the `usb-device`
4//! crate for now.
5
6#![no_std]
7
8pub mod bus;
9mod endpoint;
10mod endpoint_memory;
11mod registers;
12pub use crate::bus::UsbBus;
13pub use crate::endpoint_memory::MemoryAccess;
14
15mod pac;
16
17/// A trait for device-specific USB peripherals. Implement this to add support for a new hardware
18/// platform. Peripherals that have this trait must have the same register block as STM32 USBFS
19/// peripherals.
20pub unsafe trait UsbPeripheral: Send + Sync {
21 /// Pointer to the register block
22 const REGISTERS: *const ();
23
24 /// Embedded pull-up resistor on USB_DP line
25 const DP_PULL_UP_FEATURE: bool;
26
27 /// Pointer to the endpoint memory
28 const EP_MEMORY: *const ();
29
30 /// Endpoint memory size in bytes
31 const EP_MEMORY_SIZE: usize;
32
33 /// Endpoint memory access scheme
34 ///
35 /// See `MemoryAccess` enum for more details. Check Reference Manual to determine the correct access scheme to use.
36 const EP_MEMORY_ACCESS: MemoryAccess;
37
38 /// Enables USB device on its peripheral bus
39 fn enable();
40
41 /// Performs a chip specific startup delay
42 ///
43 /// This function is called in `UsbBus::enable()` after deasserting the `pdwn` bit and before
44 /// peripheral initialization.
45 fn startup_delay();
46}