aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/rcc/l4.rs5
-rw-r--r--examples/stm32l4/src/bin/rtc.rs5
2 files changed, 6 insertions, 4 deletions
diff --git a/embassy-stm32/src/rcc/l4.rs b/embassy-stm32/src/rcc/l4.rs
index 36c9eb2f5..b2828e58e 100644
--- a/embassy-stm32/src/rcc/l4.rs
+++ b/embassy-stm32/src/rcc/l4.rs
@@ -10,6 +10,7 @@ use crate::gpio::Speed;
10use crate::pac::rcc::vals::{Hpre, Msirange, Pllsrc, Ppre, Sw}; 10use crate::pac::rcc::vals::{Hpre, Msirange, Pllsrc, Ppre, Sw};
11use crate::pac::{FLASH, PWR, RCC}; 11use crate::pac::{FLASH, PWR, RCC};
12use crate::rcc::{set_freqs, Clocks}; 12use crate::rcc::{set_freqs, Clocks};
13use crate::rtc::{Rtc, RtcClockSource as RCS};
13use crate::time::Hertz; 14use crate::time::Hertz;
14use crate::{peripherals, Peripheral}; 15use crate::{peripherals, Peripheral};
15 16
@@ -426,6 +427,8 @@ pub(crate) unsafe fn init(config: Config) {
426 427
427 // Wait until LSE is running 428 // Wait until LSE is running
428 while !RCC.bdcr().read().lserdy() {} 429 while !RCC.bdcr().read().lserdy() {}
430
431 Rtc::set_clock_source(RCS::LSE);
429 } 432 }
430 RtcClockSource::LSI32 => { 433 RtcClockSource::LSI32 => {
431 // Turn on the internal 32 kHz LSI oscillator 434 // Turn on the internal 32 kHz LSI oscillator
@@ -433,6 +436,8 @@ pub(crate) unsafe fn init(config: Config) {
433 436
434 // Wait until LSI is running 437 // Wait until LSI is running
435 while !RCC.csr().read().lsirdy() {} 438 while !RCC.csr().read().lsirdy() {}
439
440 Rtc::set_clock_source(RCS::LSI);
436 } 441 }
437 } 442 }
438 443
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs
index fe2aabb44..294ea456c 100644
--- a/examples/stm32l4/src/bin/rtc.rs
+++ b/examples/stm32l4/src/bin/rtc.rs
@@ -33,10 +33,7 @@ async fn main(_spawner: Spawner) {
33 .and_hms_opt(10, 30, 15) 33 .and_hms_opt(10, 30, 15)
34 .unwrap(); 34 .unwrap();
35 35
36 let mut rtc = Rtc::new( 36 let mut rtc = Rtc::new(p.RTC, RtcConfig::default());
37 p.RTC,
38 RtcConfig::default().clock_source(embassy_stm32::rtc::RtcClockSource::LSE),
39 );
40 info!("Got RTC! {:?}", now.timestamp()); 37 info!("Got RTC! {:?}", now.timestamp());
41 38
42 rtc.set_datetime(now.into()).expect("datetime not set"); 39 rtc.set_datetime(now.into()).expect("datetime not set");