summaryrefslogtreecommitdiffstats
path: root/src/construction/i2c.rs
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-11 17:32:52 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-11 17:32:52 +0100
commitfce3d8546bd619964ec5dd1594cd93e744a99521 (patch)
tree7bc17d465652c86b25b9fb34ccd7ed3bf0218b56 /src/construction/i2c.rs
parentb9b5349b4b78a5d59be4a7e4a11f712e2f6a8256 (diff)
downloadads1x1x-async-fce3d8546bd619964ec5dd1594cd93e744a99521.tar.gz
ads1x1x-async-fce3d8546bd619964ec5dd1594cd93e744a99521.tar.xz
ads1x1x-async-fce3d8546bd619964ec5dd1594cd93e744a99521.zip
Implement value conversions over type parameter
Diffstat (limited to 'src/construction/i2c.rs')
-rw-r--r--src/construction/i2c.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/construction/i2c.rs b/src/construction/i2c.rs
index 9ef18eb..3ec474b 100644
--- a/src/construction/i2c.rs
+++ b/src/construction/i2c.rs
@@ -8,8 +8,8 @@ use interface::I2cInterface;
macro_rules! impl_new_destroy {
- ( $IC:ident, $create:ident, $destroy:ident ) => {
- impl<I2C, E> Ads1x1x<I2cInterface<I2C>, ic::$IC, mode::OneShot>
+ ( $IC:ident, $create:ident, $destroy:ident, $conv:ty, $converter:expr ) => {
+ impl<I2C, E> Ads1x1x<I2cInterface<I2C>, ic::$IC, $conv, mode::OneShot>
where
I2C: blocking::i2c::Write<Error = E> + blocking::i2c::WriteRead<Error = E>
{
@@ -22,12 +22,13 @@ macro_rules! impl_new_destroy {
},
config: Config::default(),
a_conversion_was_started: false,
+ converter: $converter(()),
_ic: PhantomData,
_mode: PhantomData
}
}
}
- impl<I2C, MODE> Ads1x1x<I2cInterface<I2C>, ic::$IC, MODE>
+ impl<I2C, CONV, MODE> Ads1x1x<I2cInterface<I2C>, ic::$IC, CONV, MODE>
{
/// Destroy driver instance, return I²C bus instance.
pub fn $destroy(self) -> I2C {
@@ -37,9 +38,9 @@ macro_rules! impl_new_destroy {
}
}
-impl_new_destroy!(Ads1013, new_ads1013, destroy_ads1013);
-impl_new_destroy!(Ads1113, new_ads1113, destroy_ads1113);
-impl_new_destroy!(Ads1014, new_ads1014, destroy_ads1014);
-impl_new_destroy!(Ads1114, new_ads1114, destroy_ads1114);
-impl_new_destroy!(Ads1015, new_ads1015, destroy_ads1015);
-impl_new_destroy!(Ads1115, new_ads1115, destroy_ads1115);
+impl_new_destroy!(Ads1013, new_ads1013, destroy_ads1013, ic::Resolution12Bit, ic::Resolution12Bit);
+impl_new_destroy!(Ads1113, new_ads1113, destroy_ads1113, ic::Resolution16Bit, ic::Resolution16Bit);
+impl_new_destroy!(Ads1014, new_ads1014, destroy_ads1014, ic::Resolution12Bit, ic::Resolution12Bit);
+impl_new_destroy!(Ads1114, new_ads1114, destroy_ads1114, ic::Resolution16Bit, ic::Resolution16Bit);
+impl_new_destroy!(Ads1015, new_ads1015, destroy_ads1015, ic::Resolution12Bit, ic::Resolution12Bit);
+impl_new_destroy!(Ads1115, new_ads1115, destroy_ads1115, ic::Resolution16Bit, ic::Resolution16Bit);