[][src]Struct stm32f1xx_hal::rtc::Rtc

pub struct Rtc { /* fields omitted */ }

Real time clock

A continuously running clock that counts seconds¹. It is part of the backup domain which means that the counter is not affected by system resets or standby mode. If Vbat is connected, it is not reset even if the rest of the device is powered off. This allows it to be used to wake the CPU when it is in low power mode.

See examples/rtc.rs and examples/blinky_rtc.rs for usage examples.

1: Unless configured to another frequency using select_frequency

Implementations

impl Rtc[src]

pub fn rtc(regs: RTC, bkp: &mut BackupDomain) -> Self[src]

Initialises the RTC. The BackupDomain struct is created by Rcc.bkp.constrain().

The frequency is set to 1 Hz.

Since the RTC is part of the backup domain, The RTC counter is not reset by normal resets or power cycles where (VBAT) still has power. Use set_time if you want to reset the counter.

pub fn select_frequency(&mut self, timeout: impl Into<Hertz>)[src]

Selects the frequency of the RTC Timer NOTE: Maximum frequency of 16384 Hz using the internal LSE

pub fn set_time(&mut self, counter_value: u32)[src]

Set the current RTC counter value to the specified amount

pub fn set_alarm(&mut self, counter_value: u32)[src]

Sets the time at which an alarm will be triggered

This also clears the alarm flag if it is set

pub fn listen_alarm(&mut self)[src]

Enables the RTC interrupt to trigger when the counter reaches the alarm value. In addition, if the EXTI controller has been set up correctly, this function also enables the RTCALARM interrupt.

pub fn unlisten_alarm(&mut self)[src]

Stops the RTC alarm from triggering the RTC and RTCALARM interrupts

pub fn current_time(&self) -> u32[src]

Reads the current counter

pub fn listen_seconds(&mut self)[src]

Enables triggering the RTC interrupt every time the RTC counter is increased

pub fn unlisten_seconds(&mut self)[src]

Disables the RTC second interrupt

pub fn clear_second_flag(&mut self)[src]

Clears the RTC second interrupt flag

pub fn clear_alarm_flag(&mut self)[src]

Clears the RTC alarm interrupt flag

pub fn wait_alarm(&mut self) -> Result<(), Infallible>[src]

Return Ok(()) if the alarm flag is set, Err(nb::WouldBlock) otherwise.

use nb::block;

rtc.set_alarm(rtc.read_counts() + 5);
// NOTE: Safe unwrap because Infallible can't be returned
block!(rtc.wait_alarm()).unwrap();

Auto Trait Implementations

impl Send for Rtc

impl !Sync for Rtc

impl Unpin for Rtc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.