Rtc

Struct Rtc 

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

The System Real Time Clock structure for aarch64 based on PL031.

Implementations§

Source§

impl Rtc

Source

pub fn get_time(&self) -> DateTime<Utc>

Returns the current time.

Source

pub fn set_time(&mut self, time: DateTime<Utc>) -> Result<(), TryFromIntError>

Sets the current time.

Returns an error if the given time is beyond the bounds supported by the RTC.

Source

pub fn set_match( &mut self, match_time: DateTime<Utc>, ) -> Result<(), TryFromIntError>

Sets the match register to the given time. When the RTC value matches this then an interrupt will be generated (if it is enabled).

Source§

impl Rtc

Source

pub unsafe fn new(base_address: *mut u32) -> Self

Constructs a new instance of the RTC driver for a PL031 device at the given base address.

The base address may be obtained from the device tree.

§Safety

The given base address must point to the MMIO control registers of a PL031 device, which must be mapped into the address space of the process as device memory and not have any other aliases. It must be aligned to a 4 byte boundary.

Source

pub fn get_unix_timestamp(&self) -> u32

Returns the current time in seconds since UNIX epoch.

Source

pub fn set_unix_timestamp(&mut self, unix_time: u32)

Sets the current time in seconds since UNIX epoch.

Source

pub fn set_match_timestamp(&mut self, match_timestamp: u32)

Writes a match value. When the RTC value matches this then an interrupt will be generated (if it is enabled).

Source

pub fn matched(&self) -> bool

Returns whether the match register matches the RTC value, whether or not the interrupt is enabled.

Source

pub fn interrupt_pending(&self) -> bool

Returns whether there is currently an interrupt pending.

This should be true if and only if matched returns true and the interrupt is masked.

Source

pub fn enable_interrupt(&mut self, mask: bool)

Sets or clears the interrupt mask.

When the mask is true the interrupt is enabled; when it is false the interrupt is disabled.

Source

pub fn clear_interrupt(&mut self)

Clears a pending interrupt, if any.

Trait Implementations§

Source§

impl Send for Rtc

Source§

impl Sync for Rtc

Auto Trait Implementations§

§

impl Freeze for Rtc

§

impl RefUnwindSafe 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.