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:
@ -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")]
|
||||
|
@ -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 {}
|
||||
};
|
||||
);
|
||||
|
Reference in New Issue
Block a user