embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

Rtc

Struct Rtc 

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

Minimal RTC handle for a specific instance I (store the zero-sized token like embassy)

Implementations§

Source§

impl<'a> Rtc<'a>

Source

pub fn new<I: Instance>( _inst: Peri<'a, I>, _irq: impl Binding<I::Interrupt, InterruptHandler<I>> + 'a, config: RtcConfig, ) -> Self

Create a new instance of the real time clock.

Source

pub fn set_datetime(&self, datetime: RtcDateTime)

Set the current date and time

§Arguments
  • datetime - The date and time to set
§Note

The datetime is converted to Unix timestamp and written to the time seconds register.

Source

pub fn get_datetime(&self) -> RtcDateTime

Get the current date and time

§Returns

Current date and time as RtcDateTime

§Note

Reads the current Unix timestamp from the time seconds register and converts it.

Source

pub fn set_alarm(&self, alarm: RtcDateTime)

Set the alarm date and time

§Arguments
  • alarm - The date and time when the alarm should trigger
§Note

This function:

  • Clears any existing alarm by writing 0 to the alarm register
  • Waits for the clear operation to complete
  • Sets the new alarm time
  • Waits for the write operation to complete
  • Uses timeouts to prevent infinite loops
  • Enables the alarm interrupt after setting
Source

pub fn get_alarm(&self) -> RtcDateTime

Get the current alarm date and time

§Returns

Alarm date and time as RtcDateTime

§Note

Reads the alarm timestamp from the time alarm register and converts it.

Source

pub fn start(&self)

Start the RTC time counter

§Note

Sets the Time Counter Enable (TCE) bit in the status register.

Source

pub fn stop(&self)

Stop the RTC time counter

§Note

Clears the Time Counter Enable (TCE) bit in the status register.

Source

pub fn set_interrupt(&self, mask: u32)

Enable specific RTC interrupts

§Arguments
  • mask - Bitmask of interrupts to enable (use RtcInterruptEnable constants)
§Note

This function enables the specified interrupt types and resets the alarm occurred flag. Available interrupts:

  • Time Invalid Interrupt
  • Time Overflow Interrupt
  • Alarm Interrupt
  • Seconds Interrupt
Source

pub fn disable_interrupt(&self, mask: u32)

Disable specific RTC interrupts

§Arguments
  • mask - Bitmask of interrupts to disable (use RtcInterruptEnable constants)
§Note

This function disables the specified interrupt types.

Source

pub fn clear_alarm_flag(&self)

Clear the alarm interrupt flag

§Note

This function clears the Time Alarm Interrupt Enable bit.

Source

pub async fn wait_for_alarm(&mut self, alarm: RtcDateTime)

Wait for an RTC alarm to trigger.

§Arguments
  • alarm - The date and time when the alarm should trigger

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

Auto Trait Implementations§

§

impl<'a> Freeze for Rtc<'a>

§

impl<'a> !RefUnwindSafe for Rtc<'a>

§

impl<'a> !Send for Rtc<'a>

§

impl<'a> !Sync for Rtc<'a>

§

impl<'a> Unpin for Rtc<'a>

§

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

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.