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/construction.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/construction.rs') diff --git a/src/construction.rs b/src/construction.rs index d6463df..7ac128f 100644 --- a/src/construction.rs +++ b/src/construction.rs @@ -1,24 +1,19 @@ //! Constructor/destructor functions. -use crate::{ - ic, interface::I2cInterface, mode, Ads1x1x, Config, FullScaleRange, SlaveAddr, - DEVICE_BASE_ADDRESS, -}; +use crate::{ic, mode, Ads1x1x, Config, FullScaleRange, SlaveAddr, DEVICE_BASE_ADDRESS}; use core::marker::PhantomData; macro_rules! impl_new_destroy { ( $IC:ident, $create:ident, $destroy:ident, $conv:ty ) => { - impl Ads1x1x, ic::$IC, $conv, mode::OneShot> + impl Ads1x1x where I2C: embedded_hal::i2c::I2c, { /// Create a new instance of the device in OneShot mode. pub fn $create(i2c: I2C, address: SlaveAddr) -> Self { Ads1x1x { - iface: I2cInterface { - i2c, - address: address.addr(DEVICE_BASE_ADDRESS), - }, + i2c, + address: address.addr(DEVICE_BASE_ADDRESS), config: Config::default(), fsr: FullScaleRange::default(), a_conversion_was_started: false, @@ -28,10 +23,10 @@ macro_rules! impl_new_destroy { } } } - impl Ads1x1x, ic::$IC, CONV, MODE> { + impl Ads1x1x { /// Destroy driver instance, return I²C bus instance. pub fn $destroy(self) -> I2C { - self.iface.i2c + self.i2c } } }; -- cgit v1.2.3-54-g00ecf