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/oneshot.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/devices/mode/oneshot.rs') diff --git a/src/devices/mode/oneshot.rs b/src/devices/mode/oneshot.rs index 0663e4b..957eba5 100644 --- a/src/devices/mode/oneshot.rs +++ b/src/devices/mode/oneshot.rs @@ -1,24 +1,25 @@ //! Common functions use crate::{ - conversion, devices::OperatingMode, interface, mode, Ads1x1x, BitFlags, ChannelId, - ChannelSelection, Config, DynamicOneShot, Error, ModeChangeError, Register, + conversion, devices::OperatingMode, mode, Ads1x1x, BitFlags, ChannelId, ChannelSelection, + Config, DynamicOneShot, Error, ModeChangeError, Register, }; use core::marker::PhantomData; -impl Ads1x1x +impl Ads1x1x where - DI: interface::WriteData + interface::ReadData, + I2C: embedded_hal::i2c::I2c, CONV: conversion::ConvertMeasurement, { /// Change operating mode to Continuous pub fn into_continuous( mut self, - ) -> Result, ModeChangeError> { + ) -> Result, ModeChangeError> { if let Err(Error::I2C(e)) = self.set_operating_mode(OperatingMode::Continuous) { 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: true, @@ -30,13 +31,13 @@ where fn trigger_measurement(&mut self, config: &Config) -> Result<(), Error> { let config = config.with_high(BitFlags::OS); - self.iface.write_register(Register::CONFIG, config.bits) + self.write_register(Register::CONFIG, config.bits) } } -impl Ads1x1x +impl Ads1x1x where - DI: interface::ReadData + interface::WriteData, + I2C: embedded_hal::i2c::I2c, CONV: conversion::ConvertMeasurement, { fn read_inner(&mut self, channel: ChannelSelection) -> nb::Result> { @@ -51,7 +52,6 @@ where if self.a_conversion_was_started && same_channel { // result is ready let value = self - .iface .read_register(Register::CONVERSION) .map_err(nb::Error::Other)?; self.a_conversion_was_started = false; @@ -83,9 +83,9 @@ where } } -impl DynamicOneShot for Ads1x1x +impl DynamicOneShot for Ads1x1x where - DI: interface::ReadData + interface::WriteData, + I2C: embedded_hal::i2c::I2c, CONV: conversion::ConvertMeasurement, { type Error = Error; -- cgit v1.2.3-54-g00ecf