diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-20 20:24:21 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-20 20:24:21 +0100 |
commit | ad572b64eb0e99f269297d8de19d709ef66d3f24 (patch) | |
tree | df45d290d71499dfe4e976f0215181cea5e0e77e /src | |
parent | 334c0d2352efd751dddd10db1315c144fcfe8b28 (diff) | |
download | ads1x1x-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')
-rw-r--r-- | src/devices/features/tier2.rs | 15 | ||||
-rw-r--r-- | src/lib.rs | 2 |
2 files changed, 17 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) + } } @@ -17,6 +17,7 @@ //! - Set the comparator latching. See: [`set_comparator_latching()`]. //! - Set the comparator queue. See: [`set_comparator_queue()`]. //! - Disable the comparator. See: [`disable_comparator()`]. +//! - Set the ALERT/RDY pin to be used as conversion-ready pin. See: [`use_alert_rdy_pin_as_ready()`]. //! //! [`into_continuous()`]: struct.Ads1x1x.html#method.into_continuous //! [read_os]: struct.Ads1x1x.html#method.read @@ -30,6 +31,7 @@ //! [`set_comparator_latching()`]: struct.Ads1x1x.html#method.set_comparator_latching //! [`set_comparator_queue()`]: struct.Ads1x1x.html#method.set_comparator_queue //! [`disable_comparator()`]: struct.Ads1x1x.html#method.disable_comparator +//! [`use_alert_rdy_pin_as_ready()`]: struct.Ads1x1x.html#method.use_alert_rdy_pin_as_ready //! //! ## The devices //! |