Skip to content

Commit a327cb9

Browse files
bors[bot]Disasm
andauthored
Merge #178
178: Update synopsys-usb-otg dependency to v0.2.0 r=therealprof a=Disasm Co-authored-by: Vadim Kaushan <[email protected]>
2 parents 7db793f + 802a42d commit a327cb9

File tree

6 files changed

+64
-2
lines changed

6 files changed

+64
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- [breaking-change] Updated synopsys-usb-otg dependency to v0.2.0.
13+
1014
### Added
1115

1216
- Reexport PAC as `pac` for consistency with other crates, consider `stm32` virtually deprecated

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cortex-m-rt = "0.6.10"
3131
nb = "0.1.2"
3232
rand_core = "0.5.1"
3333
stm32f4 = "0.11"
34-
synopsys-usb-otg = { version = "0.1.0", features = ["cortex-m"], optional = true }
34+
synopsys-usb-otg = { version = "0.2.0", features = ["cortex-m"], optional = true }
3535

3636
[dependencies.bare-metal]
3737
version = "0.2.5"

examples/usb_serial.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ fn main() -> ! {
1818

1919
let rcc = dp.RCC.constrain();
2020

21-
rcc.cfgr
21+
let clocks = rcc
22+
.cfgr
2223
.use_hse(25.mhz())
2324
.sysclk(48.mhz())
2425
.require_pll48clk()
@@ -32,6 +33,7 @@ fn main() -> ! {
3233
usb_pwrclk: dp.OTG_FS_PWRCLK,
3334
pin_dm: gpioa.pa11.into_alternate_af10(),
3435
pin_dp: gpioa.pa12.into_alternate_af10(),
36+
hclk: clocks.hclk(),
3537
};
3638

3739
let usb_bus = UsbBus::new(usb, unsafe { &mut EP_MEMORY });

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,18 @@ pub mod i2c;
100100
feature = "stm32f405",
101101
feature = "stm32f407",
102102
feature = "stm32f411",
103+
feature = "stm32f412",
104+
feature = "stm32f413",
103105
feature = "stm32f415",
104106
feature = "stm32f417",
107+
feature = "stm32f423",
105108
feature = "stm32f427",
106109
feature = "stm32f429",
107110
feature = "stm32f437",
108111
feature = "stm32f439",
109112
feature = "stm32f446",
113+
feature = "stm32f469",
114+
feature = "stm32f479",
110115
)
111116
))]
112117
pub mod otg_fs;
@@ -122,6 +127,8 @@ pub mod otg_fs;
122127
feature = "stm32f437",
123128
feature = "stm32f439",
124129
feature = "stm32f446",
130+
feature = "stm32f469",
131+
feature = "stm32f479",
125132
)
126133
))]
127134
pub mod otg_hs;

src/otg_fs.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::gpio::{
99
gpioa::{PA11, PA12},
1010
Alternate, AF10,
1111
};
12+
use crate::time::Hertz;
1213

1314
pub use synopsys_usb_otg::UsbBus;
1415
use synopsys_usb_otg::UsbPeripheral;
@@ -19,6 +20,7 @@ pub struct USB {
1920
pub usb_pwrclk: stm32::OTG_FS_PWRCLK,
2021
pub pin_dm: PA11<Alternate<AF10>>,
2122
pub pin_dp: PA12<Alternate<AF10>>,
23+
pub hclk: Hertz,
2224
}
2325

2426
unsafe impl Sync for USB {}
@@ -29,6 +31,29 @@ unsafe impl UsbPeripheral for USB {
2931
const HIGH_SPEED: bool = false;
3032
const FIFO_DEPTH_WORDS: usize = 320;
3133

34+
#[cfg(any(
35+
feature = "stm32f401",
36+
feature = "stm32f405",
37+
feature = "stm32f407",
38+
feature = "stm32f411",
39+
feature = "stm32f415",
40+
feature = "stm32f417",
41+
feature = "stm32f427",
42+
feature = "stm32f429",
43+
feature = "stm32f437",
44+
feature = "stm32f439",
45+
))]
46+
const ENDPOINT_COUNT: usize = 4;
47+
#[cfg(any(
48+
feature = "stm32f412",
49+
feature = "stm32f413",
50+
feature = "stm32f423",
51+
feature = "stm32f446",
52+
feature = "stm32f469",
53+
feature = "stm32f479",
54+
))]
55+
const ENDPOINT_COUNT: usize = 6;
56+
3257
fn enable() {
3358
let rcc = unsafe { &*stm32::RCC::ptr() };
3459

@@ -41,6 +66,10 @@ unsafe impl UsbPeripheral for USB {
4166
rcc.ahb2rstr.modify(|_, w| w.otgfsrst().clear_bit());
4267
});
4368
}
69+
70+
fn ahb_frequency_hz(&self) -> u32 {
71+
self.hclk.0
72+
}
4473
}
4574

4675
pub type UsbBusType = UsbBus<USB>;

src/otg_hs.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::gpio::{
1212
gpiob::{PB14, PB15},
1313
Alternate, AF12,
1414
};
15+
use crate::time::Hertz;
1516

1617
pub use synopsys_usb_otg::UsbBus;
1718
use synopsys_usb_otg::UsbPeripheral;
@@ -22,6 +23,7 @@ pub struct USB {
2223
pub usb_pwrclk: stm32::OTG_HS_PWRCLK,
2324
pub pin_dm: PB14<Alternate<AF12>>,
2425
pub pin_dp: PB15<Alternate<AF12>>,
26+
pub hclk: Hertz,
2527
}
2628

2729
unsafe impl Sync for USB {}
@@ -32,6 +34,20 @@ unsafe impl UsbPeripheral for USB {
3234
const HIGH_SPEED: bool = true;
3335
const FIFO_DEPTH_WORDS: usize = 1024;
3436

37+
#[cfg(any(
38+
feature = "stm32f405",
39+
feature = "stm32f407",
40+
feature = "stm32f415",
41+
feature = "stm32f417",
42+
feature = "stm32f427",
43+
feature = "stm32f429",
44+
feature = "stm32f437",
45+
feature = "stm32f439",
46+
))]
47+
const ENDPOINT_COUNT: usize = 6;
48+
#[cfg(any(feature = "stm32f446", feature = "stm32f469", feature = "stm32f479"))]
49+
const ENDPOINT_COUNT: usize = 9;
50+
3551
fn enable() {
3652
let rcc = unsafe { &*stm32::RCC::ptr() };
3753

@@ -44,6 +60,10 @@ unsafe impl UsbPeripheral for USB {
4460
rcc.ahb1rstr.modify(|_, w| w.otghsrst().clear_bit());
4561
});
4662
}
63+
64+
fn ahb_frequency_hz(&self) -> u32 {
65+
self.hclk.0
66+
}
4767
}
4868

4969
pub type UsbBusType = UsbBus<USB>;

0 commit comments

Comments
 (0)