pub struct Rtc<'d, T: Instance> { /* private fields */ }
Expand description
A reference to the real time clock of the system
Implementations§
Source§impl<'d, T: Instance> Rtc<'d, T>
impl<'d, T: Instance> Rtc<'d, T>
Sourcepub fn new(inner: impl Peripheral<P = T> + 'd) -> Self
pub fn new(inner: impl Peripheral<P = T> + 'd) -> Self
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.
Sourcepub fn set_leap_year_check(&mut self, leap_year_check_enabled: bool)
pub fn set_leap_year_check(&mut self, leap_year_check_enabled: bool)
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.
Leap year checking is enabled by default.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Checks to see if this Rtc is running
Sourcepub fn set_datetime(&mut self, t: DateTime) -> Result<(), RtcError>
pub fn set_datetime(&mut self, t: DateTime) -> Result<(), RtcError>
Set the datetime to a new value.
§Errors
Will return RtcError::InvalidDateTime
if the datetime is not a valid range.
Sourcepub fn disable_alarm(&mut self)
pub fn disable_alarm(&mut self)
Disable the alarm that was scheduled with schedule_alarm
.
Sourcepub fn schedule_alarm(&mut self, filter: DateTimeFilter)
pub fn schedule_alarm(&mut self, filter: DateTimeFilter)
Schedule an alarm. The filter
determines at which point in time this alarm is set.
Keep in mind that the filter only triggers on the specified time. If you want to schedule this alarm every minute, you have to call:
let now = real_time_clock.now().unwrap();
real_time_clock.schedule_alarm(
DateTimeFilter::default()
.minute(if now.minute == 59 { 0 } else { now.minute + 1 })
);
Sourcepub fn clear_interrupt(&mut self)
pub fn clear_interrupt(&mut self)
Clear the interrupt. This should be called every time the RTC_IRQ
interrupt is triggered,
or the next schedule_alarm
will never fire.