Skip to main content

Rtc

Struct Rtc 

Source
pub struct Rtc<'d> { /* private fields */ }
Expand description

RTC handle. The clock keeps counting after this is dropped.

Implementations§

Source§

impl<'d> Rtc<'d>

Source

pub fn new(peri: Peri<'d, RTC>, source: ClockSource) -> Result<Self, Error>

Enable the RTC from source with a 1 Hz time base.

An RTC already running from source keeps the prescaler it was started with: the prescaler is write-only, and rewriting it restarts the current second.

Returns an error before changing RTCCLK when the divider does not fit or the RTC already runs from another source.

Source

pub fn frequency(&self) -> Hertz

Clock frequency fed into the prescaler.

Source

pub fn synchronize(&self)

Re-acquire the register shadow after Stop-mode wake-up or an HB reset.

Clearing RSF and waiting for hardware to set it again makes the prescaler, alarm and counter reads current (RM §6.3.2).

Source

pub fn get_time(&self) -> u32

Current counter value in seconds. The epoch is whatever the user set.

Source

pub fn set_time(&self, seconds: u32)

Write the counter. Takes effect on the next prescaler tick.

Source

pub fn set_alarm(&self, seconds: u32)

Set the alarm compare value.

A pending ALRF is cleared first so a stale match cannot fire the interrupt for the new value.

Source

pub fn read_prescaler(&self) -> u32

Current prescaler counter. It counts down from frequency - 1 to 0; two reads one tick apart differ while RTCCLK is alive.

Source

pub fn enable_second_interrupt(&self, enable: bool)

Second-event interrupt on the RTC vector.

Source

pub fn enable_alarm_interrupt(&self, enable: bool)

Alarm interrupt on the RTCALARM vector.

Source

pub fn enable_overflow_interrupt(&self, enable: bool)

Overflow interrupt on the RTC vector.

Source

pub fn second_flag(&self) -> bool

A second elapsed since the last clear.

Source

pub fn alarm_flag(&self) -> bool

The counter reached the alarm value.

Source

pub fn overflow_flag(&self) -> bool

The 32-bit counter wrapped.

Source

pub fn clear_second_flag(&self)

Clear the second-event flag.

Source

pub fn clear_alarm_flag(&self)

Clear the alarm flag.

Source

pub fn clear_overflow_flag(&self)

Clear the overflow flag.

Source

pub fn clear_flags(&self)

Clear SECF, ALRF and OWF in one write.

Auto Trait Implementations§

§

impl<'d> !UnwindSafe for Rtc<'d>

§

impl<'d> Freeze for Rtc<'d>

§

impl<'d> RefUnwindSafe for Rtc<'d>

§

impl<'d> Send for Rtc<'d>

§

impl<'d> Sync for Rtc<'d>

§

impl<'d> Unpin for Rtc<'d>

§

impl<'d> UnsafeUnpin for Rtc<'d>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.