Struct Rtc

Source
pub struct Rtc { /* private fields */ }
Available on crate feature rtc only.
Expand description

Real Time Clock peripheral

Implementations§

Source§

impl Rtc

Source

pub fn new( rtc: RTC, prediv_s: u16, prediv_a: u8, bypass: bool, apb1: &mut APB1, bdcr: &mut BDCR, pwr: &mut PWR, ) -> Self

Create and enable a new RTC, and configure its clock source and prescalers. From AN4759, Table 7, when using the LSE (The only clock source this module supports currently), set prediv_s to 255, and prediv_a to 127 to get a calendar clock of 1Hz. The bypass argument is true if you’re using an external oscillator that doesn’t connect to OSC32_IN, such as a MEMS resonator.

Source

pub fn set_24h_fmt(&mut self)

Sets calendar clock to 24 hr format

Source

pub fn set_12h_fmt(&mut self)

Sets calendar clock to 12 hr format

Source

pub fn is_24h_fmt(&self) -> bool

Reads current hour format selection

Source

pub unsafe fn peripheral(&mut self) -> &mut RTC

Get access to the underlying register block.

§Safety

This function is not memory unsafe per se, but does not guarantee anything about assumptions of invariants made in this implementation.

Changing specific options can lead to un-expected behavior and nothing is guaranteed.

Source

pub fn free(self) -> RTC

Release the RTC peripheral

Trait Implementations§

Source§

impl DateTimeAccess for Rtc

Source§

type Error = Error

Error type
Source§

fn set_datetime(&mut self, date: &NaiveDateTime) -> Result<(), Self::Error>

Set the date and time. Read more
Source§

fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>

Read the date and time.
Source§

impl Debug for Rtc

Source§

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

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

impl Rtcc for Rtc

Source§

fn set_time(&mut self, time: &NaiveTime) -> Result<(), Self::Error>

Set time using NaiveTime (ISO 8601 time without timezone)

Hour format is 24h

Source§

fn set_date(&mut self, date: &NaiveDate) -> Result<(), Self::Error>

Set the date using NaiveDate (ISO 8601 calendar date without timezone). WeekDay is set using the set_weekday method

Source§

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

Set the seconds [0-59].
Source§

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

Set the minutes [0-59].
Source§

fn set_hours(&mut self, hours: Hours) -> Result<(), Self::Error>

Set the hours. Read more
Source§

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

Set the day of week [1-7].
Source§

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

Set the day of month [1-31].
Source§

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

Set the month [1-12].
Source§

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

Set the year. (e.g. 2000)
Source§

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

Read the seconds.
Source§

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

Read the minutes.
Source§

fn hours(&mut self) -> Result<Hours, Self::Error>

Read the hours.
Source§

fn time(&mut self) -> Result<NaiveTime, Self::Error>

Read the time.
Source§

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

Read the day of the week [1-7].
Source§

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

Read the day of the month [1-31].
Source§

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

Read the month [1-12].
Source§

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

Read the year (e.g. 2000).
Source§

fn date(&mut self) -> Result<NaiveDate, Self::Error>

Read the date.

Auto Trait Implementations§

§

impl Freeze for Rtc

§

impl RefUnwindSafe for Rtc

§

impl Send for Rtc

§

impl !Sync for Rtc

§

impl Unpin for Rtc

§

impl UnwindSafe for Rtc

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

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.