blob: b4628b5fe30290b53351e78d74a00727eefbef46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}
}
|