Skip to content

Commit 1bc395e

Browse files
committed
Fix examples.
1 parent ab85cd6 commit 1bc395e

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

examples/rng.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,25 @@ fn main() -> ! {
4040

4141
let clocks = rcc
4242
.cfgr
43-
// needed for RNG
43+
// Needed for RNG.
4444
.clk48_source({
45-
if cfg!(any(
45+
#[cfg(any(
4646
feature = "stm32l476",
4747
feature = "stm32l486",
4848
feature = "stm32l496",
4949
feature = "stm32l4a6"
50-
)) {
50+
))]
51+
{
5152
Clk48Source::Hsi48
52-
} else {
53+
}
54+
55+
#[cfg(not(any(
56+
feature = "stm32l476",
57+
feature = "stm32l486",
58+
feature = "stm32l496",
59+
feature = "stm32l4a6"
60+
)))]
61+
{
5362
Clk48Source::Msi
5463
}
5564
})

examples/usb_serial.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
extern crate panic_semihosting;
77

88
use cortex_m_rt::entry;
9+
use stm32l4xx_hal::rcc::Clk48Source;
910
use stm32l4xx_hal::usb::{Peripheral, UsbBus};
1011
use stm32l4xx_hal::{prelude::*, stm32};
1112
use usb_device::prelude::*;
@@ -43,7 +44,28 @@ fn main() -> ! {
4344

4445
let _clocks = rcc
4546
.cfgr
46-
.hsi48(true)
47+
// Needed for USB.
48+
.clk48_source({
49+
#[cfg(any(
50+
feature = "stm32l476",
51+
feature = "stm32l486",
52+
feature = "stm32l496",
53+
feature = "stm32l4a6"
54+
))]
55+
{
56+
Clk48Source::Hsi48
57+
}
58+
59+
#[cfg(not(any(
60+
feature = "stm32l476",
61+
feature = "stm32l486",
62+
feature = "stm32l496",
63+
feature = "stm32l4a6"
64+
)))]
65+
{
66+
Clk48Source::Msi
67+
}
68+
})
4769
.sysclk(80.MHz())
4870
.freeze(&mut flash.acr, &mut pwr);
4971

0 commit comments

Comments
 (0)