[][src]Struct mcp794xx::Mcp794xx

pub struct Mcp794xx<DI, IC> { /* fields omitted */ }

MCP794xx RTCC driver

Methods

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
    IC: WithBatteryPower
[src]

pub fn has_power_failed(&mut self) -> Result<bool, Error<E>>[src]

Returns whether the primary power has failed.

pub fn clear_power_failed(&mut self) -> Result<(), Error<E>>[src]

Clears the power failed status flag and power-fail time-stamp registers.

pub fn get_power_down_datetime(&mut self) -> Result<PowerFailDateTime, Error<E>>[src]

Returns date/time when the power failed went down (under Vtrip).

Note that the registers need to be cleared by calling clear_power_failed()

pub fn get_power_up_datetime(&mut self) -> Result<PowerFailDateTime, Error<E>>[src]

Returns date/time when the power went back up (above Vtrip).

Note that the registers need to be cleared by calling clear_power_failed()

pub fn enable_backup_battery_power(&mut self) -> Result<(), Error<E>>[src]

Enable usage of backup battery power.

Note that this clears the power failed flag.

pub fn disable_backup_battery_power(&mut self) -> Result<(), Error<E>>[src]

Disable usage of backup battery power (default).

Note that this clears the power failed flag.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>, 
[src]

pub fn enable_alarm(&mut self, alarm: Alarm) -> Result<(), Error<E>>[src]

Enable alarm

pub fn disable_alarm(&mut self, alarm: Alarm) -> Result<(), Error<E>>[src]

Disable alarm

pub fn set_alarm(
    &mut self,
    alarm: Alarm,
    when: AlarmDateTime,
    matching: AlarmMatching,
    polarity: AlarmOutputPinPolarity
) -> Result<(), Error<E>>
[src]

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.

pub fn has_alarm_matched(&mut self, alarm: Alarm) -> Result<bool, Error<E>>[src]

Returns whether the alarm has matched.

Once this is true, it will stay as such until cleared. e.g. with clear_alarm_matched_flag()

pub fn clear_alarm_matched_flag(&mut self, alarm: Alarm) -> Result<(), Error<E>>[src]

Clears the alarm matched flag.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: ReadData<Error = Error<E>>, 
[src]

pub fn is_leap_year(&mut self) -> Result<bool, Error<E>>[src]

Returns whether the current year is a leap year.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>, 
[src]

pub fn read_sram_byte(&mut self, address: u8) -> Result<u8, Error<E>>[src]

Read a single byte from an address.

Valid addresses are from 0x20 to 0x5F. Otherwise an Error::InvalidInputData will be returned.

pub fn write_sram_byte(&mut self, address: u8, data: u8) -> Result<(), Error<E>>[src]

Write a single byte to an address.

Valid addresses are from 0x20 to 0x5F. Otherwise an Error::InvalidInputData will be returned.

pub fn read_sram_data(
    &mut self,
    address: u8,
    data: &mut [u8]
) -> Result<(), Error<E>>
[src]

Read SRAM starting in an address as many bytes as necessary to fill the data array provided.

pub fn write_sram_data(
    &mut self,
    address: u8,
    data: &[u8]
) -> Result<(), Error<E>>
[src]

Write data array to SRAM starting in an address.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: ReadCurrent<Error = Error<E>>, 
[src]

pub fn read_sram_current_byte(&mut self) -> Result<u8, Error<E>>[src]

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.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>, 
[src]

pub fn enable(&mut self) -> Result<(), Error<E>>[src]

Enable the oscillator (set the clock running).

pub fn disable(&mut self) -> Result<(), Error<E>>[src]

Disable the oscillator (stops the clock) (default).

pub fn is_oscillator_running(&mut self) -> Result<bool, Error<E>>[src]

Returns whether the oscillator is running.

pub fn enable_external_oscillator(&mut self) -> Result<(), Error<E>>[src]

Enable usage of external oscillator source.

pub fn disable_external_oscillator(&mut self) -> Result<(), Error<E>>[src]

Disable usage of external oscillator source (Will use internal source).

pub fn enable_square_wave(&mut self) -> Result<(), Error<E>>[src]

Enable square-wave output.

Note that this is not available when running on backup battery power.

pub fn disable_square_wave(&mut self) -> Result<(), Error<E>>[src]

Disable square-wave output.

pub fn set_square_wave_frequency(
    &mut self,
    frequency: SqWFreq
) -> Result<(), Error<E>>
[src]

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.

pub fn set_output_pin(&mut self, level: OutputPinLevel) -> Result<(), Error<E>>[src]

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.

pub fn enable_coarse_trim(&mut self) -> Result<(), Error<E>>[src]

Enable coarse trim mode.

pub fn disable_coarse_trim(&mut self) -> Result<(), Error<E>>[src]

Disable coarse trim mode.

pub fn set_trimming(&mut self, value: i8) -> Result<(), Error<E>>[src]

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.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
    IC: WithProtectedEeprom
[src]

pub fn read_protected_eeprom_byte(
    &mut self,
    address: u8
) -> Result<u8, Error<E>>
[src]

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.

pub fn read_protected_eeprom_data(
    &mut self,
    address: u8,
    data: &mut [u8]
) -> Result<(), Error<E>>
[src]

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.

pub fn write_protected_eeprom_byte(
    &mut self,
    address: u8,
    data: u8
) -> Result<(), Error<E>>
[src]

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.

pub fn write_protected_eeprom_data(
    &mut self,
    address: u8,
    data: &[u8]
) -> Result<(), Error<E>>
[src]

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.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>,
    IC: WithEeprom
[src]

pub fn set_eeprom_write_protection(
    &mut self,
    protection: EepromWriteProtection
) -> Result<(), Error<E>>
[src]

Set the EEPROM block write protection

pub fn read_eeprom_byte(&mut self, address: u8) -> Result<u8, Error<E>>[src]

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.

pub fn read_eeprom_data(
    &mut self,
    address: u8,
    data: &mut [u8]
) -> Result<(), Error<E>>
[src]

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.

pub fn write_eeprom_byte(
    &mut self,
    address: u8,
    data: u8
) -> Result<(), Error<E>>
[src]

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.

pub fn write_eeprom_data(
    &mut self,
    address: u8,
    data: &[u8]
) -> Result<(), Error<E>>
[src]

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.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: ReadCurrent<Error = Error<E>>, 
[src]

pub fn read_eeprom_current_byte(&mut self) -> Result<u8, Error<E>>[src]

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.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: ReadData<Error = Error<E>>,
    IC: WithEui48
[src]

pub fn read_eui48(&mut self) -> Result<[u8; 6], Error<E>>[src]

Read pre-programmed EUI-48 node address from EEPROM.

impl<DI, E, IC> Mcp794xx<DI, IC> where
    DI: ReadData<Error = Error<E>>,
    IC: WithEui64
[src]

pub fn read_eui64(&mut self) -> Result<[u8; 8], Error<E>>[src]

Read pre-programmed EUI-64 node address from EEPROM.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp7940n> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp7940n(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp7940m> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp7940m(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79400> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp79400(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79401> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp79401(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79402> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp79402(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79410> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp79410(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79411> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp79411(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

impl<I2C, E> Mcp794xx<I2cInterface<I2C>, Mcp79412> where
    I2C: Write<Error = E> + WriteRead<Error = E>, 
[src]

pub fn new_mcp79412(i2c: I2C) -> Self[src]

Create a new instance of the device.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

Trait Implementations

impl<DI: Debug, IC: Debug> Debug for Mcp794xx<DI, IC>[src]

impl<DI, E, IC> Rtcc for Mcp794xx<DI, IC> where
    DI: WriteData<Error = Error<E>> + ReadData<Error = Error<E>>, 
[src]

type Error = Error<E>

Error type

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

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.

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

Note that this clears the power failed flag.

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

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.

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

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.

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

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.

Auto Trait Implementations

impl<DI, IC> Unpin for Mcp794xx<DI, IC> where
    DI: Unpin,
    IC: Unpin

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

Blanket Implementations

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

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.

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

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.

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]