pub struct Rtc {
pub regs: RTC,
}Fields§
§regs: RTCImplementations§
Source§impl Rtc
impl Rtc
Sourcepub fn new(
regs: RTC,
prediv_s: u16,
prediv_a: u8,
clock_source: RtcClock,
clocks: Clocks,
apb1: &mut APB1,
pwr: &mut PWR,
) -> Option<Self>
pub fn new( regs: RTC, prediv_s: u16, prediv_a: u8, clock_source: RtcClock, clocks: Clocks, apb1: &mut APB1, pwr: &mut PWR, ) -> Option<Self>
Create and enable a new RTC, and configure its clock source and prescalers.
** Assumes 1970-01-01 00:00:00 Epoch **
See AN4759 (Rev 7) Table 7 for configuration of prediv_s and prediv_a,
respectively the formula to calculate ck_spre on the same page.
For example, when using the LSE,
set prediv_s to 255, and prediv_a to 127 to get a calendar clock of 1Hz.
§Panics
A panic is triggered in case the RTC returns invalid a date or time, for example, hours greater than 23.
§Note
This implementation assumes that the APB clock is greater than (>=) seven (7) times the RTC clock. This ensures a secure behavior of the synchronization mechanism.
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.