From 2a2f25b35c8411a5932e576b5d0969d3928c7209 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Tue, 20 Nov 2018 19:07:16 +0100 Subject: Add function to select the measurement channel in continuous mode --- src/devices/mode/continuous.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/devices') 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 Ads1x1x @@ -29,3 +30,19 @@ where Ok(()) } } + +impl Ads1x1x +where + DI: interface::ReadData + interface::WriteData, + CONV: conversion::ConvertMeasurement, +{ + /// Select the channel for measurements. + pub fn select_channel(&mut self, _channel: &mut CH) -> Result<(), Error> + where + CH: hal::adc::Channel, ID = ChannelSelection> { + let config = self.config.with_mux_bits(CH::channel()); + self.iface.write_register(Register::CONFIG, config.bits)?; + self.config = config; + Ok(()) + } +} -- cgit v1.2.3-54-g00ecf