From 5cd361340635aafe8806c82805622bc6afc4c4d7 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 19 Jan 2024 15:09:19 +0100 Subject: Remove `I2cInterface`. (#20) * Merge `ReadData` and `WriteData` traits. * Remove `I2cInterface`. * Update changelog. * Fix links. --- src/devices/mode/continuous.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/devices/mode/continuous.rs') diff --git a/src/devices/mode/continuous.rs b/src/devices/mode/continuous.rs index b3b4807..edc87c2 100644 --- a/src/devices/mode/continuous.rs +++ b/src/devices/mode/continuous.rs @@ -1,25 +1,25 @@ //! Continuous measurement mode use crate::{ - conversion, devices::OperatingMode, interface, mode, Ads1x1x, ChannelId, Error, - ModeChangeError, Register, + conversion, devices::OperatingMode, mode, Ads1x1x, ChannelId, Error, ModeChangeError, Register, }; use core::marker::PhantomData; -impl Ads1x1x +impl Ads1x1x where - DI: interface::ReadData + interface::WriteData, + I2C: embedded_hal::i2c::I2c, CONV: conversion::ConvertMeasurement, { /// Change operating mode to OneShot pub fn into_one_shot( mut self, - ) -> Result, ModeChangeError> { + ) -> Result, ModeChangeError> { if let Err(Error::I2C(e)) = self.set_operating_mode(OperatingMode::OneShot) { return Err(ModeChangeError::I2C(e, self)); } Ok(Ads1x1x { - iface: self.iface, + i2c: self.i2c, + address: self.address, config: self.config, fsr: self.fsr, a_conversion_was_started: false, @@ -31,7 +31,7 @@ where /// Read the most recent measurement pub fn read(&mut self) -> Result> { - let value = self.iface.read_register(Register::CONVERSION)?; + let value = self.read_register(Register::CONVERSION)?; Ok(CONV::convert_measurement(value)) } @@ -43,7 +43,7 @@ where #[allow(unused_variables)] pub fn select_channel>(&mut self, channel: CH) -> Result<(), Error> { let config = self.config.with_mux_bits(CH::channel_id()); - self.iface.write_register(Register::CONFIG, config.bits)?; + self.write_register(Register::CONFIG, config.bits)?; self.config = config; Ok(()) } -- cgit v1.2.3-54-g00ecf