Skip to main content

Pcf8563Async

Struct Pcf8563Async 

Source
pub struct Pcf8563Async<I2CImpl: RegisterInterface<AddressType = u8, Error = RtcError<I2CBusErr>>, I2CBusErr: Debug> {
    pub ll: Pcf8563LowLevel<I2CImpl>,
    /* private fields */
}

Fields§

§ll: Pcf8563LowLevel<I2CImpl>

Implementations§

Source§

impl<I2CBus, E> Pcf8563<Pcf8563Interface<I2CBus>, E>
where I2CBus: I2c<Error = E>, E: Debug,

Source

pub fn new(i2c: I2CBus) -> Self

Source§

impl<I2CImpl, I2CBusErr> Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: RegisterInterface<AddressType = u8, Error = RtcError<I2CBusErr>>, I2CBusErr: Debug,

Source

pub async fn get_datetime(&mut self) -> Result<DateTime, RtcError<I2CBusErr>>

Get the current date and time

Reads all 7 time/date registers (0x02-0x08) in a single I2C burst read, as recommended by the datasheet to ensure consistency.

Source

pub async fn set_datetime( &mut self, dt: &DateTime, ) -> Result<(), RtcError<I2CBusErr>>

Set the date and time

Writes all 7 time/date registers (0x02-0x08) in a single I2C burst write. Also clears the VL (voltage-low) flag.

Source

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

Set only the time (hours, minutes, seconds)

Source

pub async fn is_clock_valid(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Check if clock integrity is guaranteed

Returns false if the VL (Voltage Low) flag is set, indicating the clock data may be invalid due to power loss.

Source

pub async fn clear_voltage_low_flag( &mut self, ) -> Result<(), RtcError<I2CBusErr>>

Clear the voltage-low flag

Should be called after setting the time to indicate clock is valid.

Source

pub async fn get_century_flag(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Get the century flag

Returns true if century is X+1 (e.g., 2100s), false if century is X (e.g., 2000s)

Source

pub async fn set_century_flag( &mut self, century: bool, ) -> Result<(), RtcError<I2CBusErr>>

Set the century flag

Source

pub async fn set_clock_running( &mut self, running: bool, ) -> Result<(), RtcError<I2CBusErr>>

Start or stop the RTC clock

Source

pub async fn is_clock_running(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Check if the RTC clock is running

Source

pub async fn get_alarm(&mut self) -> Result<Alarm, RtcError<I2CBusErr>>

Get the current alarm configuration

Source

pub async fn set_alarm( &mut self, alarm: &Alarm, ) -> Result<(), RtcError<I2CBusErr>>

Set the alarm configuration

Set a field to Some(value) to enable that alarm component, or None to disable it.

Source

pub async fn disable_alarm(&mut self) -> Result<(), RtcError<I2CBusErr>>

Disable all alarm components

Source

pub async fn get_alarm_flag(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Check if alarm flag is set (alarm has triggered)

Source

pub async fn clear_alarm_flag(&mut self) -> Result<(), RtcError<I2CBusErr>>

Clear the alarm flag

Source

pub async fn set_alarm_interrupt( &mut self, enable: bool, ) -> Result<(), RtcError<I2CBusErr>>

Enable or disable alarm interrupt

Source

pub async fn is_alarm_interrupt_enabled( &mut self, ) -> Result<bool, RtcError<I2CBusErr>>

Check if alarm interrupt is enabled

Source

pub async fn set_timer_value( &mut self, value: u8, ) -> Result<(), RtcError<I2CBusErr>>

Set the timer countdown value (0-255)

Source

pub async fn get_timer_value(&mut self) -> Result<u8, RtcError<I2CBusErr>>

Get the current timer countdown value

Source

pub async fn set_timer_frequency( &mut self, freq: TimerFrequency, ) -> Result<(), RtcError<I2CBusErr>>

Set the timer source clock frequency

Source

pub async fn get_timer_frequency( &mut self, ) -> Result<TimerFrequency, RtcError<I2CBusErr>>

Get the timer source clock frequency

Source

pub async fn set_timer_enabled( &mut self, enable: bool, ) -> Result<(), RtcError<I2CBusErr>>

Enable or disable the timer

Source

pub async fn is_timer_enabled(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Check if timer is enabled

Source

pub async fn get_timer_flag(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Check if timer flag is set (timer has triggered)

Source

pub async fn clear_timer_flag(&mut self) -> Result<(), RtcError<I2CBusErr>>

Clear the timer flag

Source

pub async fn set_timer_interrupt( &mut self, enable: bool, ) -> Result<(), RtcError<I2CBusErr>>

Enable or disable timer interrupt

Source

pub async fn is_timer_interrupt_enabled( &mut self, ) -> Result<bool, RtcError<I2CBusErr>>

Check if timer interrupt is enabled

Source

pub async fn set_timer_interrupt_pulse_mode( &mut self, pulse: bool, ) -> Result<(), RtcError<I2CBusErr>>

Set timer interrupt mode (level or pulse)

Source

pub async fn set_clkout_enabled( &mut self, enable: bool, ) -> Result<(), RtcError<I2CBusErr>>

Enable or disable the CLKOUT output

Source

pub async fn is_clkout_enabled(&mut self) -> Result<bool, RtcError<I2CBusErr>>

Check if CLKOUT is enabled

Source

pub async fn set_clkout_frequency( &mut self, freq: ClkoutFrequency, ) -> Result<(), RtcError<I2CBusErr>>

Set the CLKOUT frequency

Source

pub async fn get_clkout_frequency( &mut self, ) -> Result<ClkoutFrequency, RtcError<I2CBusErr>>

Get the CLKOUT frequency setting

Source

pub async fn init(&mut self) -> Result<(), RtcError<I2CBusErr>>

Initialize the RTC with default settings

  • Clears all control bits
  • Clears voltage-low flag
  • Disables all alarms
  • Sets timer to lowest frequency (1/60 Hz) for power saving

Auto Trait Implementations§

§

impl<I2CImpl, I2CBusErr> Freeze for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: Freeze,

§

impl<I2CImpl, I2CBusErr> RefUnwindSafe for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: RefUnwindSafe, I2CBusErr: RefUnwindSafe,

§

impl<I2CImpl, I2CBusErr> Send for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: Send, I2CBusErr: Send,

§

impl<I2CImpl, I2CBusErr> Sync for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: Sync, I2CBusErr: Sync,

§

impl<I2CImpl, I2CBusErr> Unpin for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: Unpin, I2CBusErr: Unpin,

§

impl<I2CImpl, I2CBusErr> UnsafeUnpin for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: UnsafeUnpin,

§

impl<I2CImpl, I2CBusErr> UnwindSafe for Pcf8563<I2CImpl, I2CBusErr>
where I2CImpl: UnwindSafe, I2CBusErr: 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>,

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.