pub struct Rtc {
pub regs: RTC,
/* private fields */
}
Expand description
Real Time Clock peripheral
Fields§
§regs: RTC
RTC Peripheral register definition
Implementations§
Source§impl Rtc
impl Rtc
Sourcepub fn new(
regs: RTC,
clock_source: ClockSource,
bypass: bool,
apb1: &mut APB1,
bdcr: &mut BDCR,
pwr: &mut PWR,
) -> Self
pub fn new( regs: RTC, clock_source: ClockSource, bypass: bool, apb1: &mut APB1, bdcr: &mut BDCR, pwr: &mut PWR, ) -> Self
Create and enable a new RTC, and configure its clock source and prescalers.
From AN4759, Table 7, when using the LSE (The only clock source this module
supports currently), set prediv_s
to 255, and prediv_a
to 127 to get a
calendar clock of 1Hz.
The bypass
argument is true
if you’re using an external oscillator that
doesn’t connect to OSC32_IN
, such as a MEMS resonator.
Note: You may need to run dp.RCC.apb1enr.modify(|_, w| w.pwren().set_bit());
before
constraining RCC, eg before running this constructor.
Note that if using HSE as the clock source, we assume you’ve already enabled it, eg
in clock config.
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_alarm(&mut self, exti: &mut EXTI)
pub fn set_alarm(&mut self, exti: &mut EXTI)
Setup the alarm. See AN4759, section 2.3.1.
sleep_time
is in ms. Table 8
desribes these steps.
Sourcepub fn set_wakeup(&mut self, exti: &mut EXTI, sleep_time: f32)
pub fn set_wakeup(&mut self, exti: &mut EXTI, 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 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 handle this in the EXTI handler function.
Trait Implementations§
Source§impl Rtcc for Rtc
impl Rtcc for Rtc
Source§fn set_time(&mut self, time: &NaiveTime) -> Result<(), Self::Error>
fn set_time(&mut self, time: &NaiveTime) -> Result<(), Self::Error>
set time using NaiveTime (ISO 8601 time without timezone) Hour format is 24h
Source§fn set_date(&mut self, date: &NaiveDate) -> Result<(), Self::Error>
fn set_date(&mut self, date: &NaiveDate) -> Result<(), Self::Error>
Set the date using NaiveDate (ISO 8601 calendar date without timezone).
WeekDay is set using the set_weekday
method