diff options
| author | xoviat <[email protected]> | 2023-08-08 20:33:24 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-08-08 20:33:24 -0500 |
| commit | 32fdd4c787372d44bf134cb5e547eb635c680256 (patch) | |
| tree | 37dd6dd63a23eecbebe49cd3d1de5fb3e8dc9e38 /embassy-stm32 | |
| parent | 6a73ab1afa76944c413cb91932881c35ddfbcbcd (diff) | |
tests/stm32: fix rtc test
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/rcc/f4.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/embassy-stm32/src/rcc/f4.rs b/embassy-stm32/src/rcc/f4.rs index 7aa9f0fd2..2ae0d15cb 100644 --- a/embassy-stm32/src/rcc/f4.rs +++ b/embassy-stm32/src/rcc/f4.rs | |||
| @@ -9,6 +9,7 @@ use crate::gpio::Speed; | |||
| 9 | use crate::pac::rcc::vals::{Hpre, Ppre, Sw}; | 9 | use crate::pac::rcc::vals::{Hpre, Ppre, Sw}; |
| 10 | use crate::pac::{FLASH, PWR, RCC}; | 10 | use crate::pac::{FLASH, PWR, RCC}; |
| 11 | use crate::rcc::{set_freqs, Clocks}; | 11 | use crate::rcc::{set_freqs, Clocks}; |
| 12 | use crate::rtc::{Rtc, RtcClockSource}; | ||
| 12 | use crate::time::Hertz; | 13 | use crate::time::Hertz; |
| 13 | use crate::{peripherals, Peripheral}; | 14 | use crate::{peripherals, Peripheral}; |
| 14 | 15 | ||
| @@ -33,6 +34,7 @@ pub struct Config { | |||
| 33 | pub plli2s: Option<Hertz>, | 34 | pub plli2s: Option<Hertz>, |
| 34 | 35 | ||
| 35 | pub pll48: bool, | 36 | pub pll48: bool, |
| 37 | pub rtc: Option<RtcClockSource>, | ||
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | #[cfg(stm32f410)] | 40 | #[cfg(stm32f410)] |
| @@ -459,6 +461,18 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 459 | }) | 461 | }) |
| 460 | }); | 462 | }); |
| 461 | 463 | ||
| 464 | match config.rtc { | ||
| 465 | Some(RtcClockSource::LSI) => { | ||
| 466 | RCC.csr().modify(|w| w.set_lsion(true)); | ||
| 467 | while !RCC.csr().read().lsirdy() {} | ||
| 468 | } | ||
| 469 | _ => {} | ||
| 470 | } | ||
| 471 | |||
| 472 | config.rtc.map(|clock_source| { | ||
| 473 | Rtc::set_clock_source(clock_source); | ||
| 474 | }); | ||
| 475 | |||
| 462 | set_freqs(Clocks { | 476 | set_freqs(Clocks { |
| 463 | sys: Hertz(sysclk), | 477 | sys: Hertz(sysclk), |
| 464 | apb1: Hertz(pclk1), | 478 | apb1: Hertz(pclk1), |
