summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-21 08:00:08 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-21 08:00:08 +0100
commit9d5637b6d6d1e019e736ffbc6b983a4735aa50e1 (patch)
tree1013c700a1b97afa94a4cbf3ea743fd0885d4d18
parent6705cef10d2cf3f8009430ae032adfb5d8fe6797 (diff)
downloadads1x1x-async-9d5637b6d6d1e019e736ffbc6b983a4735aa50e1.tar.gz
ads1x1x-async-9d5637b6d6d1e019e736ffbc6b983a4735aa50e1.tar.xz
ads1x1x-async-9d5637b6d6d1e019e736ffbc6b983a4735aa50e1.zip
Remove SPI interface
-rw-r--r--src/interface.rs45
-rw-r--r--src/lib.rs1
2 files changed, 0 insertions, 46 deletions
diff --git a/src/interface.rs b/src/interface.rs
index d22f776..3b42182 100644
--- a/src/interface.rs
+++ b/src/interface.rs
@@ -12,13 +12,6 @@ pub struct I2cInterface<I2C> {
pub(crate) address : u8,
}
-/// SPI interface
-#[derive(Debug, Default)]
-pub struct SpiInterface<SPI, CS> {
- pub(crate) spi: SPI,
- pub(crate) cs: CS
-}
-
/// Write data
pub trait WriteData : private::Sealed {
/// Error type
@@ -40,26 +33,6 @@ where
}
}
-impl<SPI, CS, E> WriteData for SpiInterface<SPI, CS>
-where
- SPI: blocking::spi::Write<u8, Error = E>,
- CS: hal::digital::OutputPin
-{
- type Error = E;
- fn write_register(&mut self, register: u8, data: u16) -> Result<(), Error<E>> {
- self.cs.set_low();
-
- let payload: [u8; 3] = [register + 0x80, (data >> 8) as u8, data as u8];
- let result = self.spi
- .write(&payload)
- .map_err(Error::Comm);
-
- self.cs.set_high();
- result
- }
-}
-
-
/// Read data
pub trait ReadData : private::Sealed {
/// Error type
@@ -81,21 +54,3 @@ where
.and(Ok((u16::from(data[0]) << 8) | u16::from(data[1])))
}
}
-
-impl<SPI, CS, E> ReadData for SpiInterface<SPI, CS>
-where
- SPI: blocking::spi::Transfer<u8, Error = E>,
- CS: hal::digital::OutputPin
-{
- type Error = E;
- fn read_register(&mut self, register: u8) -> Result<u16, Error<E>> {
- self.cs.set_low();
- let mut data = [register, 0, 0];
- let result = self.spi
- .transfer(&mut data)
- .map_err(Error::Comm);
- self.cs.set_high();
- let result = result?;
- Ok((u16::from(result[0]) << 8) | u16::from(result[1]))
- }
-}
diff --git a/src/lib.rs b/src/lib.rs
index 5e94b43..d92f8bb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -459,7 +459,6 @@ mod private {
pub trait Sealed {}
impl<I2C> Sealed for interface::I2cInterface<I2C> {}
- impl<SPI, CS> Sealed for interface::SpiInterface<SPI, CS> {}
impl Sealed for ic::Resolution12Bit {}
impl Sealed for ic::Resolution16Bit {}