diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-21 09:35:37 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-21 09:35:37 +0100 |
commit | 5485d9655e2ab3a6d04e5f69b246f5db4d2c5936 (patch) | |
tree | 84bb1e825656d4c523b65edc5d7780fbb060c8cc /src/interface.rs | |
parent | e4a1ac5a04d021ef026c559354e9913ae59864d8 (diff) | |
download | ads1x1x-async-5485d9655e2ab3a6d04e5f69b246f5db4d2c5936.tar.gz ads1x1x-async-5485d9655e2ab3a6d04e5f69b246f5db4d2c5936.tar.xz ads1x1x-async-5485d9655e2ab3a6d04e5f69b246f5db4d2c5936.zip |
Code formatting
Diffstat (limited to 'src/interface.rs')
-rw-r--r-- | src/interface.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/interface.rs b/src/interface.rs index 2ef42fc..36458b4 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -2,18 +2,17 @@ extern crate embedded_hal as hal; use hal::blocking; -use { private, Error }; - +use {private, Error}; /// I2C interface #[derive(Debug, Default)] pub struct I2cInterface<I2C> { pub(crate) i2c: I2C, - pub(crate) address : u8, + pub(crate) address: u8, } /// Write data -pub trait WriteData : private::Sealed { +pub trait WriteData: private::Sealed { /// Error type type Error; /// Write to an u16 register @@ -22,19 +21,17 @@ pub trait WriteData : private::Sealed { impl<I2C, E> WriteData for I2cInterface<I2C> where - I2C: blocking::i2c::Write<Error = E> + I2C: blocking::i2c::Write<Error = E>, { type Error = E; fn write_register(&mut self, register: u8, data: u16) -> Result<(), Error<E>> { let payload: [u8; 3] = [register, (data >> 8) as u8, data as u8]; - self.i2c - .write(self.address, &payload) - .map_err(Error::I2C) + self.i2c.write(self.address, &payload).map_err(Error::I2C) } } /// Read data -pub trait ReadData : private::Sealed { +pub trait ReadData: private::Sealed { /// Error type type Error; /// Read an u16 register @@ -43,7 +40,7 @@ pub trait ReadData : private::Sealed { impl<I2C, E> ReadData for I2cInterface<I2C> where - I2C: blocking::i2c::WriteRead<Error = E> + I2C: blocking::i2c::WriteRead<Error = E>, { type Error = E; fn read_register(&mut self, register: u8) -> Result<u16, Error<E>> { |