diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-04 21:32:46 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-04 21:32:46 +0100 |
commit | 5a5d08f92768c48949cb175605055b853e559c5c (patch) | |
tree | db71b7805fbb47acc57c09f7a659f9dc205ed47d /src/devices | |
download | ads1x1x-async-5a5d08f92768c48949cb175605055b853e559c5c.tar.gz ads1x1x-async-5a5d08f92768c48949cb175605055b853e559c5c.tar.xz ads1x1x-async-5a5d08f92768c48949cb175605055b853e559c5c.zip |
Initial version
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/ads1013.rs | 28 | ||||
-rw-r--r-- | src/devices/mod.rs | 19 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/devices/ads1013.rs b/src/devices/ads1013.rs new file mode 100644 index 0000000..b4628b5 --- /dev/null +++ b/src/devices/ads1013.rs @@ -0,0 +1,28 @@ +//! Functions exclusive of ADS1013 + +extern crate embedded_hal as hal; +use hal::blocking; +use core::marker::PhantomData; +use { Ads1x1x, DEVICE_BASE_ADDRESS, SlaveAddr, ic }; +use interface::I2cInterface; + +impl<I2C, E> Ads1x1x<I2cInterface<I2C>, ic::ADS1013> +where + I2C: blocking::i2c::Write<Error = E> + blocking::i2c::WriteRead<Error = E> +{ + /// Create a new instance of the ADS1013 device. + pub fn new_ads1013(i2c: I2C, address: SlaveAddr) -> Self { + Ads1x1x { + iface: I2cInterface { + i2c, + address: address.addr(DEVICE_BASE_ADDRESS) + }, + _ic: PhantomData + } + } + + /// Destroy driver instance, return I²C bus instance. + pub fn destroy_ads1013(self) -> I2C { + self.iface.i2c + } +} diff --git a/src/devices/mod.rs b/src/devices/mod.rs new file mode 100644 index 0000000..529db04 --- /dev/null +++ b/src/devices/mod.rs @@ -0,0 +1,19 @@ +/// IC markers +pub mod ic { + /// ADS1013 IC marker + pub struct ADS1013; + /// ADS1014 IC marker + pub struct ADS1014; + /// ADS1015 IC marker + pub struct ADS1015; + /// ADS1113 IC marker + pub struct ADS1113; + /// ADS1114 IC marker + pub struct ADS1114; + /// ADS1115 IC marker + pub struct ADS1115; + /// ADS1118 IC marker + pub struct ADS1118; +} + +mod ads1013; |