summaryrefslogtreecommitdiffstats
path: root/src/devices/ads1x1x/mode/continuous.rs
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-07 20:22:59 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-07 20:22:59 +0100
commit483221e740ffaebe406ee428beb59fa136d70c7f (patch)
treef7fee2bbc46b97f1508d4b8bc2fec258695e4239 /src/devices/ads1x1x/mode/continuous.rs
parentec0ffcaa6d49ae7c6e3256f9742e996d7b0752c4 (diff)
downloadads1x1x-async-483221e740ffaebe406ee428beb59fa136d70c7f.tar.gz
ads1x1x-async-483221e740ffaebe406ee428beb59fa136d70c7f.tar.xz
ads1x1x-async-483221e740ffaebe406ee428beb59fa136d70c7f.zip
Add support for one-shot measurements
Diffstat (limited to 'src/devices/ads1x1x/mode/continuous.rs')
-rw-r--r--src/devices/ads1x1x/mode/continuous.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/devices/ads1x1x/mode/continuous.rs b/src/devices/ads1x1x/mode/continuous.rs
new file mode 100644
index 0000000..1532b62
--- /dev/null
+++ b/src/devices/ads1x1x/mode/continuous.rs
@@ -0,0 +1,22 @@
+//! Common functions
+
+use core::marker::PhantomData;
+use { Ads1x1x, mode, Error, interface };
+use super::super::OperatingMode;
+
+impl<DI, IC, E> Ads1x1x<DI, IC, mode::Continuous>
+where
+ DI: interface::WriteData<Error = E>
+{
+ /// Change operating mode to OneShot
+ pub fn into_one_shot(mut self) -> Result<Ads1x1x<DI, IC, mode::OneShot>, Error<E>> {
+ self.set_operating_mode(OperatingMode::OneShot)?;
+ Ok(Ads1x1x {
+ iface: self.iface,
+ config: self.config,
+ a_conversion_was_started: self.a_conversion_was_started,
+ _ic: PhantomData,
+ _mode: PhantomData
+ })
+ }
+}