stm32: add USB driver.
This commit is contained in:
@ -37,6 +37,7 @@ embassy = { version = "0.1.0", path = "../embassy" }
|
||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["stm32"] }
|
||||
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
|
||||
embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true }
|
||||
embassy-usb = {version = "0.1.0", path = "../embassy-usb", optional = true }
|
||||
|
||||
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
|
||||
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true}
|
||||
@ -71,7 +72,7 @@ quote = "1.0.15"
|
||||
stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", default-features = false, features = ["metadata"]}
|
||||
|
||||
[features]
|
||||
defmt = ["dep:defmt", "embassy/defmt", "embedded-io?/defmt" ]
|
||||
defmt = ["dep:defmt", "embassy/defmt", "embedded-io?/defmt", "embassy-usb?/defmt"]
|
||||
sdmmc-rs = ["embedded-sdmmc"]
|
||||
net = ["embassy-net" ]
|
||||
memory-x = ["stm32-metapac/memory-x"]
|
||||
@ -90,7 +91,7 @@ time-driver-tim12 = ["_time-driver"]
|
||||
time-driver-tim15 = ["_time-driver"]
|
||||
|
||||
# Enable nightly-only features
|
||||
nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io"]
|
||||
nightly = ["embassy/nightly", "embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io", "dep:embassy-usb"]
|
||||
|
||||
# Reexport stm32-metapac at `embassy_stm32::pac`.
|
||||
# This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version.
|
||||
|
@ -279,6 +279,8 @@ fn main() {
|
||||
(("dcmi", "HSYNC"), quote!(crate::dcmi::HSyncPin)),
|
||||
(("dcmi", "VSYNC"), quote!(crate::dcmi::VSyncPin)),
|
||||
(("dcmi", "PIXCLK"), quote!(crate::dcmi::PixClkPin)),
|
||||
(("usb", "DP"), quote!(crate::usb::DpPin)),
|
||||
(("usb", "DM"), quote!(crate::usb::DmPin)),
|
||||
(("otgfs", "DP"), quote!(crate::usb_otg::DpPin)),
|
||||
(("otgfs", "DM"), quote!(crate::usb_otg::DmPin)),
|
||||
(("otghs", "DP"), quote!(crate::usb_otg::DpPin)),
|
||||
|
@ -63,6 +63,8 @@ pub mod sdmmc;
|
||||
pub mod spi;
|
||||
#[cfg(usart)]
|
||||
pub mod usart;
|
||||
#[cfg(usb)]
|
||||
pub mod usb;
|
||||
#[cfg(any(otgfs, otghs))]
|
||||
pub mod usb_otg;
|
||||
|
||||
|
36
embassy-stm32/src/usb/mod.rs
Normal file
36
embassy-stm32/src/usb/mod.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use embassy::interrupt::Interrupt;
|
||||
|
||||
use crate::rcc::RccPeripheral;
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
mod usb;
|
||||
#[cfg(feature = "nightly")]
|
||||
pub use usb::*;
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Instance {
|
||||
fn regs() -> crate::pac::usb::Usb;
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Instance: sealed::Instance + RccPeripheral + 'static {
|
||||
type Interrupt: Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
pin_trait!(DpPin, Instance);
|
||||
pin_trait!(DmPin, Instance);
|
||||
|
||||
foreach_interrupt!(
|
||||
($inst:ident, usb, $block:ident, LP, $irq:ident) => {
|
||||
impl sealed::Instance for crate::peripherals::$inst {
|
||||
fn regs() -> crate::pac::usb::Usb {
|
||||
crate::pac::$inst
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::$irq;
|
||||
}
|
||||
};
|
||||
);
|
1064
embassy-stm32/src/usb/usb.rs
Normal file
1064
embassy-stm32/src/usb/usb.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user