Skip to main content

RealTimeTimer

Struct RealTimeTimer 

Source
pub struct RealTimeTimer<const PRESCALER: usize, const RTC1HZ: bool> { /* private fields */ }

Implementations§

Source§

impl<const PRESCALER: usize, const RTC1HZ: bool> RealTimeTimer<PRESCALER, RTC1HZ>

Source

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() {}
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn clear_interrupt_flags(&mut self)

Clear interrupt status This will clear both prescaler and alarm interrupts

Trait Implementations§

Source§

impl<const PRESCALER: usize, const RTC1HZ: bool> CountDown for RealTimeTimer<PRESCALER, RTC1HZ>

Source§

fn wait(&mut self) -> Result<(), Void>

Waits on the 32-bit register alarm flag (ALMS)

Source§

type Time = Duration<u32, 1, SLCK_FREQ>

The unit of time used by this timer
Source§

fn start<T>(&mut self, timeout: T)
where T: Into<Self::Time>,

Starts a new count down
Source§

impl<const PRESCALER: usize, const RTC1HZ: bool> Periodic for RealTimeTimer<PRESCALER, RTC1HZ>

Auto Trait Implementations§

§

impl<const PRESCALER: usize, const RTC1HZ: bool> !Sync for RealTimeTimer<PRESCALER, RTC1HZ>

§

impl<const PRESCALER: usize, const RTC1HZ: bool> Freeze for RealTimeTimer<PRESCALER, RTC1HZ>

§

impl<const PRESCALER: usize, const RTC1HZ: bool> RefUnwindSafe for RealTimeTimer<PRESCALER, RTC1HZ>

§

impl<const PRESCALER: usize, const RTC1HZ: bool> Send for RealTimeTimer<PRESCALER, RTC1HZ>

§

impl<const PRESCALER: usize, const RTC1HZ: bool> Unpin for RealTimeTimer<PRESCALER, RTC1HZ>

§

impl<const PRESCALER: usize, const RTC1HZ: bool> UnsafeUnpin for RealTimeTimer<PRESCALER, RTC1HZ>

§

impl<const PRESCALER: usize, const RTC1HZ: bool> UnwindSafe for RealTimeTimer<PRESCALER, RTC1HZ>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.