diff options
| author | xoviat <[email protected]> | 2023-08-27 09:50:02 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-08-27 09:50:02 -0500 |
| commit | f28ab18d7bc05ade2130979d67b0af6ad4085d76 (patch) | |
| tree | 388291cfc8a002b92811b54dcfc5b07b49479407 | |
| parent | 3bf6081eb5985d853ffee1bf8064304daa1fdfd8 (diff) | |
stm32: fix l4 re-export
| -rw-r--r-- | embassy-stm32/src/rcc/l4.rs | 20 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/rtc.rs | 2 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/spe_adin1110_http_server.rs | 2 |
3 files changed, 10 insertions, 14 deletions
diff --git a/embassy-stm32/src/rcc/l4.rs b/embassy-stm32/src/rcc/l4.rs index 1f02254b1..c6bccfd26 100644 --- a/embassy-stm32/src/rcc/l4.rs +++ b/embassy-stm32/src/rcc/l4.rs | |||
| @@ -9,7 +9,7 @@ use crate::gpio::sealed::AFType; | |||
| 9 | use crate::gpio::Speed; | 9 | use crate::gpio::Speed; |
| 10 | use crate::pac::rcc::vals::{Hpre, Msirange, Pllsrc, Ppre, Sw}; | 10 | use crate::pac::rcc::vals::{Hpre, Msirange, Pllsrc, Ppre, Sw}; |
| 11 | use crate::pac::{FLASH, PWR, RCC}; | 11 | use crate::pac::{FLASH, PWR, RCC}; |
| 12 | use crate::rcc::bd::{BackupDomain, RtcClockSource as RCS}; | 12 | use crate::rcc::bd::{BackupDomain, RtcClockSource}; |
| 13 | use crate::rcc::{set_freqs, Clocks}; | 13 | use crate::rcc::{set_freqs, Clocks}; |
| 14 | use crate::time::Hertz; | 14 | use crate::time::Hertz; |
| 15 | use crate::{peripherals, Peripheral}; | 15 | use crate::{peripherals, Peripheral}; |
| @@ -254,16 +254,11 @@ impl Default for Config { | |||
| 254 | pllsai1: None, | 254 | pllsai1: None, |
| 255 | #[cfg(not(any(stm32l471, stm32l475, stm32l476, stm32l486)))] | 255 | #[cfg(not(any(stm32l471, stm32l475, stm32l476, stm32l486)))] |
| 256 | hsi48: false, | 256 | hsi48: false, |
| 257 | rtc_mux: RtcClockSource::LSI32, | 257 | rtc_mux: RtcClockSource::LSI, |
| 258 | } | 258 | } |
| 259 | } | 259 | } |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | pub enum RtcClockSource { | ||
| 263 | LSE32, | ||
| 264 | LSI32, | ||
| 265 | } | ||
| 266 | |||
| 267 | pub enum McoClock { | 262 | pub enum McoClock { |
| 268 | DIV1, | 263 | DIV1, |
| 269 | DIV2, | 264 | DIV2, |
| @@ -413,7 +408,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 413 | RCC.apb1enr1().modify(|w| w.set_pwren(true)); | 408 | RCC.apb1enr1().modify(|w| w.set_pwren(true)); |
| 414 | 409 | ||
| 415 | match config.rtc_mux { | 410 | match config.rtc_mux { |
| 416 | RtcClockSource::LSE32 => { | 411 | RtcClockSource::LSE => { |
| 417 | // 1. Unlock the backup domain | 412 | // 1. Unlock the backup domain |
| 418 | PWR.cr1().modify(|w| w.set_dbp(true)); | 413 | PWR.cr1().modify(|w| w.set_dbp(true)); |
| 419 | 414 | ||
| @@ -429,17 +424,18 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 429 | // Wait until LSE is running | 424 | // Wait until LSE is running |
| 430 | while !RCC.bdcr().read().lserdy() {} | 425 | while !RCC.bdcr().read().lserdy() {} |
| 431 | 426 | ||
| 432 | BackupDomain::set_rtc_clock_source(RCS::LSE); | 427 | BackupDomain::set_rtc_clock_source(RtcClockSource::LSE); |
| 433 | } | 428 | } |
| 434 | RtcClockSource::LSI32 => { | 429 | RtcClockSource::LSI => { |
| 435 | // Turn on the internal 32 kHz LSI oscillator | 430 | // Turn on the internal 32 kHz LSI oscillator |
| 436 | RCC.csr().modify(|w| w.set_lsion(true)); | 431 | RCC.csr().modify(|w| w.set_lsion(true)); |
| 437 | 432 | ||
| 438 | // Wait until LSI is running | 433 | // Wait until LSI is running |
| 439 | while !RCC.csr().read().lsirdy() {} | 434 | while !RCC.csr().read().lsirdy() {} |
| 440 | 435 | ||
| 441 | BackupDomain::set_rtc_clock_source(RCS::LSI); | 436 | BackupDomain::set_rtc_clock_source(RtcClockSource::LSI); |
| 442 | } | 437 | } |
| 438 | _ => unreachable!(), | ||
| 443 | } | 439 | } |
| 444 | 440 | ||
| 445 | let (sys_clk, sw) = match config.mux { | 441 | let (sys_clk, sw) = match config.mux { |
| @@ -451,7 +447,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 451 | w.set_msirgsel(true); | 447 | w.set_msirgsel(true); |
| 452 | w.set_msion(true); | 448 | w.set_msion(true); |
| 453 | 449 | ||
| 454 | if let RtcClockSource::LSE32 = config.rtc_mux { | 450 | if let RtcClockSource::LSE = config.rtc_mux { |
| 455 | // If LSE is enabled, enable calibration of MSI | 451 | // If LSE is enabled, enable calibration of MSI |
| 456 | w.set_msipllen(true); | 452 | w.set_msipllen(true); |
| 457 | } else { | 453 | } else { |
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs index 294ea456c..f3f8aa46f 100644 --- a/examples/stm32l4/src/bin/rtc.rs +++ b/examples/stm32l4/src/bin/rtc.rs | |||
| @@ -23,7 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | PLLMul::Mul20, | 23 | PLLMul::Mul20, |
| 24 | None, | 24 | None, |
| 25 | ); | 25 | ); |
| 26 | config.rcc.rtc_mux = rcc::RtcClockSource::LSE32; | 26 | config.rcc.rtc_mux = rcc::RtcClockSource::LSE; |
| 27 | embassy_stm32::init(config) | 27 | embassy_stm32::init(config) |
| 28 | }; | 28 | }; |
| 29 | info!("Hello World!"); | 29 | info!("Hello World!"); |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 148c58771..0a677be76 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -84,7 +84,7 @@ async fn main(spawner: Spawner) { | |||
| 84 | None, | 84 | None, |
| 85 | ); | 85 | ); |
| 86 | config.rcc.hsi48 = true; // needed for rng | 86 | config.rcc.hsi48 = true; // needed for rng |
| 87 | config.rcc.rtc_mux = rcc::RtcClockSource::LSI32; | 87 | config.rcc.rtc_mux = rcc::RtcClockSource::LSI; |
| 88 | 88 | ||
| 89 | let dp = embassy_stm32::init(config); | 89 | let dp = embassy_stm32::init(config); |
| 90 | 90 | ||
