embassy-rp

Crates

git

Versions

rp2040

Flavors

Skip to main content

Rtc

Struct Rtc 

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

A reference to the real time clock of the system

Implementations§

Source§

impl<'d, T: Instance> Rtc<'d, T>

Source

pub fn new( inner: Peri<'d, T>, _irq: impl Binding<RTC_IRQ, InterruptHandler>, ) -> Self

Create a new instance of the real time clock.

Source

pub fn set_leap_year_check(&mut self, leap_year_check_enabled: bool)

Enable or disable the leap year check. The rp2040 chip will always add a Feb 29th on every year that is divisible by 4, but this may be incorrect (e.g. on century years). This function allows you to disable this check.

Leap year checking is enabled by default.

Source

pub fn is_running(&self) -> bool

Checks to see if this Rtc is running

Source

pub fn set_raw(&mut self, t: RawDateTime)

Write raw values to the RTC calendar registers, and start the RTC.

See RawDateTime: the values are not validated.

Source

pub fn read_raw(&self) -> RawDateTime

Read the raw contents of the RTC calendar registers.

See RawDateTime: the values are not validated.

Source

pub fn disable_alarm(&mut self)

Disable the alarm that was scheduled with schedule_alarm.

Source

pub fn schedule_alarm(&mut self, filter: DateTimeFilter)

Schedule an alarm. The filter determines at which point in time this alarm is set.

Keep in mind that the filter only triggers on the specified time. If you want to schedule this alarm every minute, you have to call:

let now = real_time_clock.read_raw();
real_time_clock.schedule_alarm(
    DateTimeFilter::default()
        .minute(if now.minute == 59 { 0 } else { now.minute + 1 })
);
Source

pub fn clear_interrupt(&mut self)

Clear the interrupt. This should be called every time the RTC_IRQ interrupt is triggered, or the next schedule_alarm will never fire.

Source

pub fn alarm_scheduled(&self) -> Option<DateTimeFilter>

Check if an alarm is scheduled.

This function checks if the RTC alarm is currently active. If it is, it returns the alarm configuration as a DateTimeFilter. Otherwise, it returns None.

Source

pub async fn wait_for_alarm(&mut self)

Wait for an RTC alarm to trigger.

This function will wait until the RTC alarm is triggered. If the alarm is already triggered, it will return immediately. If no alarm is scheduled, it will wait indefinitely until one is scheduled and triggered.

Auto Trait Implementations§

§

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

§

impl<'d, T> Forget for Rtc<'d, T>

§

impl<'d, T> Freeze for Rtc<'d, T>
where Peri<'d, T>: Freeze,

§

impl<'d, T> Move for Rtc<'d, T>

§

impl<'d, T> RefUnwindSafe for Rtc<'d, T>
where Peri<'d, T>: RefUnwindSafe,

§

impl<'d, T> Send for Rtc<'d, T>
where Peri<'d, T>: Send,

§

impl<'d, T> Sync for Rtc<'d, T>
where Peri<'d, T>: Sync,

§

impl<'d, T> Unpin for Rtc<'d, T>
where Peri<'d, T>: Unpin,

§

impl<'d, T> UnsafeUnpin for Rtc<'d, T>
where Peri<'d, T>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.