diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/mode/continuous.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/devices/mode/continuous.rs b/src/devices/mode/continuous.rs index 6bf5201..cd3edee 100644 --- a/src/devices/mode/continuous.rs +++ b/src/devices/mode/continuous.rs @@ -1,7 +1,8 @@ -//! Common functions +//! Continuous measurement mode use core::marker::PhantomData; -use { Ads1x1x, mode, Error, interface }; +use { Ads1x1x, conversion, Error, hal, interface, mode, Register }; +use channels::ChannelSelection; use super::super::OperatingMode; impl<DI, IC, CONV, E> Ads1x1x<DI, IC, CONV, mode::Continuous> @@ -29,3 +30,19 @@ where Ok(()) } } + +impl<DI, IC, CONV, E> Ads1x1x<DI, IC, CONV, mode::Continuous> +where + DI: interface::ReadData<Error = E> + interface::WriteData<Error = E>, + CONV: conversion::ConvertMeasurement, +{ + /// Select the channel for measurements. + pub fn select_channel<CH>(&mut self, _channel: &mut CH) -> Result<(), Error<E>> + where + CH: hal::adc::Channel<Ads1x1x<DI, IC, CONV, mode::OneShot>, ID = ChannelSelection> { + let config = self.config.with_mux_bits(CH::channel()); + self.iface.write_register(Register::CONFIG, config.bits)?; + self.config = config; + Ok(()) + } +} |