Struct rp2040_hal::rtc::RealTimeClock

source ·
pub struct RealTimeClock { /* private fields */ }
Expand description

A reference to the real time clock of the system

Implementations§

source§

impl RealTimeClock

source

pub fn new( rtc: RTC, clock: RtcClock, resets: &mut RESETS, initial_date: DateTime ) -> Result<Self, RtcError>

Create a new instance of the real time clock, with the given date as an initial value.

Note that the ClocksManager should be enabled first. See the clocks module for more information.

§Errors

Will return RtcError::InvalidDateTime if the datetime is not a valid range.

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 RealTimeClock is running

source

pub fn set_datetime(&mut self, t: DateTime) -> Result<(), RtcError>

Set the datetime to a new value.

§Errors

Will return RtcError::InvalidDateTime if the datetime is not a valid range.

source

pub fn now(&self) -> Result<DateTime, RtcError>

Return the current datetime.

§Errors

Will return an RtcError::InvalidDateTime if the stored value in the system is not a valid DayOfWeek.

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.

If not all fields are set, the alarm will repeat each time the RTC reaches these values. For example, to fire every minute, set:

real_time_clock.schedule_alarm(DateTimeFilter::default().second(0));

It is worth nothing that the alarm will not fire on schedule if the current time matches.

source

pub fn enable_interrupt(&mut self)

Enable the propagation of alarm to the NVIC.

source

pub fn disable_interrupt(&mut self)

Disable the propagation of the alarm to the NVIC.

source

pub fn clear_interrupt(&mut self)

Clear the interrupt.

This should be called every time the RTC_IRQ interrupt is triggered or the interrupt will continually fire..

source

pub fn free(self, resets: &mut RESETS) -> (RTC, RtcClock)

Free the RTC peripheral and RTC clock

Auto Trait Implementations§

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<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

source§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

source§

fn lift_into(self) -> U

Performs the indexed conversion.
source§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
source§

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

§

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>,

§

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.