From ad572b64eb0e99f269297d8de19d709ef66d3f24 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 20 Nov 2018 20:24:21 +0100 Subject: Add function to use the ALERT/RDY pin as conversion-ready pin --- src/devices/features/tier2.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/devices') 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> { + 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) + } } -- cgit v1.2.3-54-g00ecf