Skip to content

Commit be85012

Browse files
committed
usb
1 parent 07c5683 commit be85012

File tree

6 files changed

+40
-12
lines changed

6 files changed

+40
-12
lines changed

examples/rtic-usb-cdc-echo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ mod app {
6060
usb_global: dp.OTG_FS_GLOBAL,
6161
usb_device: dp.OTG_FS_DEVICE,
6262
usb_pwrclk: dp.OTG_FS_PWRCLK,
63-
pin_dm: gpioa.pa11.into_alternate(),
64-
pin_dp: gpioa.pa12.into_alternate(),
63+
pin_dm: gpioa.pa11.into(),
64+
pin_dp: gpioa.pa12.into(),
6565
hclk: clocks.hclk(),
6666
};
6767
unsafe {

examples/usb-serial-irq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ fn main() -> ! {
4040
usb_global: dp.OTG_FS_GLOBAL,
4141
usb_device: dp.OTG_FS_DEVICE,
4242
usb_pwrclk: dp.OTG_FS_PWRCLK,
43-
pin_dm: gpioa.pa11.into_alternate(),
44-
pin_dp: gpioa.pa12.into_alternate(),
43+
pin_dm: gpioa.pa11.into(),
44+
pin_dp: gpioa.pa12.into(),
4545
hclk: clocks.hclk(),
4646
};
4747

examples/usb-serial-poll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ fn main() -> ! {
3131
usb_global: dp.OTG_FS_GLOBAL,
3232
usb_device: dp.OTG_FS_DEVICE,
3333
usb_pwrclk: dp.OTG_FS_PWRCLK,
34-
pin_dm: gpioa.pa11.into_alternate(),
35-
pin_dp: gpioa.pa12.into_alternate(),
34+
pin_dm: gpioa.pa11.into(),
35+
pin_dp: gpioa.pa12.into(),
3636
hclk: clocks.hclk(),
3737
};
3838

src/gpio/alt.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,3 +2223,31 @@ pub mod fsmc {
22232223
// Because external addresses are in units of 16 bits, external address line 25 can never
22242224
// be high. The internal memory address would overflow into the next sub-bank.
22252225
}
2226+
2227+
#[cfg(feature = "otg-fs")]
2228+
pub mod otg_fs {
2229+
use super::*;
2230+
2231+
pin! {
2232+
<Dm> for [
2233+
PA11<10>,
2234+
],
2235+
<Dp> for [
2236+
PA12<10>,
2237+
],
2238+
}
2239+
}
2240+
2241+
#[cfg(feature = "otg-hs")]
2242+
pub mod otg_hs {
2243+
use super::*;
2244+
2245+
pin! {
2246+
<Dm> for [
2247+
PB14<12>,
2248+
],
2249+
<Dp> for [
2250+
PB15<12>,
2251+
],
2252+
}
2253+
}

src/otg_fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
use crate::pac;
77

8-
use crate::gpio::{Alternate, PushPull, PA11, PA12};
8+
use crate::gpio::alt::otg_fs as alt;
99
use crate::rcc::{Enable, Reset};
1010
use fugit::HertzU32 as Hertz;
1111

@@ -16,8 +16,8 @@ pub struct USB {
1616
pub usb_global: pac::OTG_FS_GLOBAL,
1717
pub usb_device: pac::OTG_FS_DEVICE,
1818
pub usb_pwrclk: pac::OTG_FS_PWRCLK,
19-
pub pin_dm: PA11<Alternate<10, PushPull>>,
20-
pub pin_dp: PA12<Alternate<10, PushPull>>,
19+
pub pin_dm: alt::Dm,
20+
pub pin_dp: alt::Dp,
2121
pub hclk: Hertz,
2222
}
2323

src/otg_hs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
use crate::pac;
1010

11-
use crate::gpio::{Alternate, PushPull, PB14, PB15};
11+
use crate::gpio::alt::otg_hs as alt;
1212
use crate::rcc::{Enable, Reset};
1313
use fugit::HertzU32 as Hertz;
1414

@@ -19,8 +19,8 @@ pub struct USB {
1919
pub usb_global: pac::OTG_HS_GLOBAL,
2020
pub usb_device: pac::OTG_HS_DEVICE,
2121
pub usb_pwrclk: pac::OTG_HS_PWRCLK,
22-
pub pin_dm: PB14<Alternate<12, PushPull>>,
23-
pub pin_dp: PB15<Alternate<12, PushPull>>,
22+
pub pin_dm: alt::Dm,
23+
pub pin_dp: alt::Dp,
2424
pub hclk: Hertz,
2525
}
2626

0 commit comments

Comments
 (0)