pub struct RawDateTime {
pub year: u8,
pub month: u8,
pub day: u8,
pub day_of_week: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
pub subsecond: u16,
}Expand description
Raw contents of the RTC calendar registers.
This is a dumb container for the values in the RTC time and date registers, decoded from BCD.
It does no validation whatsoever: it can hold dates that do not exist (February 30, month
0, hour 61…), and Rtc::set_raw writes whatever it holds to the
hardware. Out-of-range values are truncated to the width of the register fields.
It is meant for code that cares about the last few hundred bytes of flash, or that needs the
hardware day of week. For anything else, enable the jiff feature and use
RtcTimeProvider::read and Rtc::set, which work with validated jiff::civil::DateTime
values.
Fields§
§year: u8Year within the century, as stored in the RTC, 0..=99. The jiff API takes it as the
years 2000 to 2099.
month: u8Month, 1..=12, 1 is January.
day: u8Day of the month, 1..=31.
day_of_week: u8Day of the week, 1..=7, 1 is Monday. The hardware does not allow 0.
The RTC does not check it against the date, it only increments it every day, wrapping from 7 to 1.
hour: u8Hour, 0..=23.
minute: u8Minute, 0..=59.
second: u8Second, 0..=59.
subsecond: u16Subsecond counter, the SS field of RTC_SSR.
It counts down from PREDIV_S (RTC_PRER) to 0 once per second, so the fraction of the
current second that has elapsed is (PREDIV_S - subsecond) / (PREDIV_S + 1). Right after
Rtc::synchronize it can be above PREDIV_S, meaning the time is still before second.
Rtc::set_raw ignores it: setting the calendar resets the counter.