diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-10 10:01:27 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-10 10:01:27 +0100 |
commit | f6ac6188a652bd7ccff772648d57cff9a0963e84 (patch) | |
tree | eccb385ef79bd57367f6a59312907304c042fc8e /src/devices | |
parent | e7532aef9723a4078874d42ccb9a616628f1b3e6 (diff) | |
download | ads1x1x-async-f6ac6188a652bd7ccff772648d57cff9a0963e84.tar.gz ads1x1x-async-f6ac6188a652bd7ccff772648d57cff9a0963e84.tar.xz ads1x1x-async-f6ac6188a652bd7ccff772648d57cff9a0963e84.zip |
Add support for setting the comparator latching
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/ads1x1x/features/tier2.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/devices/ads1x1x/features/tier2.rs b/src/devices/ads1x1x/features/tier2.rs index 7d22796..43dce5c 100644 --- a/src/devices/ads1x1x/features/tier2.rs +++ b/src/devices/ads1x1x/features/tier2.rs @@ -3,7 +3,7 @@ //! These are the features included only in ADS1x14, ADS1x15 use { Ads1x1x, Error, interface, ic, ComparatorMode, ComparatorPolarity, - Register, BitFlags }; + ComparatorLatching, Register, BitFlags }; impl<DI, IC, MODE, E> Ads1x1x<DI, IC, MODE> where @@ -33,4 +33,16 @@ where self.config = config; Ok(()) } + + /// Set comparator latching + pub fn set_comparator_latching(&mut self, latching: ComparatorLatching) -> Result<(), Error<E>> { + let config; + match latching { + ComparatorLatching::Nonlatching => config = self.config.with_low( BitFlags::COMP_LAT), + ComparatorLatching::Latching => config = self.config.with_high(BitFlags::COMP_LAT) + } + self.iface.write_register(Register::CONFIG, config.bits)?; + self.config = config; + Ok(()) + } } |