pub struct Ds323x<DI, IC> { /* private fields */ }
Expand description
DS3231, DS3232 and DS3234 RTC driver
Implementations§
source§impl<DI, IC, CommE, PinE> Ds323x<DI, IC>where
DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
impl<DI, IC, CommE, PinE> Ds323x<DI, IC>where DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
sourcepub fn set_alarm1_day(
&mut self,
when: DayAlarm1,
matching: Alarm1Matching
) -> Result<(), Error<CommE, PinE>>
pub fn set_alarm1_day( &mut self, when: DayAlarm1, matching: Alarm1Matching ) -> Result<(), Error<CommE, PinE>>
Set Alarm1 for day of the month.
Will return an Error::InvalidInputData
if any of the used parameters
(depending on the matching startegy) is out of range. Any unused
parameter is set to the corresponding minimum valid value:
- Second, minute, hour: 0
- Day: 1
sourcepub fn set_alarm1_hms(
&mut self,
when: NaiveTime
) -> Result<(), Error<CommE, PinE>>
pub fn set_alarm1_hms( &mut self, when: NaiveTime ) -> Result<(), Error<CommE, PinE>>
Set Alarm1 for a time (fires when hours, minutes and seconds match).
Will return an Error::InvalidInputData
if any of the parameters is out of range.
The day is not used by this matching strategy and is set to 1.
sourcepub fn set_alarm1_weekday(
&mut self,
when: WeekdayAlarm1,
matching: Alarm1Matching
) -> Result<(), Error<CommE, PinE>>
pub fn set_alarm1_weekday( &mut self, when: WeekdayAlarm1, matching: Alarm1Matching ) -> Result<(), Error<CommE, PinE>>
Set Alarm1 for weekday.
Will return an Error::InvalidInputData
if any of the used parameters
(depending on the matching startegy) is out of range. Any unused
parameter is set to the corresponding minimum valid value:
- Second, minute, hour: 0
- Weekday: 1
sourcepub fn set_alarm2_day(
&mut self,
when: DayAlarm2,
matching: Alarm2Matching
) -> Result<(), Error<CommE, PinE>>
pub fn set_alarm2_day( &mut self, when: DayAlarm2, matching: Alarm2Matching ) -> Result<(), Error<CommE, PinE>>
Set Alarm2 for date (day of month).
Will return an Error::InvalidInputData
if any of the used parameters
(depending on the matching startegy) is out of range. Any unused
parameter is set to the corresponding minimum valid value:
- Minute, hour: 0
- Day: 1
sourcepub fn set_alarm2_hm(
&mut self,
when: NaiveTime
) -> Result<(), Error<CommE, PinE>>
pub fn set_alarm2_hm( &mut self, when: NaiveTime ) -> Result<(), Error<CommE, PinE>>
Set Alarm2 for a time (fires when hours and minutes match).
Will return an Error::InvalidInputData
if any of the parameters is out of range.
The day is not used by this matching strategy and is set to 1.
sourcepub fn set_alarm2_weekday(
&mut self,
when: WeekdayAlarm2,
matching: Alarm2Matching
) -> Result<(), Error<CommE, PinE>>
pub fn set_alarm2_weekday( &mut self, when: WeekdayAlarm2, matching: Alarm2Matching ) -> Result<(), Error<CommE, PinE>>
Set Alarm2 for weekday.
Will return an Error::InvalidInputData
if any of the used parameters
(depending on the matching startegy) is out of range. Any unused
parameter is set to the corresponding minimum valid value:
- Minute, hour: 0
- Weekday: 1
source§impl<DI, IC, CommE, PinE> Ds323x<DI, IC>where
DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
impl<DI, IC, CommE, PinE> Ds323x<DI, IC>where DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
sourcepub fn enable(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn enable(&mut self) -> Result<(), Error<CommE, PinE>>
Enable the oscillator (set the clock running) (default).
sourcepub fn disable(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn disable(&mut self) -> Result<(), Error<CommE, PinE>>
Disable the oscillator (stops the clock).
sourcepub fn convert_temperature(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn convert_temperature(&mut self) -> Result<(), Error<CommE, PinE>>
Force a temperature conversion and time compensation with TXCO algorithm.
The busy status should be checked before doing this. See busy()
sourcepub fn enable_32khz_output(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn enable_32khz_output(&mut self) -> Result<(), Error<CommE, PinE>>
Enable the 32kHz output. (enabled per default)
sourcepub fn disable_32khz_output(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn disable_32khz_output(&mut self) -> Result<(), Error<CommE, PinE>>
Disable the 32kHz output.
sourcepub fn set_aging_offset(&mut self, offset: i8) -> Result<(), Error<CommE, PinE>>
pub fn set_aging_offset(&mut self, offset: i8) -> Result<(), Error<CommE, PinE>>
Set the aging offset.
sourcepub fn aging_offset(&mut self) -> Result<i8, Error<CommE, PinE>>
pub fn aging_offset(&mut self) -> Result<i8, Error<CommE, PinE>>
Read the aging offset.
sourcepub fn use_int_sqw_output_as_interrupt(
&mut self
) -> Result<(), Error<CommE, PinE>>
pub fn use_int_sqw_output_as_interrupt( &mut self ) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn use_int_sqw_output_as_square_wave( &mut self ) -> Result<(), Error<CommE, PinE>>
Set the interrupt/square-wave output to be used as square-wave output. (default)
sourcepub fn enable_square_wave(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn enable_square_wave(&mut self) -> Result<(), Error<CommE, PinE>>
Enable battery-backed square wave generation.
sourcepub fn disable_square_wave(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn disable_square_wave(&mut self) -> Result<(), Error<CommE, PinE>>
Disable battery-backed square wave generation.
sourcepub fn set_square_wave_frequency(
&mut self,
freq: SqWFreq
) -> Result<(), Error<CommE, PinE>>
pub fn set_square_wave_frequency( &mut self, freq: SqWFreq ) -> Result<(), Error<CommE, PinE>>
Set the square-wave output frequency.
sourcepub fn enable_alarm1_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn enable_alarm1_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
Enable Alarm1 interrupts.
sourcepub fn disable_alarm1_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn disable_alarm1_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
Disable Alarm1 interrupts.
sourcepub fn enable_alarm2_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn enable_alarm2_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
Enable Alarm2 interrupts.
sourcepub fn disable_alarm2_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
pub fn disable_alarm2_interrupts(&mut self) -> Result<(), Error<CommE, PinE>>
Disable Alarm2 interrupts.
source§impl<DI, IC, CommE, PinE> Ds323x<DI, IC>where
DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
impl<DI, IC, CommE, PinE> Ds323x<DI, IC>where DI: ReadData<Error = Error<CommE, PinE>> + WriteData<Error = Error<CommE, PinE>>,
sourcepub fn running(&mut self) -> Result<bool, Error<CommE, PinE>>
pub fn running(&mut self) -> Result<bool, Error<CommE, PinE>>
Read whether the oscillator is running
sourcepub fn has_been_stopped(&mut self) -> Result<bool, Error<CommE, PinE>>
pub fn has_been_stopped(&mut self) -> Result<bool, Error<CommE, PinE>>
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<CommE, PinE>>
pub fn clear_has_been_stopped_flag(&mut self) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn has_alarm1_matched(&mut self) -> Result<bool, Error<CommE, PinE>>
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<CommE, PinE>>
pub fn clear_alarm1_matched_flag(&mut self) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn has_alarm2_matched(&mut self) -> Result<bool, Error<CommE, PinE>>
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<CommE, PinE>>
pub fn clear_alarm2_matched_flag(&mut self) -> Result<(), Error<CommE, PinE>>
Clear flag signalling whether the Alarm2 has matched at some point.
See also: has_alarm2_matched()
sourcepub fn temperature(&mut self) -> Result<f32, Error<CommE, PinE>>
pub fn temperature(&mut self) -> Result<f32, Error<CommE, PinE>>
Read the temperature.
Note: It is possible to manually force a temperature conversion with
convert_temperature()
source§impl<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.
source§impl<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.
source§impl<SPI, CS, CommE, PinE> Ds323x<SpiInterface<SPI, CS>, DS3234>where
SPI: Transfer<u8, Error = CommE> + Write<u8, Error = CommE>,
CS: OutputPin<Error = PinE>,
impl<SPI, CS, CommE, PinE> Ds323x<SpiInterface<SPI, CS>, DS3234>where SPI: Transfer<u8, Error = CommE> + Write<u8, Error = CommE>, CS: OutputPin<Error = PinE>,
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<CommE, PinE>>
pub fn enable_32khz_output_on_battery( &mut self ) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn disable_32khz_output_on_battery( &mut self ) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn set_temperature_conversion_rate( &mut self, rate: TempConvRate ) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn enable_temperature_conversions_on_battery( &mut self ) -> Result<(), Error<CommE, PinE>>
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<CommE, PinE>>
pub fn disable_temperature_conversions_on_battery( &mut self ) -> Result<(), Error<CommE, PinE>>
Disable the temperature conversions when battery-powered.
Note: This is only available for DS3234 devices.