Struct Rtc

Source
pub struct Rtc { /* private fields */ }
Expand description

Represents a Real Time Clock (RTC) peripheral.

Implementations§

Source§

impl Rtc

Source

pub fn new(regs: RTC, config: RtcConfig) -> Result<Self>

Initialize the RTC, including configuration register writes.

Source

pub fn set_24h_fmt(&mut self) -> Result<()>

Sets calendar clock to 24 hr format

Source

pub fn set_12h_fmt(&mut self) -> Result<()>

Sets calendar clock to 12 hr format

Source

pub fn is_24h_fmt(&self) -> bool

Reads current hour format selection

Source

pub fn set_wakeup(&mut self, sleep_time: f32) -> Result<()>

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.

Source

pub fn enable_wakeup(&mut self)

Enable the wakeup timer.

Source

pub fn disable_wakeup(&mut self)

Disable the wakeup timer.

Source

pub fn set_wakeup_interval(&mut self, sleep_time: f32) -> Result<()>

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

Source

pub fn clear_wakeup_flag(&mut self) -> Result<()>

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

Source

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

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

Source

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

Set the seconds component of the RTC’s current time.

Source

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

Set the minutes component of the RTC’s current time.

Source

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

Set the hours component of the RTC’s current time.

Source

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

Set the weekday component of the RTC’s current date.

Source

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

Set the day component of the RTC’s current date.

Source

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

Set the month component of the RTC’s current date.

Source

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

Set the year component of the RTC’s current date.

Source

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

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

Source

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

Set the current datetime.

Source

pub fn get_seconds(&mut self) -> u8

Get the seconds component of the current time.

Source

pub fn get_minutes(&mut self) -> u8

Get the minutes component of the current time.

Source

pub fn get_hours(&mut self) -> u8

Get the hours component of the current time.

Source

pub fn get_time(&mut self) -> NaiveTime

Get the current time.

Source

pub fn get_weekday(&mut self) -> u8

Get the weekday component of the current date.

Source

pub fn get_day(&mut self) -> u8

Get the day component of the current date.

Source

pub fn get_month(&mut self) -> u8

Get the month component of the current date.

Source

pub fn get_year(&mut self) -> u16

Get the year component of the current date.

Source

pub fn get_date(&mut self) -> NaiveDate

Get the current date.

Source

pub fn get_datetime(&mut self) -> NaiveDateTime

Get the current datetime.

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.