pub struct Mcp794xx<DI, IC> { /* private fields */ }
Expand description
MCP794xx RTCC driver
Implementations
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
IC: WithBatteryPower,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
IC: WithBatteryPower,
sourcepub fn has_power_failed(&mut self) -> Result<bool, Error<E>>
pub fn has_power_failed(&mut self) -> Result<bool, Error<E>>
Returns whether the primary power has failed.
sourcepub fn clear_power_failed(&mut self) -> Result<(), Error<E>>
pub fn clear_power_failed(&mut self) -> Result<(), Error<E>>
Clears the power failed status flag and power-fail time-stamp registers.
sourcepub fn get_power_down_datetime(&mut self) -> Result<PowerFailDateTime, Error<E>>
pub fn get_power_down_datetime(&mut self) -> Result<PowerFailDateTime, Error<E>>
Returns date/time when the power failed went down (under Vtrip).
Note that the registers need to be cleared by calling
clear_power_failed()
sourcepub fn get_power_up_datetime(&mut self) -> Result<PowerFailDateTime, Error<E>>
pub fn get_power_up_datetime(&mut self) -> Result<PowerFailDateTime, Error<E>>
Returns date/time when the power went back up (above Vtrip).
Note that the registers need to be cleared by calling
clear_power_failed()
sourcepub fn enable_backup_battery_power(&mut self) -> Result<(), Error<E>>
pub fn enable_backup_battery_power(&mut self) -> Result<(), Error<E>>
Enable usage of backup battery power.
Note that this clears the power failed flag.
sourcepub fn disable_backup_battery_power(&mut self) -> Result<(), Error<E>>
pub fn disable_backup_battery_power(&mut self) -> Result<(), Error<E>>
Disable usage of backup battery power (default).
Note that this clears the power failed flag.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
sourcepub fn set_alarm(
&mut self,
alarm: Alarm,
when: AlarmDateTime,
matching: AlarmMatching,
polarity: AlarmOutputPinPolarity
) -> Result<(), Error<E>>
pub fn set_alarm(
&mut self,
alarm: Alarm,
when: AlarmDateTime,
matching: AlarmMatching,
polarity: AlarmOutputPinPolarity
) -> Result<(), Error<E>>
Set alarm for date/time with a trigger rate and an output pin polarity.
Note that this clears the alarm has matched flag and the alarm needs to be enabled separately. Note that the output pin polarity will be set to the same value for both alarms.
sourcepub fn has_alarm_matched(&mut self, alarm: Alarm) -> Result<bool, Error<E>>
pub fn has_alarm_matched(&mut self, alarm: Alarm) -> Result<bool, Error<E>>
Returns whether the alarm has matched.
Once this is true, it will stay as such until cleared. e.g. with
clear_alarm_matched_flag()
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: ReadData<Error = Error<E>>,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: ReadData<Error = Error<E>>,
sourcepub fn is_leap_year(&mut self) -> Result<bool, Error<E>>
pub fn is_leap_year(&mut self) -> Result<bool, Error<E>>
Returns whether the current year is a leap year.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
sourcepub fn read_sram_byte(&mut self, address: u8) -> Result<u8, Error<E>>
pub fn read_sram_byte(&mut self, address: u8) -> Result<u8, Error<E>>
Read a single byte from an address.
Valid addresses are from 0x20 to 0x5F. Otherwise an Error::InvalidInputData will be returned.
sourcepub fn write_sram_byte(&mut self, address: u8, data: u8) -> Result<(), Error<E>>
pub fn write_sram_byte(&mut self, address: u8, data: u8) -> Result<(), Error<E>>
Write a single byte to an address.
Valid addresses are from 0x20 to 0x5F. Otherwise an Error::InvalidInputData will be returned.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: ReadCurrent<Error = Error<E>>,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: ReadCurrent<Error = Error<E>>,
sourcepub fn read_sram_current_byte(&mut self) -> Result<u8, Error<E>>
pub fn read_sram_current_byte(&mut self) -> Result<u8, Error<E>>
Read a single byte from the current address.
The current address corresponds to the last accessed address (including addresses accessed in EEPROM) incremented by 1.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
sourcepub fn enable(&mut self) -> Result<(), Error<E>>
pub fn enable(&mut self) -> Result<(), Error<E>>
Enable the oscillator (set the clock running).
sourcepub fn disable(&mut self) -> Result<(), Error<E>>
pub fn disable(&mut self) -> Result<(), Error<E>>
Disable the oscillator (stops the clock) (default).
sourcepub fn is_oscillator_running(&mut self) -> Result<bool, Error<E>>
pub fn is_oscillator_running(&mut self) -> Result<bool, Error<E>>
Returns whether the oscillator is running.
sourcepub fn enable_external_oscillator(&mut self) -> Result<(), Error<E>>
pub fn enable_external_oscillator(&mut self) -> Result<(), Error<E>>
Enable usage of external oscillator source.
sourcepub fn disable_external_oscillator(&mut self) -> Result<(), Error<E>>
pub fn disable_external_oscillator(&mut self) -> Result<(), Error<E>>
Disable usage of external oscillator source (Will use internal source).
sourcepub fn enable_square_wave(&mut self) -> Result<(), Error<E>>
pub fn enable_square_wave(&mut self) -> Result<(), Error<E>>
Enable square-wave output.
Note that this is not available when running on backup battery power.
sourcepub fn disable_square_wave(&mut self) -> Result<(), Error<E>>
pub fn disable_square_wave(&mut self) -> Result<(), Error<E>>
Disable square-wave output.
sourcepub fn set_square_wave_frequency(
&mut self,
frequency: SqWFreq
) -> Result<(), Error<E>>
pub fn set_square_wave_frequency(
&mut self,
frequency: SqWFreq
) -> Result<(), Error<E>>
Set square-wave output frequency.
Note that this setting will be ignored if the square-wave output is not enabled or digital trimming is enabled.
sourcepub fn set_output_pin(&mut self, level: OutputPinLevel) -> Result<(), Error<E>>
pub fn set_output_pin(&mut self, level: OutputPinLevel) -> Result<(), Error<E>>
Set output pin logic level.
Note that this setting will be ignored if the square-wave output or any of the alarm interrupt outputs are enabled.
sourcepub fn enable_coarse_trim(&mut self) -> Result<(), Error<E>>
pub fn enable_coarse_trim(&mut self) -> Result<(), Error<E>>
Enable coarse trim mode.
sourcepub fn disable_coarse_trim(&mut self) -> Result<(), Error<E>>
pub fn disable_coarse_trim(&mut self) -> Result<(), Error<E>>
Disable coarse trim mode.
sourcepub fn set_trimming(&mut self, value: i8) -> Result<(), Error<E>>
pub fn set_trimming(&mut self, value: i8) -> Result<(), Error<E>>
Set digital trimming value.
The sign determines whether the value will be added or substracted to or from the 32.768kHz clock signal. The argument value is always multiplied by two, so a value of 127 will add 254 clock cycles and a value of -50 will substract 100 cycles. Depending on the digital trimming setting, this will be applied either once per minute or 128 times per second. Set to 0 or -128 to disable digital trimming.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
IC: WithProtectedEeprom,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
IC: WithProtectedEeprom,
sourcepub fn read_protected_eeprom_byte(&mut self, address: u8) -> Result<u8, Error<E>>
pub fn read_protected_eeprom_byte(&mut self, address: u8) -> Result<u8, Error<E>>
Read a single byte from an address in the protected EEPROM.
Valid addresses are in the range [0xF0-0xF7]
.
Error::InvalidInputData
will be returned for invalid addresses.
sourcepub fn read_protected_eeprom_data(
&mut self,
address: u8,
data: &mut [u8]
) -> Result<(), Error<E>>
pub fn read_protected_eeprom_data(
&mut self,
address: u8,
data: &mut [u8]
) -> Result<(), Error<E>>
Read protected EEPROM starting in an address as many bytes as necessary to fill the data array provided.
Valid addresses are in the range [0xF0-0xF7]
.
Error::InvalidInputData
will be returned for invalid addresses or
if the reading would overflow the size of the protected EEPROM.
sourcepub fn write_protected_eeprom_byte(
&mut self,
address: u8,
data: u8
) -> Result<(), Error<E>>
pub fn write_protected_eeprom_byte(
&mut self,
address: u8,
data: u8
) -> Result<(), Error<E>>
Unlock protected EEPROM and write a single byte to an address.
Valid addresses are in the range [0xF0-0xF7]
.
Error::InvalidInputData
will be returned for invalid addresses.
sourcepub fn write_protected_eeprom_data(
&mut self,
address: u8,
data: &[u8]
) -> Result<(), Error<E>>
pub fn write_protected_eeprom_data(
&mut self,
address: u8,
data: &[u8]
) -> Result<(), Error<E>>
Write data array starting in an address in the protected EEPROM.
Valid addresses are in the range [0xF0-0xF7]
.
Error::InvalidInputData
will be returned for invalid addresses or
if the writing would overflow the size of the protected EEPROM.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
IC: WithEeprom,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
IC: WithEeprom,
sourcepub fn set_eeprom_write_protection(
&mut self,
protection: EepromWriteProtection
) -> Result<(), Error<E>>
pub fn set_eeprom_write_protection(
&mut self,
protection: EepromWriteProtection
) -> Result<(), Error<E>>
Set the EEPROM block write protection
sourcepub fn read_eeprom_byte(&mut self, address: u8) -> Result<u8, Error<E>>
pub fn read_eeprom_byte(&mut self, address: u8) -> Result<u8, Error<E>>
Read a single byte from an address in EEPROM.
Valid addresses are in the range [0x00-0x7F]
.
Error::InvalidInputData
will be returned for invalid addresses.
sourcepub fn read_eeprom_data(
&mut self,
address: u8,
data: &mut [u8]
) -> Result<(), Error<E>>
pub fn read_eeprom_data(
&mut self,
address: u8,
data: &mut [u8]
) -> Result<(), Error<E>>
Read EEPROM starting in an address as many bytes as necessary to fill the data array provided.
Valid addresses are in the range [0x00-0x7F]
.
Error::InvalidInputData
will be returned for invalid addresses or
if the reading would overflow the size of the EEPROM.
sourcepub fn write_eeprom_byte(&mut self, address: u8, data: u8) -> Result<(), Error<E>>
pub fn write_eeprom_byte(&mut self, address: u8, data: u8) -> Result<(), Error<E>>
Write a single byte to an address in EEPROM.
Valid addresses are in the range [0x00-0x7F]
.
Error::InvalidInputData
will be returned for invalid addresses.
sourcepub fn write_eeprom_data(
&mut self,
address: u8,
data: &[u8]
) -> Result<(), Error<E>>
pub fn write_eeprom_data(
&mut self,
address: u8,
data: &[u8]
) -> Result<(), Error<E>>
Write data array starting in an address in EEPROM.
Valid addresses are in the range [0x00-0x7F]
.
Error::InvalidInputData
will be returned for invalid addresses or
if the writing would overflow the size of the EEPROM.
sourceimpl<DI, E, IC> Mcp794xx<DI, IC> where
DI: ReadCurrent<Error = Error<E>>,
impl<DI, E, IC> Mcp794xx<DI, IC> where
DI: ReadCurrent<Error = Error<E>>,
sourcepub fn read_eeprom_current_byte(&mut self) -> Result<u8, Error<E>>
pub fn read_eeprom_current_byte(&mut self) -> Result<u8, Error<E>>
Read a single byte from the current address in EEPROM.
The current address corresponds to the last accessed address (including addresses accessed in SRAM/RTCC) incremented by 1.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp7940n> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp7940n> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp7940n(i2c: I2C) -> Self
pub fn new_mcp7940n(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp7940m> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp7940m> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp7940m(i2c: I2C) -> Self
pub fn new_mcp7940m(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79400> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79400> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp79400(i2c: I2C) -> Self
pub fn new_mcp79400(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79401> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79401> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp79401(i2c: I2C) -> Self
pub fn new_mcp79401(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79402> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79402> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp79402(i2c: I2C) -> Self
pub fn new_mcp79402(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79410> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79410> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp79410(i2c: I2C) -> Self
pub fn new_mcp79410(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79411> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79411> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp79411(i2c: I2C) -> Self
pub fn new_mcp79411(i2c: I2C) -> Self
Create a new instance of the device.
sourceimpl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79412> where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79412> where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_mcp79412(i2c: I2C) -> Self
pub fn new_mcp79412(i2c: I2C) -> Self
Create a new instance of the device.
Trait Implementations
sourceimpl<DI, E, IC> DateTimeAccess for Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
impl<DI, E, IC> DateTimeAccess for Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
sourcefn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>
fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error>
This device can compensate for leap years up to 2399 but only the two last year digits are stored so we will return the year as in the range 2000-2099.
sourcefn set_datetime(&mut self, datetime: &NaiveDateTime) -> Result<(), Self::Error>
fn set_datetime(&mut self, datetime: &NaiveDateTime) -> Result<(), Self::Error>
Note that this clears the power failed flag. This device can compensate for leap years up to 2399 but only the two last year digits are stored so we only support the range 2000-2099.
sourceimpl<DI, E, IC> Rtcc for Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
impl<DI, E, IC> Rtcc for Mcp794xx<DI, IC> where
DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
sourcefn year(&mut self) -> Result<u16, Self::Error>
fn year(&mut self) -> Result<u16, Self::Error>
This device can compensate for leap years up to 2399 but only the two last year digits are stored so we will return the year as in the range 2000-2099.
sourcefn set_weekday(&mut self, weekday: u8) -> Result<(), Self::Error>
fn set_weekday(&mut self, weekday: u8) -> Result<(), Self::Error>
Note that this clears the power failed flag.
Auto Trait Implementations
impl<DI, IC> RefUnwindSafe for Mcp794xx<DI, IC> where
DI: RefUnwindSafe,
IC: RefUnwindSafe,
impl<DI, IC> Send for Mcp794xx<DI, IC> where
DI: Send,
IC: Send,
impl<DI, IC> Sync for Mcp794xx<DI, IC> where
DI: Sync,
IC: Sync,
impl<DI, IC> Unpin for Mcp794xx<DI, IC> where
DI: Unpin,
IC: Unpin,
impl<DI, IC> UnwindSafe for Mcp794xx<DI, IC> where
DI: UnwindSafe,
IC: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more