diff options
author | Markus Reiter <me@reitermark.us> | 2024-01-19 15:09:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-19 15:09:19 +0100 |
commit | 5cd361340635aafe8806c82805622bc6afc4c4d7 (patch) | |
tree | e71f39a729a95020ca299925b93d0990416666b7 /src/devices/mode/continuous.rs | |
parent | 6f417d833e2a4041f32a6578332b050d79028910 (diff) | |
download | ads1x1x-async-5cd361340635aafe8806c82805622bc6afc4c4d7.tar.gz ads1x1x-async-5cd361340635aafe8806c82805622bc6afc4c4d7.tar.xz ads1x1x-async-5cd361340635aafe8806c82805622bc6afc4c4d7.zip |
Remove `I2cInterface`. (#20)
* Merge `ReadData` and `WriteData` traits.
* Remove `I2cInterface`.
* Update changelog.
* Fix links.
Diffstat (limited to 'src/devices/mode/continuous.rs')
-rw-r--r-- | src/devices/mode/continuous.rs | 16 |
1 files changed, 8 insertions, 8 deletions
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<DI, IC, CONV, E> Ads1x1x<DI, IC, CONV, mode::Continuous> +impl<I2C, IC, CONV, E> Ads1x1x<I2C, IC, CONV, mode::Continuous> where - DI: interface::ReadData<Error = E> + interface::WriteData<Error = E>, + I2C: embedded_hal::i2c::I2c<Error = E>, CONV: conversion::ConvertMeasurement, { /// Change operating mode to OneShot pub fn into_one_shot( mut self, - ) -> Result<Ads1x1x<DI, IC, CONV, mode::OneShot>, ModeChangeError<E, Self>> { + ) -> Result<Ads1x1x<I2C, IC, CONV, mode::OneShot>, ModeChangeError<E, Self>> { 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<i16, Error<E>> { - 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<CH: ChannelId<Self>>(&mut self, channel: CH) -> Result<(), Error<E>> { 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(()) } |