summaryrefslogtreecommitdiffstats
path: root/src/devices/features/tier1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/features/tier1.rs')
-rw-r--r--src/devices/features/tier1.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/devices/features/tier1.rs b/src/devices/features/tier1.rs
index 30e900e..bd19419 100644
--- a/src/devices/features/tier1.rs
+++ b/src/devices/features/tier1.rs
@@ -1,8 +1,29 @@
//! Common functions
-use { Ads1x1x, DataRate, Error, Register, BitFlags, interface };
+use { Ads1x1x, DataRate12Bit, Error, Register, BitFlags, interface, ic };
+
+impl<DI, IC, MODE, E> Ads1x1x<DI, IC, ic::Resolution12Bit, MODE>
+where
+ DI: interface::WriteData<Error = E>,
+{
+ /// Set data rate
+ pub fn set_data_rate(&mut self, rate: DataRate12Bit) -> Result<(), Error<E>> {
+ 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),
+ }
+ self.iface.write_register(Register::CONFIG, config.bits)?;
+ self.config = config;
+ Ok(())
+ }
+}
-impl<DI, IC, CONV, MODE, E> Ads1x1x<DI, IC, CONV, MODE>
where
DI: interface::WriteData<Error = E>
{