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;
13
14mod pac;
15
16/// A trait for device-specific USB peripherals. Implement this to add support for a new hardware
17/// platform. Peripherals that have this trait must have the same register block as STM32 USBFS
18/// peripherals.
19pub unsafe trait UsbPeripheral: Send + Sync {
20    /// Pointer to the register block
21    const REGISTERS: *const ();
22
23    /// Embedded pull-up resistor on USB_DP line
24    const DP_PULL_UP_FEATURE: bool;
25
26    /// Pointer to the endpoint memory
27    const EP_MEMORY: *const ();
28
29    /// Endpoint memory size in bytes
30    const EP_MEMORY_SIZE: usize;
31
32    /// Endpoint memory access scheme
33    ///
34    /// Check Reference Manual for details.
35    /// Set to `true` if "2x16 bits/word" access scheme is used, otherwise set to `false`.
36    const EP_MEMORY_ACCESS_2X16: bool;
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}