mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 14:44:42 +00:00
Remove unnecessary pin required by USB peripheral (#990)
* Remove unnecessary pin required by USB peripheral * CHANGELOG.md
This commit is contained in:
parent
17884743bd
commit
f1e1ec574f
@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- The `embedded-io` trait implementations are now gated behind the `embedded-io` feature (#964)
|
||||
- Simplifed RMT channels and channel creators (#958)
|
||||
- Reworked construction of I2S driver instances (#983)
|
||||
- S2 / S3: Don't require GPIO 18 to create a USB peripheral driver instance (#990)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -36,63 +36,53 @@ use crate::{
|
||||
system::{Peripheral as PeripheralEnable, PeripheralClockControl},
|
||||
};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait UsbSel {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait UsbDp {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait UsbDm {}
|
||||
|
||||
pub struct USB<'d, S, P, M>
|
||||
pub struct USB<'d, P, M>
|
||||
where
|
||||
S: UsbSel + Send + Sync,
|
||||
P: UsbDp + Send + Sync,
|
||||
M: UsbDm + Send + Sync,
|
||||
{
|
||||
_usb0: PeripheralRef<'d, peripherals::USB0>,
|
||||
_usb_sel: PeripheralRef<'d, S>,
|
||||
_usb_dp: PeripheralRef<'d, P>,
|
||||
_usb_dm: PeripheralRef<'d, M>,
|
||||
}
|
||||
|
||||
impl<'d, S, P, M> USB<'d, S, P, M>
|
||||
impl<'d, P, M> USB<'d, P, M>
|
||||
where
|
||||
S: UsbSel + Send + Sync,
|
||||
P: UsbDp + Send + Sync,
|
||||
M: UsbDm + Send + Sync,
|
||||
{
|
||||
pub fn new(
|
||||
usb0: impl Peripheral<P = peripherals::USB0> + 'd,
|
||||
usb_sel: impl Peripheral<P = S> + 'd,
|
||||
usb_dp: impl Peripheral<P = P> + 'd,
|
||||
usb_dm: impl Peripheral<P = M> + 'd,
|
||||
) -> Self {
|
||||
crate::into_ref!(usb_sel, usb_dp, usb_dm);
|
||||
crate::into_ref!(usb_dp, usb_dm);
|
||||
|
||||
PeripheralClockControl::enable(PeripheralEnable::Usb);
|
||||
|
||||
Self {
|
||||
_usb0: usb0.into_ref(),
|
||||
_usb_sel: usb_sel,
|
||||
_usb_dp: usb_dp,
|
||||
_usb_dm: usb_dm,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'d, S, P, M> Sync for USB<'d, S, P, M>
|
||||
unsafe impl<'d, P, M> Sync for USB<'d, P, M>
|
||||
where
|
||||
S: UsbSel + Send + Sync,
|
||||
P: UsbDp + Send + Sync,
|
||||
M: UsbDm + Send + Sync,
|
||||
{
|
||||
}
|
||||
|
||||
unsafe impl<'d, S, P, M> UsbPeripheral for USB<'d, S, P, M>
|
||||
unsafe impl<'d, P, M> UsbPeripheral for USB<'d, P, M>
|
||||
where
|
||||
S: UsbSel + Send + Sync,
|
||||
P: UsbDp + Send + Sync,
|
||||
M: UsbDm + Send + Sync,
|
||||
{
|
||||
|
@ -429,6 +429,5 @@ impl InterruptStatusRegisterAccess for InterruptStatusRegisterAccessBank1 {
|
||||
}
|
||||
|
||||
// implement marker traits on USB pins
|
||||
impl<T> crate::otg_fs::UsbSel for Gpio18<T> {}
|
||||
impl<T> crate::otg_fs::UsbDp for Gpio19<T> {}
|
||||
impl<T> crate::otg_fs::UsbDm for Gpio20<T> {}
|
||||
|
@ -439,6 +439,5 @@ impl InterruptStatusRegisterAccess for InterruptStatusRegisterAccessBank1 {
|
||||
}
|
||||
|
||||
// implement marker traits on USB pins
|
||||
impl<T> crate::otg_fs::UsbSel for Gpio18<T> {}
|
||||
impl<T> crate::otg_fs::UsbDp for Gpio19<T> {}
|
||||
impl<T> crate::otg_fs::UsbDm for Gpio20<T> {}
|
||||
|
@ -25,12 +25,7 @@ fn main() -> ! {
|
||||
|
||||
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
|
||||
|
||||
let usb = USB::new(
|
||||
peripherals.USB0,
|
||||
io.pins.gpio18,
|
||||
io.pins.gpio19,
|
||||
io.pins.gpio20,
|
||||
);
|
||||
let usb = USB::new(peripherals.USB0, io.pins.gpio19, io.pins.gpio20);
|
||||
|
||||
let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });
|
||||
|
||||
|
@ -25,12 +25,7 @@ fn main() -> ! {
|
||||
|
||||
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
|
||||
|
||||
let usb = USB::new(
|
||||
peripherals.USB0,
|
||||
io.pins.gpio18,
|
||||
io.pins.gpio19,
|
||||
io.pins.gpio20,
|
||||
);
|
||||
let usb = USB::new(peripherals.USB0, io.pins.gpio19, io.pins.gpio20);
|
||||
|
||||
let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user