Struct Rtc

Source
pub struct Rtc<Mode: RtcMode> { /* private fields */ }
Expand description

Represents the RTC peripheral for either clock/calendar or timer mode.

Implementations§

Source§

impl<Mode: RtcMode> Rtc<Mode>

Source

pub fn into_count32_mode(self) -> Rtc<Count32Mode>

Reconfigures the RTC for 32-bit counter mode with no prescaler (default state after reset) and the counter initialized to zero and started.

Source

pub fn into_clock_mode(self) -> Rtc<ClockMode>

Reconfigures the peripheral for clock/calendar mode. Requires the source clock to be running at 1024 Hz.

Source

pub fn free(self) -> Rtc

Releases the RTC resource

Source§

impl Rtc<Count32Mode>

Source

pub fn count32_mode(rtc: Rtc, rtc_clock_freq: Hertz, pm: &mut Pm) -> Self

Configures the RTC in 32-bit counter mode with no prescaler (default state after reset) and the counter initialized to zero and started.

Source

pub fn count32(&self) -> u32

Returns the internal counter value.

Source

pub fn set_count32(&mut self, count: u32)

Sets the internal counter value.

Source

pub fn reset_and_compute_prescaler<T: Into<Nanoseconds>>( &mut self, timeout: T, ) -> &Self

This resets the internal counter, sets the prescaler to match the provided timeout, and starts the counter. You should configure the prescaler using the longest timeout you plan to measure.

Source§

impl Rtc<ClockMode>

Source

pub fn clock_mode(rtc: Rtc, rtc_clock_freq: Hertz, pm: &mut Pm) -> Self

Source

pub fn current_time(&self) -> Datetime

Returns the current clock/calendar value.

Source

pub fn set_time(&mut self, time: Datetime)

Updates the current clock/calendar value.

Trait Implementations§

Source§

impl DelayNs for Rtc<Count32Mode>

Source§

fn delay_ns(&mut self, ns: u32)

Pauses execution for at minimum ns nanoseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

fn delay_us(&mut self, us: u32)

Pauses execution for at minimum us microseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

fn delay_ms(&mut self, ms: u32)

Pauses execution for at minimum ms milliseconds. Pause can be longer if the implementation requires it due to precision/timing issues.
Source§

impl InterruptDrivenTimer for Rtc<Count32Mode>

Source§

fn enable_interrupt(&mut self)

Enable the interrupt generation for this hardware timer. This method only sets the clock configuration to trigger the interrupt; it does not configure the interrupt controller or define an interrupt handler.

Source§

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

Starts the timer and puts it in periodic mode in which the counter counts up to the specified timeout and then resets repeatedly back to zero.

Source§

fn disable_interrupt(&mut self)

Disables interrupt generation for this hardware timer. This method only sets the clock configuration to prevent triggering the interrupt; it does not configure the interrupt controller.

Source§

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

Wait for the timer to finish counting down without blocking.
Source§

impl Monotonic for Rtc<Count32Mode>

Source§

type Instant = Instant<u32, 1, CLOCK_FREQ>

The type for instant, defining an instant in time. Read more
Source§

type Duration = Duration<u32, 1, CLOCK_FREQ>

The type for duration, defining an duration of time. Read more
Source§

unsafe fn reset(&mut self)

Optionally resets the counter to zero for a fixed baseline in a system. Read more
Source§

fn now(&mut self) -> Self::Instant

Get the current time.
Source§

fn zero() -> Self::Instant

The time at time zero. Used by RTIC before the monotonic has been initialized.
Source§

fn set_compare(&mut self, instant: Self::Instant)

Set the compare value of the timer interrupt. Read more
Source§

fn clear_compare_flag(&mut self)

Clear the compare interrupt flag.
Source§

const DISABLE_INTERRUPT_ON_EMPTY_QUEUE: bool = true

This tells RTIC if it should disable the interrupt bound to the monotonic if there are no scheduled tasks. One may want to set this to false if one is using the on_interrupt method to perform housekeeping and need overflow interrupts to happen, such as when extending a 16 bit timer to 32/64 bits, even if there are no scheduled tasks.
Source§

fn on_interrupt(&mut self)

Optional. Commonly used for performing housekeeping of a timer when it has been extended, e.g. a 16 bit timer extended to 32/64 bits. This will be called at the end of the interrupt handler after all other operations have finished.
Source§

fn enable_timer(&mut self)

Optional. This is used to save power, this is called when the Monotonic interrupt is enabled.
Source§

fn disable_timer(&mut self)

Optional. This is used to save power, this is called when the Monotonic interrupt is disabled.
Source§

impl CountDown for Rtc<Count32Mode>

Source§

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

Starts the timer and puts it in periodic mode in which the counter counts up to the specified timeout and then resets repeatedly back to zero.

Source§

type Time = Duration<u32, 1, 1000000000>

The unit of time used by this timer
Source§

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

Non-blockingly “waits” until the count down finishes Read more
Source§

impl Periodic for Rtc<Count32Mode>

Auto Trait Implementations§

§

impl<Mode> Freeze for Rtc<Mode>

§

impl<Mode> RefUnwindSafe for Rtc<Mode>
where Mode: RefUnwindSafe,

§

impl<Mode> Send for Rtc<Mode>
where Mode: Send,

§

impl<Mode> !Sync for Rtc<Mode>

§

impl<Mode> Unpin for Rtc<Mode>
where Mode: Unpin,

§

impl<Mode> UnwindSafe for Rtc<Mode>
where Mode: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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.