From eb0c438e9dbad47a9cf2c24610233b0224f7e269 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Wed, 21 Nov 2018 08:11:15 +0100 Subject: Make function to read if a measurement is in progress public --- src/devices/common.rs | 10 +++++++++- src/devices/mode/oneshot.rs | 7 ------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/devices') diff --git a/src/devices/common.rs b/src/devices/common.rs index 1121265..92b4f9e 100644 --- a/src/devices/common.rs +++ b/src/devices/common.rs @@ -5,7 +5,7 @@ use super::OperatingMode; impl Ads1x1x where - DI: interface::WriteData + DI: interface::WriteData + interface::ReadData, { pub(super) fn set_operating_mode(&mut self, mode: OperatingMode) -> Result<(), Error> { let config; @@ -18,6 +18,14 @@ where Ok(()) } + /// Read whether a measurement is currently in progress. + pub fn is_measurement_in_progress(&mut self) -> Result> { + let config = Config { + bits: self.iface.read_register(Register::CONFIG)? + }; + Ok(!config.is_high(BitFlags::OS)) + } + /// Reset the internal state of this driver to the default values. /// /// *Note:* This does not alter the state or configuration of the device. diff --git a/src/devices/mode/oneshot.rs b/src/devices/mode/oneshot.rs index 41a9f26..a03d8d2 100644 --- a/src/devices/mode/oneshot.rs +++ b/src/devices/mode/oneshot.rs @@ -23,13 +23,6 @@ where }) } - fn is_measurement_in_progress(&mut self) -> Result> { - let config = Config { - bits: self.iface.read_register(Register::CONFIG)? - }; - Ok(!config.is_high(BitFlags::OS)) - } - fn trigger_measurement(&mut self, config: &Config) -> Result<(), Error> { let config = config.with_high(BitFlags::OS); self.iface.write_register(Register::CONFIG, config.bits) -- cgit v1.2.3-54-g00ecf