From 9d5637b6d6d1e019e736ffbc6b983a4735aa50e1 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Wed, 21 Nov 2018 08:00:08 +0100 Subject: Remove SPI interface --- src/interface.rs | 45 --------------------------------------------- src/lib.rs | 1 - 2 files changed, 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 { pub(crate) address : u8, } -/// SPI interface -#[derive(Debug, Default)] -pub struct SpiInterface { - pub(crate) spi: SPI, - pub(crate) cs: CS -} - /// Write data pub trait WriteData : private::Sealed { /// Error type @@ -40,26 +33,6 @@ where } } -impl WriteData for SpiInterface -where - SPI: blocking::spi::Write, - CS: hal::digital::OutputPin -{ - type Error = E; - fn write_register(&mut self, register: u8, data: u16) -> Result<(), Error> { - 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 ReadData for SpiInterface -where - SPI: blocking::spi::Transfer, - CS: hal::digital::OutputPin -{ - type Error = E; - fn read_register(&mut self, register: u8) -> Result> { - 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 Sealed for interface::I2cInterface {} - impl Sealed for interface::SpiInterface {} impl Sealed for ic::Resolution12Bit {} impl Sealed for ic::Resolution16Bit {} -- cgit v1.2.3-54-g00ecf