summaryrefslogtreecommitdiffstats
path: root/src/devices/features
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-20 20:24:21 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-20 20:24:21 +0100
commitad572b64eb0e99f269297d8de19d709ef66d3f24 (patch)
treedf45d290d71499dfe4e976f0215181cea5e0e77e /src/devices/features
parent334c0d2352efd751dddd10db1315c144fcfe8b28 (diff)
downloadads1x1x-async-ad572b64eb0e99f269297d8de19d709ef66d3f24.tar.gz
ads1x1x-async-ad572b64eb0e99f269297d8de19d709ef66d3f24.tar.xz
ads1x1x-async-ad572b64eb0e99f269297d8de19d709ef66d3f24.zip
Add function to use the ALERT/RDY pin as conversion-ready pin
Diffstat (limited to 'src/devices/features')
-rw-r--r--src/devices/features/tier2.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/devices/features/tier2.rs b/src/devices/features/tier2.rs
index 79843f6..6047572 100644
--- a/src/devices/features/tier2.rs
+++ b/src/devices/features/tier2.rs
@@ -115,4 +115,19 @@ where
self.config = config;
Ok(())
}
+
+ /// Use the ALERT/RDY pin as conversion-ready pin.
+ ///
+ /// This the ALERT/RDY pin outputs the OS bit when in OneShot mode, and
+ /// provides a continuous-conversion ready pulse when in
+ /// continuous-conversion mode.
+ ///
+ /// When calling this the comparator will be disabled and the thresholds will be cleared.
+ pub fn use_alert_rdy_pin_as_ready(&mut self) -> Result<(), Error<E>> {
+ if self.config != self.config.with_high(BitFlags::COMP_QUE1).with_high(BitFlags::COMP_QUE0) {
+ self.disable_comparator()?;
+ }
+ self.iface.write_register(Register::HIGH_TH, 0x8000)?;
+ self.iface.write_register(Register::LOW_TH, 0)
+ }
}