Struct stm32_hal2::rtc::Rtc
source · [−]pub struct Rtc { /* private fields */ }
Expand description
Represents a Real Time Clock (RTC) peripheral.
Implementations
sourceimpl Rtc
impl Rtc
sourcepub fn new(regs: RTC, config: RtcConfig) -> Self
pub fn new(regs: RTC, config: RtcConfig) -> Self
Initialize the RTC, including configuration register writes.
sourcepub fn set_24h_fmt(&mut self)
pub fn set_24h_fmt(&mut self)
Sets calendar clock to 24 hr format
sourcepub fn set_12h_fmt(&mut self)
pub fn set_12h_fmt(&mut self)
Sets calendar clock to 12 hr format
sourcepub fn is_24h_fmt(&self) -> bool
pub fn is_24h_fmt(&self) -> bool
Reads current hour format selection
sourcepub fn set_wakeup(&mut self, sleep_time: f32)
pub fn set_wakeup(&mut self, sleep_time: f32)
Setup periodic auto-wakeup interrupts. See ST AN4759, Table 11, and more broadly,
section 2.4.1. See also reference manual, section 27.5.
In addition to running this function, set up the interrupt handling function by
adding the line make_rtc_interrupt_handler!(RTC_WKUP);
somewhere in the body
of your program.
sleep_time
is in ms.
sourcepub fn enable_wakeup(&mut self)
pub fn enable_wakeup(&mut self)
Enable the wakeup timer.
sourcepub fn disable_wakeup(&mut self)
pub fn disable_wakeup(&mut self)
Disable the wakeup timer.
sourcepub fn set_wakeup_interval(&mut self, sleep_time: f32)
pub fn set_wakeup_interval(&mut self, sleep_time: f32)
Change the sleep time for the auto wakeup, after it’s been set up.
Sleep time is in MS. Major DRY from set_wakeup
.
sourcepub fn clear_wakeup_flag(&mut self)
pub fn clear_wakeup_flag(&mut self)
Clears the wakeup flag. Must be cleared manually after every RTC wakeup. Alternatively, you could call this in the RTC wakeup interrupt handler.
sourcepub fn set_time(&mut self, time: &NaiveTime) -> Result<(), Error>
pub fn set_time(&mut self, time: &NaiveTime) -> Result<(), Error>
set time using NaiveTime (ISO 8601 time without timezone) Hour format is 24h
sourcepub fn set_seconds(&mut self, seconds: u8) -> Result<(), Error>
pub fn set_seconds(&mut self, seconds: u8) -> Result<(), Error>
Set the seconds component of the RTC’s current time.
sourcepub fn set_minutes(&mut self, minutes: u8) -> Result<(), Error>
pub fn set_minutes(&mut self, minutes: u8) -> Result<(), Error>
Set the minutes component of the RTC’s current time.
sourcepub fn set_hours(&mut self, hours: u8) -> Result<(), Error>
pub fn set_hours(&mut self, hours: u8) -> Result<(), Error>
Set the hours component of the RTC’s current time.
sourcepub fn set_weekday(&mut self, weekday: u8) -> Result<(), Error>
pub fn set_weekday(&mut self, weekday: u8) -> Result<(), Error>
Set the weekday component of the RTC’s current date.
sourcepub fn set_day(&mut self, day: u8) -> Result<(), Error>
pub fn set_day(&mut self, day: u8) -> Result<(), Error>
Set the day component of the RTC’s current date.
sourcepub fn set_month(&mut self, month: u8) -> Result<(), Error>
pub fn set_month(&mut self, month: u8) -> Result<(), Error>
Set the month component of the RTC’s current date.
sourcepub fn set_year(&mut self, year: u16) -> Result<(), Error>
pub fn set_year(&mut self, year: u16) -> Result<(), Error>
Set the year component of the RTC’s current date.
sourcepub fn set_date(&mut self, date: &NaiveDate) -> Result<(), Error>
pub fn set_date(&mut self, date: &NaiveDate) -> Result<(), Error>
Set the date using NaiveDate (ISO 8601 calendar date without timezone).
WeekDay is set using the set_weekday
method
sourcepub fn set_datetime(&mut self, date: &NaiveDateTime) -> Result<(), Error>
pub fn set_datetime(&mut self, date: &NaiveDateTime) -> Result<(), Error>
Set the current datetime.
sourcepub fn get_seconds(&mut self) -> u8
pub fn get_seconds(&mut self) -> u8
Get the seconds component of the current time.
sourcepub fn get_minutes(&mut self) -> u8
pub fn get_minutes(&mut self) -> u8
Get the minutes component of the current time.
sourcepub fn get_weekday(&mut self) -> u8
pub fn get_weekday(&mut self) -> u8
Get the weekday component of the current date.
sourcepub fn get_datetime(&mut self) -> NaiveDateTime
pub fn get_datetime(&mut self) -> NaiveDateTime
Get the current datetime.