pub struct Rtc {
pub regs: RTC,
/* private fields */
}
Expand description
Real Time Clock peripheral
Fields§
§regs: RTC
RTC Peripheral register
Implementations§
Source§impl Rtc
impl Rtc
Sourcepub fn new(regs: RTC, pwr: &mut PWR) -> Self
pub fn new(regs: RTC, pwr: &mut PWR) -> Self
Create and enable a new RTC with external crystal or ceramic resonator and default prescalers.
Sourcepub fn with_config(
regs: RTC,
pwr: &mut PWR,
clock_source: impl Into<ClockSource>,
prediv_s: u16,
prediv_a: u8,
) -> Self
pub fn with_config( regs: RTC, pwr: &mut PWR, clock_source: impl Into<ClockSource>, prediv_s: u16, prediv_a: u8, ) -> Self
Create and enable a new RTC, and configure its clock source and prescalers.
From AN3371, Table 3,
set prediv_s
to 255 (249 for LSI), and prediv_a
to 127 to get a calendar clock of 1Hz.
Sourcepub fn new_lsi(regs: RTC, pwr: &mut PWR) -> Self
pub fn new_lsi(regs: RTC, pwr: &mut PWR) -> Self
Create and enable a new RTC with internal crystal and default prescalers.
Sourcepub fn lsi_with_config(
regs: RTC,
pwr: &mut PWR,
prediv_s: u16,
prediv_a: u8,
) -> Self
pub fn lsi_with_config( regs: RTC, pwr: &mut PWR, prediv_s: u16, prediv_a: u8, ) -> Self
Create and enable a new RTC, and configure its clock source and prescalers.
From AN3371, Table 3, when using the LSI,
set prediv_s
to 249, and prediv_a
to 127 to get a calendar clock of 1Hz.
pub fn set_prescalers(&mut self, prediv_s: u16, prediv_a: u8)
Sourcepub fn set_year(&mut self, year: u16) -> Result<(), Error>
pub fn set_year(&mut self, year: u16) -> Result<(), Error>
Set the year [1970-2069].
The year cannot be less than 1970, since the Unix epoch is assumed (1970-01-01 00:00:00). Also, the year cannot be greater than 2069 since the RTC range is 0 - 99.
Sourcepub fn set_date(&mut self, date: &Date) -> Result<(), Error>
pub fn set_date(&mut self, date: &Date) -> Result<(), Error>
Set the date.
The year cannot be less than 1970, since the Unix epoch is assumed (1970-01-01 00:00:00). Also, the year cannot be greater than 2069 since the RTC range is 0 - 99.
Sourcepub fn set_datetime(&mut self, date: &PrimitiveDateTime) -> Result<(), Error>
pub fn set_datetime(&mut self, date: &PrimitiveDateTime) -> Result<(), Error>
Set the date and time.
The year cannot be less than 1970, since the Unix epoch is assumed (1970-01-01 00:00:00). Also, the year cannot be greater than 2069 since the RTC range is 0 - 99.
pub fn get_datetime(&mut self) -> PrimitiveDateTime
Sourcepub fn enable_wakeup(&mut self, interval: MicrosDurationU64)
pub fn enable_wakeup(&mut self, interval: MicrosDurationU64)
Configures the wakeup timer to trigger periodically every interval
duration
§Panics
Panics if interval is greater than 2¹⁷-1 seconds.
Sourcepub fn disable_wakeup(&mut self)
pub fn disable_wakeup(&mut self)
Disables the wakeup timer
Sourcepub fn enable_vbat_timestamp(&mut self)
pub fn enable_vbat_timestamp(&mut self)
Configures the timestamp to be captured when the RTC switches to Vbat power
Sourcepub fn disable_timestamp(&mut self)
pub fn disable_timestamp(&mut self)
Disables the timestamp
Sourcepub fn read_timestamp(&self) -> PrimitiveDateTime
pub fn read_timestamp(&self) -> PrimitiveDateTime
Reads the stored value of the timestamp if present
Clears the timestamp interrupt flags.
Sourcepub fn set_alarm(
&mut self,
alarm: Alarm,
date: impl Into<AlarmDay>,
time: Time,
) -> Result<(), Error>
pub fn set_alarm( &mut self, alarm: Alarm, date: impl Into<AlarmDay>, time: Time, ) -> Result<(), Error>
Sets the time at which an alarm will be triggered This also clears the alarm flag if it is set
Sourcepub fn is_pending(&self, event: Event) -> bool
pub fn is_pending(&self, event: Event) -> bool
Returns true
if event
is pending
Sourcepub fn clear_interrupt(&mut self, event: Event)
pub fn clear_interrupt(&mut self, event: Event)
Clears the interrupt flag for event