diff --git a/embassy-rp/src/rtc/mod.rs b/embassy-rp/src/rtc/mod.rs index b18f12fc..90b796a9 100644 --- a/embassy-rp/src/rtc/mod.rs +++ b/embassy-rp/src/rtc/mod.rs @@ -12,26 +12,24 @@ pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; use crate::clocks::clk_rtc_freq; /// A reference to the real time clock of the system -pub struct RealTimeClock<'d, T: Instance> { +pub struct Rtc<'d, T: Instance> { inner: PeripheralRef<'d, T>, } -impl<'d, T: Instance> RealTimeClock<'d, T> { +impl<'d, T: Instance> Rtc<'d, T> { /// Create a new instance of the real time clock, with the given date as an initial value. /// /// # Errors /// /// Will return `RtcError::InvalidDateTime` if the datetime is not a valid range. - pub fn new(inner: impl Peripheral
+ 'd, initial_date: DateTime) -> Result + 'd) -> Self {
into_ref!(inner);
// Set the RTC divider
inner.regs().clkdiv_m1().write(|w| w.set_clkdiv_m1(clk_rtc_freq() - 1));
- let mut result = Self { inner };
- result.set_leap_year_check(true); // should be on by default, make sure this is the case.
- result.set_datetime(initial_date)?;
- Ok(result)
+ let result = Self { inner };
+ result
}
/// Enable or disable the leap year check. The rp2040 chip will always add a Feb 29th on every year that is divisable by 4, but this may be incorrect (e.g. on century years). This function allows you to disable this check.
@@ -43,7 +41,7 @@ impl<'d, T: Instance> RealTimeClock<'d, T> {
});
}
- /// Checks to see if this RealTimeClock is running
+ /// Checks to see if this Rtc is running
pub fn is_running(&self) -> bool {
self.inner.regs().ctrl().read().rtc_active()
}
@@ -113,8 +111,8 @@ impl<'d, T: Instance> RealTimeClock<'d, T> {
/// # fn main() { }
/// # #[cfg(not(feature = "chrono"))]
/// # fn main() {
- /// # use embassy_rp::rtc::{RealTimeClock, DateTimeFilter};
- /// # let mut real_time_clock: RealTimeClock