diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-21 08:11:15 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-21 08:11:15 +0100 |
commit | eb0c438e9dbad47a9cf2c24610233b0224f7e269 (patch) | |
tree | 6f897520ce5bc9d5963d760f99173b6ce50fc2ae /src/devices/common.rs | |
parent | 0ae97c430f4082e94730a1b220f75db1add65270 (diff) | |
download | ads1x1x-async-eb0c438e9dbad47a9cf2c24610233b0224f7e269.tar.gz ads1x1x-async-eb0c438e9dbad47a9cf2c24610233b0224f7e269.tar.xz ads1x1x-async-eb0c438e9dbad47a9cf2c24610233b0224f7e269.zip |
Make function to read if a measurement is in progress public
Diffstat (limited to 'src/devices/common.rs')
-rw-r--r-- | src/devices/common.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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<DI, IC, CONV, MODE, E> Ads1x1x<DI, IC, CONV, MODE> where - DI: interface::WriteData<Error = E> + DI: interface::WriteData<Error = E> + interface::ReadData<Error = E>, { pub(super) fn set_operating_mode(&mut self, mode: OperatingMode) -> Result<(), Error<E>> { 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<bool, Error<E>> { + 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. |