stm32/rtc: use rccperi enable
This commit is contained in:
parent
481d2998ef
commit
04b09a2acb
@ -59,7 +59,7 @@ sdio-host = "0.5.0"
|
|||||||
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
|
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
|
||||||
critical-section = "1.1"
|
critical-section = "1.1"
|
||||||
atomic-polyfill = "1.0.1"
|
atomic-polyfill = "1.0.1"
|
||||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-74025d56c0ba061703f360558ce80f51d1165060" }
|
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-1551a1c01a993bb5ffc603311f80097c14e03f85" }
|
||||||
vcell = "0.1.3"
|
vcell = "0.1.3"
|
||||||
bxcan = "0.7.0"
|
bxcan = "0.7.0"
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
@ -78,7 +78,7 @@ critical-section = { version = "1.1", features = ["std"] }
|
|||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
proc-macro2 = "1.0.36"
|
proc-macro2 = "1.0.36"
|
||||||
quote = "1.0.15"
|
quote = "1.0.15"
|
||||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-74025d56c0ba061703f360558ce80f51d1165060", default-features = false, features = ["metadata"]}
|
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-1551a1c01a993bb5ffc603311f80097c14e03f85", default-features = false, features = ["metadata"]}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rt"]
|
default = ["rt"]
|
||||||
|
@ -88,11 +88,6 @@ impl BackupDomain {
|
|||||||
))]
|
))]
|
||||||
#[allow(dead_code, unused_variables)]
|
#[allow(dead_code, unused_variables)]
|
||||||
pub fn configure_ls(clock_source: RtcClockSource, lsi: bool, lse: Option<LseDrive>) {
|
pub fn configure_ls(clock_source: RtcClockSource, lsi: bool, lse: Option<LseDrive>) {
|
||||||
if lsi || lse.is_some() {
|
|
||||||
use crate::rtc::sealed::Instance;
|
|
||||||
crate::peripherals::RTC::enable_peripheral_clk();
|
|
||||||
}
|
|
||||||
|
|
||||||
if lsi {
|
if lsi {
|
||||||
#[cfg(rtc_v3u5)]
|
#[cfg(rtc_v3u5)]
|
||||||
let csr = crate::pac::RCC.bdcr();
|
let csr = crate::pac::RCC.bdcr();
|
||||||
|
@ -10,6 +10,7 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
|||||||
use embassy_sync::blocking_mutex::Mutex;
|
use embassy_sync::blocking_mutex::Mutex;
|
||||||
|
|
||||||
pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError};
|
pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError};
|
||||||
|
use crate::rcc::sealed::RccPeripheral;
|
||||||
pub use crate::rcc::RtcClockSource;
|
pub use crate::rcc::RtcClockSource;
|
||||||
use crate::time::Hertz;
|
use crate::time::Hertz;
|
||||||
|
|
||||||
@ -111,11 +112,12 @@ impl RtcTimeProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
|
||||||
/// RTC Abstraction
|
/// RTC Abstraction
|
||||||
pub struct Rtc {
|
pub struct Rtc {
|
||||||
#[cfg(feature = "low-power")]
|
#[cfg(feature = "low-power")]
|
||||||
stop_time: Mutex<CriticalSectionRawMutex, Cell<Option<RtcInstant>>>,
|
stop_time: Mutex<CriticalSectionRawMutex, Cell<Option<RtcInstant>>>,
|
||||||
|
#[cfg(not(feature = "low-power"))]
|
||||||
|
_private: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
@ -154,9 +156,13 @@ impl Default for RtcCalibrationCyclePeriod {
|
|||||||
|
|
||||||
impl Rtc {
|
impl Rtc {
|
||||||
pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self {
|
pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self {
|
||||||
|
RTC::enable();
|
||||||
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
#[cfg(feature = "low-power")]
|
#[cfg(feature = "low-power")]
|
||||||
stop_time: Mutex::const_new(CriticalSectionRawMutex::new(), Cell::new(None)),
|
stop_time: Mutex::const_new(CriticalSectionRawMutex::new(), Cell::new(None)),
|
||||||
|
#[cfg(not(feature = "low-power"))]
|
||||||
|
_private: (),
|
||||||
};
|
};
|
||||||
|
|
||||||
let frequency = Self::frequency();
|
let frequency = Self::frequency();
|
||||||
@ -292,8 +298,6 @@ pub(crate) mod sealed {
|
|||||||
crate::pac::RTC
|
crate::pac::RTC
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enable_peripheral_clk();
|
|
||||||
|
|
||||||
/// Read content of the backup register.
|
/// Read content of the backup register.
|
||||||
///
|
///
|
||||||
/// The registers retain their values during wakes from standby mode or system resets. They also
|
/// The registers retain their values during wakes from standby mode or system resets. They also
|
||||||
|
@ -286,17 +286,6 @@ impl sealed::Instance for crate::peripherals::RTC {
|
|||||||
#[cfg(all(feature = "low-power", stm32l0))]
|
#[cfg(all(feature = "low-power", stm32l0))]
|
||||||
type WakeupInterrupt = crate::interrupt::typelevel::RTC;
|
type WakeupInterrupt = crate::interrupt::typelevel::RTC;
|
||||||
|
|
||||||
fn enable_peripheral_clk() {
|
|
||||||
#[cfg(any(rtc_v2l4, rtc_v2wb))]
|
|
||||||
{
|
|
||||||
// enable peripheral clock for communication
|
|
||||||
crate::pac::RCC.apb1enr1().modify(|w| w.set_rtcapben(true));
|
|
||||||
|
|
||||||
// read to allow the pwr clock to enable
|
|
||||||
crate::pac::PWR.cr1().read();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_backup_register(rtc: &Rtc, register: usize) -> Option<u32> {
|
fn read_backup_register(rtc: &Rtc, register: usize) -> Option<u32> {
|
||||||
if register < Self::BACKUP_REGISTER_COUNT {
|
if register < Self::BACKUP_REGISTER_COUNT {
|
||||||
Some(rtc.bkpr(register).read().bkp())
|
Some(rtc.bkpr(register).read().bkp())
|
||||||
|
@ -128,23 +128,6 @@ impl super::Rtc {
|
|||||||
impl sealed::Instance for crate::peripherals::RTC {
|
impl sealed::Instance for crate::peripherals::RTC {
|
||||||
const BACKUP_REGISTER_COUNT: usize = 32;
|
const BACKUP_REGISTER_COUNT: usize = 32;
|
||||||
|
|
||||||
fn enable_peripheral_clk() {
|
|
||||||
#[cfg(any(rcc_wle, rcc_wl5, rcc_g4))]
|
|
||||||
{
|
|
||||||
// enable peripheral clock for communication
|
|
||||||
crate::pac::RCC.apb1enr1().modify(|w| w.set_rtcapben(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(rcc_g0)]
|
|
||||||
{
|
|
||||||
// enable peripheral clock for communication
|
|
||||||
crate::pac::RCC.apbenr1().modify(|w| w.set_rtcapben(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
// read to allow the pwr clock to enable
|
|
||||||
crate::pac::PWR.cr1().read();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_backup_register(_rtc: &Rtc, register: usize) -> Option<u32> {
|
fn read_backup_register(_rtc: &Rtc, register: usize) -> Option<u32> {
|
||||||
#[allow(clippy::if_same_then_else)]
|
#[allow(clippy::if_same_then_else)]
|
||||||
if register < Self::BACKUP_REGISTER_COUNT {
|
if register < Self::BACKUP_REGISTER_COUNT {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user