Skip to content

Commit 84a73af

Browse files
committed
Tidy up USB support for STM32H735
1 parent 1c3cb85 commit 84a73af

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

examples/usb_serial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() -> ! {
3535
ccdr.peripheral.kernel_usb_clk_mux(UsbClkSel::HSI48);
3636

3737
// IO
38-
#[cfg(not(feature = "rm0455"))]
38+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
3939
let (pin_dm, pin_dp) = {
4040
let gpiob = dp.GPIOB.split(ccdr.peripheral.GPIOB);
4141
(
@@ -44,7 +44,7 @@ fn main() -> ! {
4444
)
4545
};
4646

47-
#[cfg(feature = "rm0455")]
47+
#[cfg(any(feature = "rm0455", feature = "rm0468"))]
4848
let (pin_dm, pin_dp) = {
4949
let gpioa = dp.GPIOA.split(ccdr.peripheral.GPIOA);
5050
(

src/rcc/rec.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ peripheral_reset_and_enable_control! {
482482
AHB1, "" => [
483483
Eth1Mac,
484484
#[cfg(any(feature = "rm0399"))] Art,
485-
Adc12 [group clk: Adc(Variant) d3ccip "ADC"]
485+
Adc12 [group clk: Adc(Variant) d3ccip "ADC"],
486+
Usb1Otg [group clk: Usb d2ccip2 "USB"]
486487
];
487488
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
488489
AHB1, "" => [
489-
Usb1Otg [group clk: Usb d2ccip2 "USB"],
490490
Usb2Otg [group clk: Usb]
491491
];
492492
#[cfg(feature = "rm0455")]
@@ -495,10 +495,6 @@ peripheral_reset_and_enable_control! {
495495
Usb1Otg [group clk: Usb cdccip2 "USB"],
496496
Adc12 [group clk: Adc(Variant) srdccip "ADC"]
497497
];
498-
#[cfg(feature = "rm0468")]
499-
AHB1, "" => [
500-
Usb1Otg [kernel clk: Usb d2ccip2 "USB"]
501-
];
502498

503499

504500
#[cfg(all())]

src/usb_hs.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ use crate::gpio::{
1515
gpiob::{PB0, PB1, PB10, PB11, PB12, PB13, PB5},
1616
gpioc::{PC0, PC2, PC3},
1717
gpioh::PH4,
18-
gpioi::PI11,
1918
Alternate, AF10,
2019
};
2120

22-
#[cfg(not(feature = "rm0455"))]
21+
#[cfg(not(feature = "rm0468"))]
22+
use crate::gpio::gpioi::PI11;
23+
24+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
2325
use crate::gpio::{
2426
gpiob::{PB14, PB15},
2527
AF12,
@@ -38,7 +40,7 @@ pub struct USB1 {
3840
pub hclk: Hertz,
3941
}
4042
impl USB1 {
41-
#[cfg(not(feature = "rm0455"))]
43+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
4244
pub fn new(
4345
usb_global: stm32::OTG1_HS_GLOBAL,
4446
usb_device: stm32::OTG1_HS_DEVICE,
@@ -50,7 +52,7 @@ impl USB1 {
5052
) -> Self {
5153
Self::new_unchecked(usb_global, usb_device, usb_pwrclk, prec, clocks)
5254
}
53-
#[cfg(feature = "rm0455")]
55+
#[cfg(any(feature = "rm0455", feature = "rm0468"))]
5456
pub fn new(
5557
usb_global: stm32::OTG1_HS_GLOBAL,
5658
usb_device: stm32::OTG1_HS_DEVICE,
@@ -79,15 +81,15 @@ impl USB1 {
7981
}
8082
}
8183

82-
#[cfg(not(feature = "rm0455"))]
84+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
8385
pub struct USB2 {
8486
pub usb_global: stm32::OTG2_HS_GLOBAL,
8587
pub usb_device: stm32::OTG2_HS_DEVICE,
8688
pub usb_pwrclk: stm32::OTG2_HS_PWRCLK,
8789
pub prec: rcc::rec::Usb2Otg,
8890
pub hclk: Hertz,
8991
}
90-
#[cfg(not(feature = "rm0455"))]
92+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
9193
impl USB2 {
9294
pub fn new(
9395
usb_global: stm32::OTG2_HS_GLOBAL,
@@ -161,11 +163,11 @@ usb_peripheral! {
161163
}
162164
pub type Usb1BusType = UsbBus<USB1>;
163165

164-
#[cfg(not(feature = "rm0455"))]
166+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
165167
usb_peripheral! {
166168
USB2, OTG2_HS_GLOBAL, usb2otgen, usb2otgrst
167169
}
168-
#[cfg(not(feature = "rm0455"))]
170+
#[cfg(any(feature = "rm0433", feature = "rm0399"))]
169171
pub type Usb2BusType = UsbBus<USB2>;
170172

171173
pub struct USB1_ULPI {
@@ -178,9 +180,11 @@ pub struct USB1_ULPI {
178180

179181
pub enum Usb1UlpiDirPin {
180182
PC2(PC2<Alternate<AF10>>),
183+
#[cfg(not(feature = "rm0468"))]
181184
PI11(PI11<Alternate<AF10>>),
182185
}
183186

187+
#[cfg(not(feature = "rm0468"))]
184188
impl From<PI11<Alternate<AF10>>> for Usb1UlpiDirPin {
185189
fn from(v: PI11<Alternate<AF10>>) -> Self {
186190
Usb1UlpiDirPin::PI11(v)

0 commit comments

Comments
 (0)