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>
impl<'a> Rtc<'a>
Sourcepub fn new<I: Instance>(
_inst: Peri<'a, I>,
_irq: impl Binding<I::Interrupt, InterruptHandler<I>> + 'a,
config: RtcConfig,
) -> Self
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.
Sourcepub fn set_datetime(&self, datetime: RtcDateTime)
pub fn set_datetime(&self, datetime: RtcDateTime)
Sourcepub fn get_datetime(&self) -> RtcDateTime
pub fn get_datetime(&self) -> RtcDateTime
Sourcepub fn set_alarm(&self, alarm: RtcDateTime)
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
Sourcepub fn get_alarm(&self) -> RtcDateTime
pub fn get_alarm(&self) -> RtcDateTime
Sourcepub fn set_interrupt(&self, mask: u32)
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
Sourcepub fn disable_interrupt(&self, mask: u32)
pub fn disable_interrupt(&self, mask: u32)
Sourcepub fn clear_alarm_flag(&self)
pub fn clear_alarm_flag(&self)
Sourcepub async fn wait_for_alarm(&mut self, alarm: RtcDateTime)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more