Remove embassy_hal_common::usb.

The replacement is `embassy-usb`. There's a WIP driver for stm32 USBD in #709,
there's no WIP driver for stm32 USB_OTG. This means we're left without
USB_OTG support for now.

Reason for removing is I'm going to soon remove `embassy::io`, and
USB uses it. I don't want to spend time maintaining "dead" code
that is going to be removed. Volunteers welcome, either to update
old USB to the new IO, or write a USB_OTG driver fo the new USB.
This commit is contained in:
Dario Nieuwenhuis
2022-05-04 01:00:38 +02:00
parent 85c0525e01
commit fc32b3750c
14 changed files with 39 additions and 1342 deletions

View File

@ -53,7 +53,6 @@ futures = { version = "0.3.17", default-features = false, features = ["async-awa
rand_core = "0.6.3"
sdio-host = "0.5.0"
embedded-sdmmc = { git = "https://github.com/thalesfragoso/embedded-sdmmc-rs", branch = "async", optional = true }
synopsys-usb-otg = { version = "0.3", features = ["cortex-m", "hs"], optional = true }
critical-section = "0.2.5"
bare-metal = "1.0.0"
atomic-polyfill = "0.1.5"
@ -76,7 +75,6 @@ net = ["embassy-net", "vcell"]
memory-x = ["stm32-metapac/memory-x"]
subghz = []
exti = []
usb-otg = ["synopsys-usb-otg"]
# Features starting with `_` are for internal use only. They're not intended
# to be enabled by other crates, and are not covered by semver guarantees.

View File

@ -279,22 +279,22 @@ fn main() {
(("dcmi", "HSYNC"), (quote!(crate::dcmi::HSyncPin), quote!())),
(("dcmi", "VSYNC"), (quote!(crate::dcmi::VSyncPin), quote!())),
(("dcmi", "PIXCLK"), (quote!(crate::dcmi::PixClkPin), quote!())),
(("otgfs", "DP"), (quote!(crate::usb_otg::DpPin), quote!(#[cfg(feature="usb-otg")]))),
(("otgfs", "DM"), (quote!(crate::usb_otg::DmPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "DP"), (quote!(crate::usb_otg::DpPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "DM"), (quote!(crate::usb_otg::DmPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_CK"), (quote!(crate::usb_otg::UlpiClkPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_DIR"), (quote!(crate::usb_otg::UlpiDirPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_NXT"), (quote!(crate::usb_otg::UlpiNxtPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_STP"), (quote!(crate::usb_otg::UlpiStpPin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D0"), (quote!(crate::usb_otg::UlpiD0Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D1"), (quote!(crate::usb_otg::UlpiD1Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D2"), (quote!(crate::usb_otg::UlpiD2Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D3"), (quote!(crate::usb_otg::UlpiD3Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D4"), (quote!(crate::usb_otg::UlpiD4Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D5"), (quote!(crate::usb_otg::UlpiD5Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D6"), (quote!(crate::usb_otg::UlpiD6Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otghs", "ULPI_D7"), (quote!(crate::usb_otg::UlpiD7Pin), quote!(#[cfg(feature="usb-otg")]))),
(("otgfs", "DP"), (quote!(crate::usb_otg::DpPin), quote!())),
(("otgfs", "DM"), (quote!(crate::usb_otg::DmPin), quote!())),
(("otghs", "DP"), (quote!(crate::usb_otg::DpPin), quote!())),
(("otghs", "DM"), (quote!(crate::usb_otg::DmPin), quote!())),
(("otghs", "ULPI_CK"), (quote!(crate::usb_otg::UlpiClkPin), quote!())),
(("otghs", "ULPI_DIR"), (quote!(crate::usb_otg::UlpiDirPin), quote!())),
(("otghs", "ULPI_NXT"), (quote!(crate::usb_otg::UlpiNxtPin), quote!())),
(("otghs", "ULPI_STP"), (quote!(crate::usb_otg::UlpiStpPin), quote!())),
(("otghs", "ULPI_D0"), (quote!(crate::usb_otg::UlpiD0Pin), quote!())),
(("otghs", "ULPI_D1"), (quote!(crate::usb_otg::UlpiD1Pin), quote!())),
(("otghs", "ULPI_D2"), (quote!(crate::usb_otg::UlpiD2Pin), quote!())),
(("otghs", "ULPI_D3"), (quote!(crate::usb_otg::UlpiD3Pin), quote!())),
(("otghs", "ULPI_D4"), (quote!(crate::usb_otg::UlpiD4Pin), quote!())),
(("otghs", "ULPI_D5"), (quote!(crate::usb_otg::UlpiD5Pin), quote!())),
(("otghs", "ULPI_D6"), (quote!(crate::usb_otg::UlpiD6Pin), quote!())),
(("otghs", "ULPI_D7"), (quote!(crate::usb_otg::UlpiD7Pin), quote!())),
(("can", "TX"), (quote!(crate::can::TxPin), quote!())),
(("can", "RX"), (quote!(crate::can::RxPin), quote!())),
(("eth", "REF_CLK"), (quote!(crate::eth::RefClkPin), quote!(#[cfg(feature="net")]))),

View File

@ -61,7 +61,7 @@ pub mod sdmmc;
pub mod spi;
#[cfg(usart)]
pub mod usart;
#[cfg(feature = "usb-otg")]
#[cfg(any(otgfs, otghs))]
pub mod usb_otg;
#[cfg(feature = "subghz")]

View File

@ -1,15 +1,11 @@
use core::marker::PhantomData;
use embassy::util::Unborrow;
use embassy_hal_common::unborrow;
use synopsys_usb_otg::{PhyType, UsbPeripheral};
use crate::gpio::sealed::AFType;
use crate::gpio::Speed;
use crate::{peripherals, rcc::RccPeripheral};
pub use embassy_hal_common::usb::*;
pub use synopsys_usb_otg::UsbBus;
macro_rules! config_ulpi_pins {
($($pin:ident),*) => {
unborrow!($($pin),*);
@ -23,9 +19,24 @@ macro_rules! config_ulpi_pins {
};
}
/// USB PHY type
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PhyType {
/// Internal Full-Speed PHY
///
/// Available on most High-Speed peripherals.
InternalFullSpeed,
/// Internal High-Speed PHY
///
/// Available on a few STM32 chips.
InternalHighSpeed,
/// External ULPI High-Speed PHY
ExternalHighSpeed,
}
pub struct UsbOtg<'d, T: Instance> {
phantom: PhantomData<&'d mut T>,
phy_type: PhyType,
_phy_type: PhyType,
}
impl<'d, T: Instance> UsbOtg<'d, T> {
@ -44,7 +55,7 @@ impl<'d, T: Instance> UsbOtg<'d, T> {
Self {
phantom: PhantomData,
phy_type: PhyType::InternalFullSpeed,
_phy_type: PhyType::InternalFullSpeed,
}
}
@ -71,7 +82,7 @@ impl<'d, T: Instance> UsbOtg<'d, T> {
Self {
phantom: PhantomData,
phy_type: PhyType::ExternalHighSpeed,
_phy_type: PhyType::ExternalHighSpeed,
}
}
}
@ -83,29 +94,6 @@ impl<'d, T: Instance> Drop for UsbOtg<'d, T> {
}
}
unsafe impl<'d, T: Instance> Send for UsbOtg<'d, T> {}
unsafe impl<'d, T: Instance> Sync for UsbOtg<'d, T> {}
unsafe impl<'d, T: Instance> UsbPeripheral for UsbOtg<'d, T> {
const REGISTERS: *const () = T::REGISTERS;
const HIGH_SPEED: bool = T::HIGH_SPEED;
const FIFO_DEPTH_WORDS: usize = T::FIFO_DEPTH_WORDS;
const ENDPOINT_COUNT: usize = T::ENDPOINT_COUNT;
fn enable() {
<T as crate::rcc::sealed::RccPeripheral>::enable();
<T as crate::rcc::sealed::RccPeripheral>::reset();
}
fn phy_type(&self) -> PhyType {
self.phy_type
}
fn ahb_frequency_hz(&self) -> u32 {
<T as crate::rcc::sealed::RccPeripheral>::frequency().0
}
}
pub(crate) mod sealed {
pub trait Instance {
const REGISTERS: *const ();
@ -177,7 +165,7 @@ foreach_peripheral!(
const FIFO_DEPTH_WORDS: usize = 512;
const ENDPOINT_COUNT: usize = 8;
} else {
compile_error!("USB_OTG_FS peripheral is not supported by this chip. Disable \"usb-otg-fs\" feature or select a different chip.");
compile_error!("USB_OTG_FS peripheral is not supported by this chip.");
}
}
}
@ -214,7 +202,7 @@ foreach_peripheral!(
const FIFO_DEPTH_WORDS: usize = 1024;
const ENDPOINT_COUNT: usize = 9;
} else {
compile_error!("USB_OTG_HS peripheral is not supported by this chip. Disable \"usb-otg-hs\" feature or select a different chip.");
compile_error!("USB_OTG_HS peripheral is not supported by this chip.");
}
}
}
@ -222,12 +210,3 @@ foreach_peripheral!(
impl Instance for peripherals::$inst {}
};
);
foreach_interrupt!(
($inst:ident, otgfs, $block:ident, GLOBAL, $irq:ident) => {
unsafe impl USBInterrupt for crate::interrupt::$irq {}
};
($inst:ident, otghs, $block:ident, GLOBAL, $irq:ident) => {
unsafe impl USBInterrupt for crate::interrupt::$irq {}
};
);