Struct stm32f4xx_hal::rtc::Rtc

source ·
pub struct Rtc<CS: FrequencySource = Lse> {
    pub regs: RTC,
    /* private fields */
}
Expand description

Real Time Clock peripheral

Fields§

§regs: RTC

RTC Peripheral register

Implementations§

source§

impl Rtc<Lse>

source

pub fn new(regs: RTC, pwr: &mut PWR) -> Self

Create and enable a new RTC with external crystal or ceramic resonator and default prescalers.

source

pub fn with_config( regs: RTC, pwr: &mut PWR, mode: LSEClockMode, prediv_s: u16, prediv_a: u8 ) -> Self

Create and enable a new RTC, and configure its clock source and prescalers.

From AN3371, Table 3, when using the LSE, set prediv_s to 255, and prediv_a to 127 to get a calendar clock of 1Hz.

source§

impl Rtc<Lsi>

source

pub fn new_lsi(regs: RTC, pwr: &mut PWR) -> Self

Create and enable a new RTC with internal crystal and default prescalers.

source

pub fn lsi_with_config( regs: RTC, pwr: &mut PWR, prediv_s: u16, prediv_a: u8 ) -> Self

Create and enable a new RTC, and configure its clock source and prescalers.

From AN3371, Table 3, when using the LSI, set prediv_s to 249, and prediv_a to 127 to get a calendar clock of 1Hz.

source§

impl<CS: FrequencySource> Rtc<CS>

source

pub fn set_prescalers(&mut self, prediv_s: u16, prediv_a: u8)

source

pub fn set_time(&mut self, time: &Time) -> Result<(), Error>

Set the time using time::Time.

source

pub fn set_seconds(&mut self, seconds: u8) -> Result<(), Error>

Set the seconds [0-59].

source

pub fn set_minutes(&mut self, minutes: u8) -> Result<(), Error>

Set the minutes [0-59].

source

pub fn set_hours(&mut self, hours: u8) -> Result<(), Error>

Set the hours [0-23].

source

pub fn set_weekday(&mut self, weekday: u8) -> Result<(), Error>

Set the day of week [1-7].

source

pub fn set_day(&mut self, day: u8) -> Result<(), Error>

Set the day of month [1-31].

source

pub fn set_month(&mut self, month: u8) -> Result<(), Error>

Set the month [1-12].

source

pub fn set_year(&mut self, year: u16) -> Result<(), Error>

Set the year [1970-2069].

The year cannot be less than 1970, since the Unix epoch is assumed (1970-01-01 00:00:00). Also, the year cannot be greater than 2069 since the RTC range is 0 - 99.

source

pub fn set_date(&mut self, date: &Date) -> Result<(), Error>

Set the date.

The year cannot be less than 1970, since the Unix epoch is assumed (1970-01-01 00:00:00). Also, the year cannot be greater than 2069 since the RTC range is 0 - 99.

source

pub fn set_datetime(&mut self, date: &PrimitiveDateTime) -> Result<(), Error>

Set the date and time.

The year cannot be less than 1970, since the Unix epoch is assumed (1970-01-01 00:00:00). Also, the year cannot be greater than 2069 since the RTC range is 0 - 99.

source

pub fn get_datetime(&mut self) -> PrimitiveDateTime

source

pub fn enable_wakeup(&mut self, interval: MicrosDurationU64)

Configures the wakeup timer to trigger periodically every interval duration

§Panics

Panics if interval is greater than 2¹⁷-1 seconds.

source

pub fn disable_wakeup(&mut self)

Disables the wakeup timer

source

pub fn enable_vbat_timestamp(&mut self)

Configures the timestamp to be captured when the RTC switches to Vbat power

source

pub fn disable_timestamp(&mut self)

Disables the timestamp

source

pub fn read_timestamp(&self) -> PrimitiveDateTime

Reads the stored value of the timestamp if present

Clears the timestamp interrupt flags.

source

pub fn set_alarm( &mut self, alarm: Alarm, date: impl Into<AlarmDay>, time: Time ) -> Result<(), Error>

Sets the time at which an alarm will be triggered This also clears the alarm flag if it is set

source

pub fn listen(&mut self, exti: &mut EXTI, event: Event)

Start listening for event

source

pub fn unlisten(&mut self, exti: &mut EXTI, event: Event)

Stop listening for event

source

pub fn is_pending(&self, event: Event) -> bool

Returns true if event is pending

source

pub fn clear_interrupt(&mut self, event: Event)

Clears the interrupt flag for event

Trait Implementations§

source§

impl Debug for Rtc

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Format for Rtc

source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

§

impl<CS> Freeze for Rtc<CS>

§

impl<CS> RefUnwindSafe for Rtc<CS>
where CS: RefUnwindSafe,

§

impl<CS> Send for Rtc<CS>
where CS: Send,

§

impl<CS = Lse> !Sync for Rtc<CS>

§

impl<CS> Unpin for Rtc<CS>
where CS: Unpin,

§

impl<CS> UnwindSafe for Rtc<CS>
where CS: UnwindSafe,

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>,

§

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>,

§

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.