Struct stm32_hal2::rtc::Rtc[][src]

pub struct Rtc { /* fields omitted */ }
Expand description

Real Time Clock peripheral

Implementations

impl Rtc[src]

pub fn new(regs: RTC, rcc: &mut RCC, pwr: &mut PWR, config: RtcConfig) -> Self[src]

Create and enable a new RTC abstraction, 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. Note that if using HSE as the clock source, we assume you’ve already enabled it, eg in clock config.

pub fn set_24h_fmt(&mut self)[src]

Sets calendar clock to 24 hr format

pub fn set_12h_fmt(&mut self)[src]

Sets calendar clock to 12 hr format

pub fn is_24h_fmt(&self) -> bool[src]

Reads current hour format selection

pub fn set_wakeup(&mut self, exti: &mut EXTI, sleep_time: f32)[src]

Setup periodic auto-wakeup interrupts. See ST AN4759, Table 11, and more broadly, section 2.4.1. See also reference manual, section 27.5. In addition to running this function, set up the interrupt handling function by adding the line make_rtc_interrupt_handler!(RTC_WKUP); somewhere in the body of your program. sleep_time is in ms.

pub fn enable_wakeup(&mut self)[src]

Enable the wakeup timer.

pub fn disable_wakeup(&mut self)[src]

Disable the wakeup timer. // todo dry with enable.

pub fn set_wakeup_interval(&mut self, sleep_time: f32)[src]

Change the sleep time for the auto wakeup, after it’s been set up. Sleep time is in MS. Major DRY from set_wakeup.

pub fn clear_wakeup_flag(&mut self)[src]

Clears the wakeup flag. Must be cleared manually after every RTC wakeup. Alternatively, you could call this in the RTC wakeup interrupt handler.

Trait Implementations

impl Rtcc for Rtc[src]

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

set time using NaiveTime (ISO 8601 time without timezone) Hour format is 24h

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

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

type Error = Error

Error type

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

Set the seconds [0-59].

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

Set the minutes [0-59].

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

Set the hours. Read more

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

Set the day of week [1-7].

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

Set the day of month [1-31].

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

Set the month [1-12].

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

Set the year. (e.g. 2000)

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

Set the date and time. Read more

fn get_seconds(&mut self) -> Result<u8, Self::Error>[src]

Read the seconds.

fn get_minutes(&mut self) -> Result<u8, Self::Error>[src]

Read the minutes.

fn get_hours(&mut self) -> Result<Hours, Self::Error>[src]

Read the hours.

fn get_time(&mut self) -> Result<NaiveTime, Self::Error>[src]

Read the time.

fn get_weekday(&mut self) -> Result<u8, Self::Error>[src]

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

fn get_day(&mut self) -> Result<u8, Self::Error>[src]

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

fn get_month(&mut self) -> Result<u8, Self::Error>[src]

Read the month [1-12].

fn get_year(&mut self) -> Result<u16, Self::Error>[src]

Read the year (e.g. 2000).

fn get_date(&mut self) -> Result<NaiveDate, Self::Error>[src]

Read the date.

fn get_datetime(&mut self) -> Result<NaiveDateTime, Self::Error>[src]

Read the date and time.

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.