From ae608cf2fa009556953b72f18683496c17b8dca0 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 6 Aug 2023 12:06:29 -0500 Subject: [PATCH] stm32: fix rtc and examples --- embassy-stm32/src/rtc/v3.rs | 7 ++++--- examples/stm32wl/src/bin/rtc.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs index 64ecf4fbd..9f04c9b69 100644 --- a/embassy-stm32/src/rtc/v3.rs +++ b/embassy-stm32/src/rtc/v3.rs @@ -22,10 +22,11 @@ impl<'d, T: Instance> super::Rtc<'d, T> { let reg = crate::pac::RCC.bdcr().read(); assert!(!reg.lsecsson(), "RTC is not compatible with LSE CSS, yet."); + let clock_source = clock_source as u8; #[cfg(not(any(rcc_wl5, rcc_wle)))] - let config_rtcsel = crate::pac::rcc::vals::Rtcsel::from_bits(clock_source as u8); + let clock_source = crate::pac::rcc::vals::Rtcsel::from_bits(clock_source); - if !reg.rtcen() || reg.rtcsel() != clock_source as u8 { + if !reg.rtcen() || reg.rtcsel() != clock_source { crate::pac::RCC.bdcr().modify(|w| w.set_bdrst(true)); crate::pac::RCC.bdcr().modify(|w| { @@ -33,7 +34,7 @@ impl<'d, T: Instance> super::Rtc<'d, T> { w.set_bdrst(false); // Select RTC source - w.set_rtcsel(clock_source as u8); + w.set_rtcsel(clock_source); w.set_rtcen(true); diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs index e11825499..0d7906bde 100644 --- a/examples/stm32wl/src/bin/rtc.rs +++ b/examples/stm32wl/src/bin/rtc.rs @@ -29,7 +29,7 @@ async fn main(_spawner: Spawner) { let mut rtc = Rtc::new( p.RTC, - RtcConfig::default().clock_config(embassy_stm32::rtc::RtcClockSource::LSE), + RtcConfig::default().clock_source(embassy_stm32::rtc::RtcClockSource::LSE), ); info!("Got RTC! {:?}", now.timestamp());