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/devices/features/tier1.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/devices/features/tier1.rs')
-rw-r--r-- | src/devices/features/tier1.rs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/devices/features/tier1.rs b/src/devices/features/tier1.rs index 16ed96c..6bd1a99 100644 --- a/src/devices/features/tier1.rs +++ b/src/devices/features/tier1.rs @@ -1,6 +1,6 @@ //! Common functions -use { Ads1x1x, DataRate12Bit, DataRate16Bit, Error, Register, BitFlags, interface, ic }; +use {ic, interface, Ads1x1x, BitFlags as BF, DataRate12Bit, DataRate16Bit, Error, Register}; impl<DI, IC, MODE, E> Ads1x1x<DI, IC, ic::Resolution12Bit, MODE> where @@ -8,15 +8,16 @@ where { /// Set data rate pub fn set_data_rate(&mut self, rate: DataRate12Bit) -> Result<(), Error<E>> { + use DataRate12Bit as DR; let config; match rate { - DataRate12Bit::Sps128 => config = self.config.with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0), - DataRate12Bit::Sps250 => config = self.config.with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0), - DataRate12Bit::Sps490 => config = self.config.with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0), - DataRate12Bit::Sps920 => config = self.config.with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_high(BitFlags::DR0), - DataRate12Bit::Sps1600 => config = self.config.with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0), - DataRate12Bit::Sps2400 => config = self.config.with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0), - DataRate12Bit::Sps3300 => config = self.config.with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0), + DR::Sps128 => config = self.config.with_low( BF::DR2).with_low( BF::DR1).with_low( BF::DR0), + DR::Sps250 => config = self.config.with_low( BF::DR2).with_low( BF::DR1).with_high(BF::DR0), + DR::Sps490 => config = self.config.with_low( BF::DR2).with_high(BF::DR1).with_low( BF::DR0), + DR::Sps920 => config = self.config.with_low( BF::DR2).with_high(BF::DR1).with_high(BF::DR0), + DR::Sps1600 => config = self.config.with_high(BF::DR2).with_low( BF::DR1).with_low( BF::DR0), + DR::Sps2400 => config = self.config.with_high(BF::DR2).with_low( BF::DR1).with_high(BF::DR0), + DR::Sps3300 => config = self.config.with_high(BF::DR2).with_high(BF::DR1).with_low( BF::DR0), } self.iface.write_register(Register::CONFIG, config.bits)?; self.config = config; @@ -30,16 +31,17 @@ where { /// Set data rate pub fn set_data_rate(&mut self, rate: DataRate16Bit) -> Result<(), Error<E>> { + use DataRate16Bit as DR; let config; match rate { - DataRate16Bit::Sps8 => config = self.config.with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0), - DataRate16Bit::Sps16 => config = self.config.with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0), - DataRate16Bit::Sps32 => config = self.config.with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0), - DataRate16Bit::Sps64 => config = self.config.with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_high(BitFlags::DR0), - DataRate16Bit::Sps128 => config = self.config.with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0), - DataRate16Bit::Sps250 => config = self.config.with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0), - DataRate16Bit::Sps475 => config = self.config.with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0), - DataRate16Bit::Sps860 => config = self.config.with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_high(BitFlags::DR0), + DR::Sps8 => config = self.config.with_low( BF::DR2).with_low( BF::DR1).with_low( BF::DR0), + DR::Sps16 => config = self.config.with_low( BF::DR2).with_low( BF::DR1).with_high(BF::DR0), + DR::Sps32 => config = self.config.with_low( BF::DR2).with_high(BF::DR1).with_low( BF::DR0), + DR::Sps64 => config = self.config.with_low( BF::DR2).with_high(BF::DR1).with_high(BF::DR0), + DR::Sps128 => config = self.config.with_high(BF::DR2).with_low( BF::DR1).with_low( BF::DR0), + DR::Sps250 => config = self.config.with_high(BF::DR2).with_low( BF::DR1).with_high(BF::DR0), + DR::Sps475 => config = self.config.with_high(BF::DR2).with_high(BF::DR1).with_low( BF::DR0), + DR::Sps860 => config = self.config.with_high(BF::DR2).with_high(BF::DR1).with_high(BF::DR0), } self.iface.write_register(Register::CONFIG, config.bits)?; self.config = config; |