stm32: fix rtc and examples

This commit is contained in:
xoviat 2023-08-06 12:06:29 -05:00
parent 28618d12a1
commit ae608cf2fa
2 changed files with 5 additions and 4 deletions

View file

@ -22,10 +22,11 @@ impl<'d, T: Instance> super::Rtc<'d, T> {
let reg = crate::pac::RCC.bdcr().read(); let reg = crate::pac::RCC.bdcr().read();
assert!(!reg.lsecsson(), "RTC is not compatible with LSE CSS, yet."); 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)))] #[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| w.set_bdrst(true));
crate::pac::RCC.bdcr().modify(|w| { crate::pac::RCC.bdcr().modify(|w| {
@ -33,7 +34,7 @@ impl<'d, T: Instance> super::Rtc<'d, T> {
w.set_bdrst(false); w.set_bdrst(false);
// Select RTC source // Select RTC source
w.set_rtcsel(clock_source as u8); w.set_rtcsel(clock_source);
w.set_rtcen(true); w.set_rtcen(true);

View file

@ -29,7 +29,7 @@ async fn main(_spawner: Spawner) {
let mut rtc = Rtc::new( let mut rtc = Rtc::new(
p.RTC, 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()); info!("Got RTC! {:?}", now.timestamp());