summaryrefslogtreecommitdiffstats
path: root/src/construction.rs
diff options
context:
space:
mode:
authorMarkus Reiter <me@reitermark.us>2024-01-19 15:09:19 +0100
committerGitHub <noreply@github.com>2024-01-19 15:09:19 +0100
commit5cd361340635aafe8806c82805622bc6afc4c4d7 (patch)
treee71f39a729a95020ca299925b93d0990416666b7 /src/construction.rs
parent6f417d833e2a4041f32a6578332b050d79028910 (diff)
downloadads1x1x-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/construction.rs')
-rw-r--r--src/construction.rs17
1 files changed, 6 insertions, 11 deletions
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<I2C, E> Ads1x1x<I2cInterface<I2C>, ic::$IC, $conv, mode::OneShot>
+ impl<I2C, E> Ads1x1x<I2C, ic::$IC, $conv, mode::OneShot>
where
I2C: embedded_hal::i2c::I2c<Error = E>,
{
/// 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<I2C, CONV, MODE> Ads1x1x<I2cInterface<I2C>, ic::$IC, CONV, MODE> {
+ impl<I2C, CONV, MODE> Ads1x1x<I2C, ic::$IC, CONV, MODE> {
/// Destroy driver instance, return I²C bus instance.
pub fn $destroy(self) -> I2C {
- self.iface.i2c
+ self.i2c
}
}
};