diff options
Diffstat (limited to 'src/devices/ads1x1x/features/tier2.rs')
-rw-r--r-- | src/devices/ads1x1x/features/tier2.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/devices/ads1x1x/features/tier2.rs b/src/devices/ads1x1x/features/tier2.rs new file mode 100644 index 0000000..d238691 --- /dev/null +++ b/src/devices/ads1x1x/features/tier2.rs @@ -0,0 +1,23 @@ +//! Tier 2 features. +//! +//! These are the features included only in ADS1x14, ADS1x15 + +use { Ads1x1x, Error, interface, ic, ComparatorMode, Register, BitFlags }; + +impl<DI, IC, MODE, E> Ads1x1x<DI, IC, MODE> +where + DI: interface::WriteData<Error = E>, + IC: ic::Resolution + ic::Tier2Features +{ + /// Set comparator mode + pub fn set_comparator_mode(&mut self, mode: ComparatorMode) -> Result<(), Error<E>> { + let config; + match mode { + ComparatorMode::Traditional => config = self.config.with_low(BitFlags::COMP_MODE), + ComparatorMode::Window => config = self.config.with_high(BitFlags::COMP_MODE) + } + self.iface.write_register(Register::CONFIG, config.bits)?; + self.config = config; + Ok(()) + } +} |