pub struct Ds323x<DI, IC> { /* private fields */ }
Expand description
DS3231, DS3232 and DS3234 RTC driver
Implementations
sourceimpl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
impl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<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) (default).
sourcepub fn convert_temperature(&mut self) -> Result<(), Error<E>>
pub fn convert_temperature(&mut self) -> Result<(), Error<E>>
Force a temperature conversion and time compensation with TXCO algorithm.
The busy status should be checked before doing this. See is_busy()
sourcepub fn enable_32khz_output(&mut self) -> Result<(), Error<E>>
pub fn enable_32khz_output(&mut self) -> Result<(), Error<E>>
Enable the 32kHz output. (enabled per default)
sourcepub fn disable_32khz_output(&mut self) -> Result<(), Error<E>>
pub fn disable_32khz_output(&mut self) -> Result<(), Error<E>>
Disable the 32kHz output.
sourcepub fn get_aging_offset(&mut self) -> Result<i8, Error<E>>
pub fn get_aging_offset(&mut self) -> Result<i8, Error<E>>
Read the aging offset.
sourcepub fn use_int_sqw_output_as_interrupt(&mut self) -> Result<(), Error<E>>
pub fn use_int_sqw_output_as_interrupt(&mut self) -> Result<(), Error<E>>
Set the interrupt/square-wave output to be used as interrupt output.
sourcepub fn use_int_sqw_output_as_square_wave(&mut self) -> Result<(), Error<E>>
pub fn use_int_sqw_output_as_square_wave(&mut self) -> Result<(), Error<E>>
Set the interrupt/square-wave output to be used as square-wave output. (default)
sourcepub fn enable_square_wave(&mut self) -> Result<(), Error<E>>
pub fn enable_square_wave(&mut self) -> Result<(), Error<E>>
Enable battery-backed square wave generation.
sourcepub fn disable_square_wave(&mut self) -> Result<(), Error<E>>
pub fn disable_square_wave(&mut self) -> Result<(), Error<E>>
Disable battery-backed square wave generation.
sourcepub fn set_square_wave_frequency(
&mut self,
freq: SqWFreq
) -> Result<(), Error<E>>
pub fn set_square_wave_frequency(
&mut self,
freq: SqWFreq
) -> Result<(), Error<E>>
Set the square-wave output frequency.
sourcepub fn enable_alarm1_interrupts(&mut self) -> Result<(), Error<E>>
pub fn enable_alarm1_interrupts(&mut self) -> Result<(), Error<E>>
Enable Alarm1 interrupts.
sourcepub fn disable_alarm1_interrupts(&mut self) -> Result<(), Error<E>>
pub fn disable_alarm1_interrupts(&mut self) -> Result<(), Error<E>>
Disable Alarm1 interrupts.
sourcepub fn enable_alarm2_interrupts(&mut self) -> Result<(), Error<E>>
pub fn enable_alarm2_interrupts(&mut self) -> Result<(), Error<E>>
Enable Alarm2 interrupts.
sourcepub fn disable_alarm2_interrupts(&mut self) -> Result<(), Error<E>>
pub fn disable_alarm2_interrupts(&mut self) -> Result<(), Error<E>>
Disable Alarm2 interrupts.
sourceimpl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
impl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
sourcepub fn is_running(&mut self) -> Result<bool, Error<E>>
pub fn is_running(&mut self) -> Result<bool, Error<E>>
Read whether the oscillator is running
sourcepub fn has_been_stopped(&mut self) -> Result<bool, Error<E>>
pub fn has_been_stopped(&mut self) -> Result<bool, Error<E>>
Read whether the oscillator is stopped or has been stopped at some point.
This allows a better assessment of the validity of the timekeeping data.
Once this is true, it will stay as such until cleared with
clear_has_been_stopped_flag()
sourcepub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<E>>
pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<E>>
Clear flag signalling whether the oscillator is stopped or has been stopped at some point.
See also: has_been_stopped()
sourcepub fn has_alarm1_matched(&mut self) -> Result<bool, Error<E>>
pub fn has_alarm1_matched(&mut self) -> Result<bool, Error<E>>
Read whether the Alarm1 has matched at some point.
Once this is true, it will stay as such until cleared with
clear_alarm1_matched_flag()
sourcepub fn clear_alarm1_matched_flag(&mut self) -> Result<(), Error<E>>
pub fn clear_alarm1_matched_flag(&mut self) -> Result<(), Error<E>>
Clear flag signalling whether the Alarm1 has matched at some point.
See also: has_alarm1_matched()
sourcepub fn has_alarm2_matched(&mut self) -> Result<bool, Error<E>>
pub fn has_alarm2_matched(&mut self) -> Result<bool, Error<E>>
Read whether the Alarm2 has matched at some point.
Once this is true, it will stay as such until cleared with
clear_alarm2_matched_flag()
sourcepub fn clear_alarm2_matched_flag(&mut self) -> Result<(), Error<E>>
pub fn clear_alarm2_matched_flag(&mut self) -> Result<(), Error<E>>
Clear flag signalling whether the Alarm2 has matched at some point.
See also: has_alarm2_matched()
sourcepub fn get_temperature(&mut self) -> Result<f32, Error<E>>
pub fn get_temperature(&mut self) -> Result<f32, Error<E>>
Read the temperature.
Note: It is possible to manually force a temperature conversion with
convert_temperature()
sourceimpl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
impl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
sourcepub fn set_alarm1_day(
&mut self,
when: DayAlarm1,
matching: Alarm1Matching
) -> Result<(), Error<E>>
pub fn set_alarm1_day(
&mut self,
when: DayAlarm1,
matching: Alarm1Matching
) -> Result<(), Error<E>>
Set Alarm1 for day of the month.
Will return an Error::InvalidInputData
if any of the parameters is out of range.
sourcepub fn set_alarm1_weekday(
&mut self,
when: WeekdayAlarm1,
matching: Alarm1Matching
) -> Result<(), Error<E>>
pub fn set_alarm1_weekday(
&mut self,
when: WeekdayAlarm1,
matching: Alarm1Matching
) -> Result<(), Error<E>>
Set Alarm1 for weekday.
Will return an Error::InvalidInputData
if any of the parameters is out of range.
sourcepub fn set_alarm2_day(
&mut self,
when: DayAlarm2,
matching: Alarm2Matching
) -> Result<(), Error<E>>
pub fn set_alarm2_day(
&mut self,
when: DayAlarm2,
matching: Alarm2Matching
) -> Result<(), Error<E>>
Set Alarm2 for date (day of month).
Will return an Error::InvalidInputData
if any of the parameters is out of range.
sourcepub fn set_alarm2_weekday(
&mut self,
when: WeekdayAlarm2,
matching: Alarm2Matching
) -> Result<(), Error<E>>
pub fn set_alarm2_weekday(
&mut self,
when: WeekdayAlarm2,
matching: Alarm2Matching
) -> Result<(), Error<E>>
Set Alarm2 for weekday.
Will return an Error::InvalidInputData
if any of the parameters is out of range.
sourceimpl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
impl<DI, IC, E> Ds323x<DI, IC>where
DI: ReadData<Error = E> + WriteData<Error = E>,
sourcepub fn get_seconds(&mut self) -> Result<u8, Error<E>>
pub fn get_seconds(&mut self) -> Result<u8, Error<E>>
Read the seconds.
sourcepub fn get_minutes(&mut self) -> Result<u8, Error<E>>
pub fn get_minutes(&mut self) -> Result<u8, Error<E>>
Read the minutes.
sourcepub fn get_weekday(&mut self) -> Result<u8, Error<E>>
pub fn get_weekday(&mut self) -> Result<u8, Error<E>>
Read the day of the week [1-7].
sourcepub fn get_datetime(&mut self) -> Result<DateTime, Error<E>>
pub fn get_datetime(&mut self) -> Result<DateTime, Error<E>>
Read the date and time.
sourcepub fn set_seconds(&mut self, seconds: u8) -> Result<(), Error<E>>
pub fn set_seconds(&mut self, seconds: u8) -> Result<(), Error<E>>
Set the seconds [0-59].
Will return an Error::InvalidInputData
if the seconds are out of range.
sourcepub fn set_minutes(&mut self, minutes: u8) -> Result<(), Error<E>>
pub fn set_minutes(&mut self, minutes: u8) -> Result<(), Error<E>>
Set the minutes [0-59].
Will return an Error::InvalidInputData
if the minutes are out of range.
sourcepub fn set_hours(&mut self, hours: Hours) -> Result<(), Error<E>>
pub fn set_hours(&mut self, hours: Hours) -> Result<(), Error<E>>
Set the hours.
Changes the operating mode to 12h/24h depending on the parameter.
Will return an Error::InvalidInputData
if the hours are out of range.
sourcepub fn set_weekday(&mut self, weekday: u8) -> Result<(), Error<E>>
pub fn set_weekday(&mut self, weekday: u8) -> Result<(), Error<E>>
Set the day of week [1-7].
Will return an Error::InvalidInputData
if the day is out of range.
sourcepub fn set_day(&mut self, day: u8) -> Result<(), Error<E>>
pub fn set_day(&mut self, day: u8) -> Result<(), Error<E>>
Set the day of month [1-31].
Will return an Error::InvalidInputData
if the day is out of range.
sourcepub fn set_month(&mut self, month: u8) -> Result<(), Error<E>>
pub fn set_month(&mut self, month: u8) -> Result<(), Error<E>>
Set the month [1-12].
Will return an Error::InvalidInputData
if the month is out of range.
sourceimpl<I2C, E> Ds323x<I2cInterface<I2C>, DS3231>where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Ds323x<I2cInterface<I2C>, DS3231>where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_ds3231(i2c: I2C) -> Self
pub fn new_ds3231(i2c: I2C) -> Self
Create a new instance of the DS3231 device.
sourcepub fn destroy_ds3231(self) -> I2C
pub fn destroy_ds3231(self) -> I2C
Destroy driver instance, return I²C bus instance.
sourceimpl<I2C, E> Ds323x<I2cInterface<I2C>, DS3232>where
I2C: Write<Error = E> + WriteRead<Error = E>,
impl<I2C, E> Ds323x<I2cInterface<I2C>, DS3232>where
I2C: Write<Error = E> + WriteRead<Error = E>,
sourcepub fn new_ds3232(i2c: I2C) -> Self
pub fn new_ds3232(i2c: I2C) -> Self
Create a new instance of the DS3232 device.
sourcepub fn destroy_ds3232(self) -> I2C
pub fn destroy_ds3232(self) -> I2C
Destroy driver instance, return I²C bus instance.
sourcepub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
pub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
Enable the 32kHz output when battery-powered. (enabled per default)
Additionally, the 32kHz output needs to be enabled. See
enable_32khz_output()
.
Note: This is only available for DS3232 and DS3234 devices.
sourcepub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
pub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
Disable the 32kHz output when battery-powered.
The 32kHz output will still generate a wave when not battery-powered if
it enabled. See enable_32khz_output()
.
Note: This is only available for DS3232 and DS3234 devices.
sourcepub fn set_temperature_conversion_rate(
&mut self,
rate: TempConvRate
) -> Result<(), Error<E>>
pub fn set_temperature_conversion_rate(
&mut self,
rate: TempConvRate
) -> Result<(), Error<E>>
Set the temperature conversion rate.
Set how often the temperature is measured and applies compensation to the oscillator. This can be used to reduce power consumption but sudden temperature changes will not be compensated for.
Note: This is only available for DS3232 and DS3234 devices.
sourceimpl<SPI, CS, E> Ds323x<SpiInterface<SPI, CS>, DS3234>where
SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
CS: OutputPin,
impl<SPI, CS, E> Ds323x<SpiInterface<SPI, CS>, DS3234>where
SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
CS: OutputPin,
sourcepub fn new_ds3234(spi: SPI, chip_select: CS) -> Self
pub fn new_ds3234(spi: SPI, chip_select: CS) -> Self
Create a new instance.
sourcepub fn destroy_ds3234(self) -> (SPI, CS)
pub fn destroy_ds3234(self) -> (SPI, CS)
Destroy driver instance, return SPI bus instance and CS output pin.
sourcepub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
pub fn enable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
Enable the 32kHz output when battery-powered. (enabled per default)
Additionally, the 32kHz output needs to be enabled. See
enable_32khz_output()
.
Note: This is only available for DS3232 and DS3234 devices.
sourcepub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
pub fn disable_32khz_output_on_battery(&mut self) -> Result<(), Error<E>>
Disable the 32kHz output when battery-powered.
The 32kHz output will still generate a wave when not battery-powered if
it enabled. See enable_32khz_output()
.
Note: This is only available for DS3232 and DS3234 devices.
sourcepub fn set_temperature_conversion_rate(
&mut self,
rate: TempConvRate
) -> Result<(), Error<E>>
pub fn set_temperature_conversion_rate(
&mut self,
rate: TempConvRate
) -> Result<(), Error<E>>
Set the temperature conversion rate.
Set how often the temperature is measured and applies compensation to the oscillator. This can be used to reduce power consumption but sudden temperature changes will not be compensated for.
Note: This is only available for DS3232 and DS3234 devices.
sourcepub fn enable_temperature_conversions_on_battery(
&mut self
) -> Result<(), Error<E>>
pub fn enable_temperature_conversions_on_battery(
&mut self
) -> Result<(), Error<E>>
Enable the temperature conversions when battery-powered. (enabled per default)
Note: This is only available for DS3234 devices.
sourcepub fn disable_temperature_conversions_on_battery(
&mut self
) -> Result<(), Error<E>>
pub fn disable_temperature_conversions_on_battery(
&mut self
) -> Result<(), Error<E>>
Disable the temperature conversions when battery-powered.
Note: This is only available for DS3234 devices.