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: Peri<'d, T>,
_irq: impl Binding<RTC_IRQ, InterruptHandler>,
) -> Self
pub fn new( inner: Peri<'d, T>, _irq: impl Binding<RTC_IRQ, InterruptHandler>, ) -> Self
Create a new instance of the real time clock.
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 divisible 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_raw(&mut self, t: RawDateTime)
pub fn set_raw(&mut self, t: RawDateTime)
Write raw values to the RTC calendar registers, and start the RTC.
See RawDateTime: the values are not validated.
Sourcepub fn read_raw(&self) -> RawDateTime
pub fn read_raw(&self) -> RawDateTime
Read the raw contents of the RTC calendar registers.
See RawDateTime: the values are not validated.
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.read_raw();
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.
Sourcepub fn alarm_scheduled(&self) -> Option<DateTimeFilter>
pub fn alarm_scheduled(&self) -> Option<DateTimeFilter>
Check if an alarm is scheduled.
This function checks if the RTC alarm is currently active. If it is, it returns the alarm configuration
as a DateTimeFilter. Otherwise, it returns None.
Sourcepub async fn wait_for_alarm(&mut self)
pub async fn wait_for_alarm(&mut self)
Wait for an RTC alarm to trigger.
This function will wait until the RTC alarm is triggered. If the alarm is already triggered, it will return immediately. If no alarm is scheduled, it will wait indefinitely until one is scheduled and triggered.