Skip to content

Commit a621db3

Browse files
committed
Force user to initialize HSI48 before using USB
This prevents mistakes (USB won't work without HSI48) and restores the behavior of the old API, before the recent changes.
1 parent 59a867b commit a621db3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/usb_serial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ fn main() -> ! {
1616

1717
let mut rcc = dp.RCC.freeze(rcc::Config::hsi16());
1818
let mut syscfg = SYSCFG::new(dp.SYSCFG, &mut rcc);
19-
rcc.enable_hsi48(&mut syscfg, dp.CRS);
19+
let hsi48 = rcc.enable_hsi48(&mut syscfg, dp.CRS);
2020

2121
let gpioa = dp.GPIOA.split(&mut rcc);
2222

23-
let usb = USB::new(dp.USB, gpioa.pa11, gpioa.pa12);
23+
let usb = USB::new(dp.USB, gpioa.pa11, gpioa.pa12, hsi48);
2424
let usb_bus = UsbBus::new(usb);
2525

2626
let mut serial = SerialPort::new(&usb_bus);

src/usb.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
//! Please check out the USB examples in the `examples/` directory to see how it
1313
//! fits together.
1414
15-
use crate::pac::{self, RCC};
15+
use crate::{
16+
pac::{self, RCC},
17+
rcc::HSI48,
18+
};
1619
use stm32_usbd::UsbPeripheral;
1720

1821
use crate::gpio::gpioa::{PA11, PA12};
@@ -27,6 +30,7 @@ impl USB {
2730
_: pac::USB,
2831
_dm: PA11<Input<Floating>>,
2932
_dp: PA12<Input<Floating>>,
33+
_: HSI48,
3034
)
3135
-> Self
3236
{

0 commit comments

Comments
 (0)