Struct stm32f1xx_hal::rtc::Rtc

source ·
pub struct Rtc<CS = RtcClkLse> { /* private fields */ }
Expand description

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§

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.

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

Set the current RTC counter value to the specified amount

Sets the time at which an alarm will be triggered

This also clears the alarm flag if it is set

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.

Stops the RTC alarm from triggering the RTC and RTCALARM interrupts

Reads the current counter

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

Disables the RTC second interrupt

Clears the RTC second interrupt flag

Clears the RTC alarm interrupt flag

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§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.