pub struct RealTimeTimer<const PRESCALER: usize, const RTC1HZ: bool> { /* private fields */ }Implementations§
Source§impl<const PRESCALER: usize, const RTC1HZ: bool> RealTimeTimer<PRESCALER, RTC1HZ>
impl<const PRESCALER: usize, const RTC1HZ: bool> RealTimeTimer<PRESCALER, RTC1HZ>
Sourcepub fn new(rtt: RTT) -> Self
pub fn new(rtt: RTT) -> Self
RTT is simple to initialize as it requires no other setup. (with the exception of using a 32.768 kHz crystal). Both the internal RC counters (32.768 kHz and 1 Hz) require no setup.
If prescaler is equal to zero, the prescaler period is equal to 2^16 * SCLK period. If not, the prescaler period is equal to us_prescaler * SCLK period. 0 - 2^16 * SCLK 1, 2 - Forbidden Otherwise - RTPRES * SLCK 3 => 32.768 kHz / 3 = 10.92267 kHz (91552.706 ns) This means our minimum unit of time is ~92 us.
The maximum amount of time using the minimum unit of time: 91552.706 ns * 2^32 = 3.932159E14 393215.9 seconds 6553.598 minutes 109.2266 hours 4.55111 days
If the RTC1HZ is enabled, a 1 Hz signal is used for the 32-bit alarm. The prescaler is still active and can be triggered from the prescaler increment interrupt. This is a calibrated source and is optimized for 1 Hz (if you don’t have a physical 32.768 Hz crystal).
const PRESCALER: usize = 3;
let mut rtt = RealTimeTimer::<PRESCALER, false>::new(peripherals.RTT);
// Set Wait for 1 second
rtt.start(1_000_000u32.micros());
// Wait for 1 second
while !rtt.wait().is_ok() {}
// Wait for 1 second again
while !rtt.wait().is_ok() {}Sourcepub fn enable_alarm_interrupt(&mut self)
pub fn enable_alarm_interrupt(&mut self)
Enable the interrupt generation for the 32-bit register alarm. This method only sets the clock configuration to trigger the interrupt; it does not configure the interrupt controller or define an interrupt handler.
Sourcepub fn enable_prescaler_interrupt(&mut self)
pub fn enable_prescaler_interrupt(&mut self)
Enable the interrupt generation for the 16-bit prescaler overflow. This method only sets the clock configuration to trigger the interrupt; it does not configure the interrupt controller or define an interrupt handler.
Sourcepub fn disable_alarm_interrupt(&mut self)
pub fn disable_alarm_interrupt(&mut self)
Disables interrupt generation for the 32-bit register alarm. This method only sets the clock configuration to prevent triggering the interrupt; it does not configure the interrupt controller.
Sourcepub fn disable_prescaler_interrupt(&mut self)
pub fn disable_prescaler_interrupt(&mut self)
Disables interrupt generation for the 16-bit prescaler overflow. This method only sets the clock configuration to prevent triggering the interrupt; it does not configure the interrupt controller.
Sourcepub fn clear_interrupt_flags(&mut self)
pub fn clear_interrupt_flags(&mut self)
Clear interrupt status This will clear both prescaler and alarm interrupts