Remove unnecessary pin required by USB peripheral (#990)

* Remove unnecessary pin required by USB peripheral

* CHANGELOG.md
This commit is contained in:
Björn Quentin 2023-12-01 14:24:38 +01:00 committed by GitHub
parent 17884743bd
commit f1e1ec574f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 29 deletions

View File

@ -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) - The `embedded-io` trait implementations are now gated behind the `embedded-io` feature (#964)
- Simplifed RMT channels and channel creators (#958) - Simplifed RMT channels and channel creators (#958)
- Reworked construction of I2S driver instances (#983) - Reworked construction of I2S driver instances (#983)
- S2 / S3: Don't require GPIO 18 to create a USB peripheral driver instance (#990)
### Fixed ### Fixed

View File

@ -36,63 +36,53 @@ use crate::{
system::{Peripheral as PeripheralEnable, PeripheralClockControl}, system::{Peripheral as PeripheralEnable, PeripheralClockControl},
}; };
#[doc(hidden)]
pub trait UsbSel {}
#[doc(hidden)] #[doc(hidden)]
pub trait UsbDp {} pub trait UsbDp {}
#[doc(hidden)] #[doc(hidden)]
pub trait UsbDm {} pub trait UsbDm {}
pub struct USB<'d, S, P, M> pub struct USB<'d, P, M>
where where
S: UsbSel + Send + Sync,
P: UsbDp + Send + Sync, P: UsbDp + Send + Sync,
M: UsbDm + Send + Sync, M: UsbDm + Send + Sync,
{ {
_usb0: PeripheralRef<'d, peripherals::USB0>, _usb0: PeripheralRef<'d, peripherals::USB0>,
_usb_sel: PeripheralRef<'d, S>,
_usb_dp: PeripheralRef<'d, P>, _usb_dp: PeripheralRef<'d, P>,
_usb_dm: PeripheralRef<'d, M>, _usb_dm: PeripheralRef<'d, M>,
} }
impl<'d, S, P, M> USB<'d, S, P, M> impl<'d, P, M> USB<'d, P, M>
where where
S: UsbSel + Send + Sync,
P: UsbDp + Send + Sync, P: UsbDp + Send + Sync,
M: UsbDm + Send + Sync, M: UsbDm + Send + Sync,
{ {
pub fn new( pub fn new(
usb0: impl Peripheral<P = peripherals::USB0> + 'd, usb0: impl Peripheral<P = peripherals::USB0> + 'd,
usb_sel: impl Peripheral<P = S> + 'd,
usb_dp: impl Peripheral<P = P> + 'd, usb_dp: impl Peripheral<P = P> + 'd,
usb_dm: impl Peripheral<P = M> + 'd, usb_dm: impl Peripheral<P = M> + 'd,
) -> Self { ) -> Self {
crate::into_ref!(usb_sel, usb_dp, usb_dm); crate::into_ref!(usb_dp, usb_dm);
PeripheralClockControl::enable(PeripheralEnable::Usb); PeripheralClockControl::enable(PeripheralEnable::Usb);
Self { Self {
_usb0: usb0.into_ref(), _usb0: usb0.into_ref(),
_usb_sel: usb_sel,
_usb_dp: usb_dp, _usb_dp: usb_dp,
_usb_dm: usb_dm, _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 where
S: UsbSel + Send + Sync,
P: UsbDp + Send + Sync, P: UsbDp + Send + Sync,
M: UsbDm + 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 where
S: UsbSel + Send + Sync,
P: UsbDp + Send + Sync, P: UsbDp + Send + Sync,
M: UsbDm + Send + Sync, M: UsbDm + Send + Sync,
{ {

View File

@ -429,6 +429,5 @@ impl InterruptStatusRegisterAccess for InterruptStatusRegisterAccessBank1 {
} }
// implement marker traits on USB pins // 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::UsbDp for Gpio19<T> {}
impl<T> crate::otg_fs::UsbDm for Gpio20<T> {} impl<T> crate::otg_fs::UsbDm for Gpio20<T> {}

View File

@ -439,6 +439,5 @@ impl InterruptStatusRegisterAccess for InterruptStatusRegisterAccessBank1 {
} }
// implement marker traits on USB pins // 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::UsbDp for Gpio19<T> {}
impl<T> crate::otg_fs::UsbDm for Gpio20<T> {} impl<T> crate::otg_fs::UsbDm for Gpio20<T> {}

View File

@ -25,12 +25,7 @@ fn main() -> ! {
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let usb = USB::new( let usb = USB::new(peripherals.USB0, io.pins.gpio19, io.pins.gpio20);
peripherals.USB0,
io.pins.gpio18,
io.pins.gpio19,
io.pins.gpio20,
);
let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY }); let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });

View File

@ -25,12 +25,7 @@ fn main() -> ! {
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let usb = USB::new( let usb = USB::new(peripherals.USB0, io.pins.gpio19, io.pins.gpio20);
peripherals.USB0,
io.pins.gpio18,
io.pins.gpio19,
io.pins.gpio20,
);
let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY }); let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });