embassy-stm32

Crates

git

Versions

stm32g471re

Flavors

Skip to main content

Rtc

Struct Rtc 

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

RTC driver.

Implementations§

Source§

impl Rtc<'_>

Source

pub fn calibrate(&mut self, clock_drift: f32, period: RtcCalibrationCyclePeriod)

Calibrate the clock drift.

clock_drift can be adjusted from -487.1 ppm to 488.5 ppm and is clamped to this range.

§Note

To perform a calibration when async_prescaler is less then 3, sync_prescaler has to be reduced accordingly (see RM0351 Rev 9, sec 38.3.12).

Source§

impl<'d> Rtc<'d>

Source

pub const BACKUP_REGISTER_COUNT: usize = RTC::BACKUP_REGISTER_COUNT

Number of backup registers of this instance.

Source

pub fn new(peri: Peri<'d, RTC>, rtc_config: RtcConfig) -> Self

Create a new RTC instance.

The date and time are kept. If the RTC does not already run with the prescalers for rtc_config, they are written, which restarts the current second.

With the low-power feature and a time driver that is not a low-power timer, embassy_stm32::init already configures the RTC with Config::rtc to measure the time spent in Stop mode. Pass the same configuration here to keep it.

Source

pub fn reader(&self) -> RtcReader<'d>

Get a reader for the current date and time.

Use it to read the time from other tasks, while the Rtc is used to set it.

Source

pub fn read_raw(&self) -> RawDateTime

Read the raw contents of the RTC calendar registers. See RtcReader::read_raw.

Source

pub fn set_raw(&mut self, t: RawDateTime)

Write raw values to the RTC calendar registers.

See RawDateTime: the values are not validated, and subsecond is ignored. This function sets subseconds to 0.

Source

pub fn synchronize(&mut self, shift: f32)

Synchronize to a remote clock with a high degree of precision.

shift should be adjusted from -1 to 1 second.

Source

pub fn get_daylight_savings(&self) -> bool

Check if daylight savings time is active.

Source

pub fn set_daylight_savings(&mut self, daylight_savings: bool)

Enable/disable daylight savings time.

Source

pub fn read_backup_register(&self, register: usize) -> Option<u32>

Read content of the backup register.

The registers retain their values during wakes from standby mode or system resets. They also retain their value when Vdd is switched off as long as V_BAT is powered.

Always returns None. Use the TAMP peripheral instead.

Source

pub fn write_backup_register(&self, register: usize, value: u32)

Set content of the backup register.

The registers retain their values during wakes from standby mode or system resets. They also retain their value when Vdd is switched off as long as V_BAT is powered.

Does not write to the register. Use the TAMP peripheral instead.

Auto Trait Implementations§

§

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

§

impl<'d> Forget for Rtc<'d>

§

impl<'d> Freeze for Rtc<'d>

§

impl<'d> Move for Rtc<'d>

§

impl<'d> RefUnwindSafe for Rtc<'d>

§

impl<'d> Send for Rtc<'d>

§

impl<'d> Sync for Rtc<'d>

§

impl<'d> Unpin for Rtc<'d>

§

impl<'d> UnsafeUnpin for Rtc<'d>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.