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/devices/features | |
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/devices/features')
-rw-r--r-- | src/devices/features/tier2.rs | 15 |
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) + } } |