pub struct Rtc<'d> { /* private fields */ }Expand description
RTC handle. The clock keeps counting after this is dropped.
Implementations§
Source§impl<'d> Rtc<'d>
impl<'d> Rtc<'d>
Sourcepub fn new(peri: Peri<'d, RTC>, source: ClockSource) -> Result<Self, Error>
pub fn new(peri: Peri<'d, RTC>, source: ClockSource) -> Result<Self, Error>
Enable the RTC from source with a 1 Hz time base.
An RTC already running from source keeps the prescaler it was
started with: the prescaler is write-only, and rewriting it restarts
the current second.
Returns an error before changing RTCCLK when the divider does not
fit or the RTC already runs from another source.
Sourcepub fn synchronize(&self)
pub fn synchronize(&self)
Re-acquire the register shadow after Stop-mode wake-up or an HB reset.
Clearing RSF and waiting for hardware to set it again makes the
prescaler, alarm and counter reads current (RM §6.3.2).
Sourcepub fn get_time(&self) -> u32
pub fn get_time(&self) -> u32
Current counter value in seconds. The epoch is whatever the user set.
Sourcepub fn set_time(&self, seconds: u32)
pub fn set_time(&self, seconds: u32)
Write the counter. Takes effect on the next prescaler tick.
Sourcepub fn set_alarm(&self, seconds: u32)
pub fn set_alarm(&self, seconds: u32)
Set the alarm compare value.
A pending ALRF is cleared first so a stale match cannot fire the
interrupt for the new value.
Sourcepub fn read_prescaler(&self) -> u32
pub fn read_prescaler(&self) -> u32
Current prescaler counter. It counts down from frequency - 1 to 0;
two reads one tick apart differ while RTCCLK is alive.
Sourcepub fn enable_second_interrupt(&self, enable: bool)
pub fn enable_second_interrupt(&self, enable: bool)
Second-event interrupt on the RTC vector.
Sourcepub fn enable_alarm_interrupt(&self, enable: bool)
pub fn enable_alarm_interrupt(&self, enable: bool)
Alarm interrupt on the RTCALARM vector.
Sourcepub fn enable_overflow_interrupt(&self, enable: bool)
pub fn enable_overflow_interrupt(&self, enable: bool)
Overflow interrupt on the RTC vector.
Sourcepub fn second_flag(&self) -> bool
pub fn second_flag(&self) -> bool
A second elapsed since the last clear.
Sourcepub fn alarm_flag(&self) -> bool
pub fn alarm_flag(&self) -> bool
The counter reached the alarm value.
Sourcepub fn overflow_flag(&self) -> bool
pub fn overflow_flag(&self) -> bool
The 32-bit counter wrapped.
Sourcepub fn clear_second_flag(&self)
pub fn clear_second_flag(&self)
Clear the second-event flag.
Sourcepub fn clear_alarm_flag(&self)
pub fn clear_alarm_flag(&self)
Clear the alarm flag.
Sourcepub fn clear_overflow_flag(&self)
pub fn clear_overflow_flag(&self)
Clear the overflow flag.
Sourcepub fn clear_flags(&self)
pub fn clear_flags(&self)
Clear SECF, ALRF and OWF in one write.