summaryrefslogtreecommitdiffstats
path: root/tests/tier2_i2c.rs
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-08 19:08:57 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-08 19:08:57 +0100
commitdf30ade977dceef79b69fa8d7fe193bcc23d35c3 (patch)
tree98ceee01369a5a2ebd9f1e80f8b09bc271c3f01f /tests/tier2_i2c.rs
parente316baaf8ca226caa2447041e1d895fb72ed4f19 (diff)
downloadads1x1x-async-df30ade977dceef79b69fa8d7fe193bcc23d35c3.tar.gz
ads1x1x-async-df30ade977dceef79b69fa8d7fe193bcc23d35c3.tar.xz
ads1x1x-async-df30ade977dceef79b69fa8d7fe193bcc23d35c3.zip
Add support for setting the comparator mode
Diffstat (limited to 'tests/tier2_i2c.rs')
-rw-r--r--tests/tier2_i2c.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/tier2_i2c.rs b/tests/tier2_i2c.rs
new file mode 100644
index 0000000..1eb2871
--- /dev/null
+++ b/tests/tier2_i2c.rs
@@ -0,0 +1,32 @@
+extern crate embedded_hal;
+extern crate embedded_hal_mock as hal;
+use hal::i2c::Transaction as I2cTrans;
+extern crate ads1x1x;
+use ads1x1x::ComparatorMode;
+
+#[macro_use]
+mod common;
+use common::{ new_ads1014, destroy_ads1014,
+ DEVICE_ADDRESS as DEV_ADDR, Register, BitFlags, Config };
+
+macro_rules! test_set_comparator_mode {
+ ($name:ident, $variant:ident, $config:expr) => {
+ #[test]
+ fn $name() {
+ let transactions = [ I2cTrans::write(DEV_ADDR, vec![Register::CONFIG, $config.msb(), $config.lsb()]) ];
+ let mut dev = new_ads1014(&transactions);
+ dev.set_comparator_mode(ComparatorMode::$variant).unwrap();
+ destroy_ads1014(dev);
+ }
+ }
+}
+
+
+mod can_set_comparator_mode {
+ use super::*;
+ test_set_comparator_mode!(traditional, Traditional, Config::default().with_low( BitFlags::COMP_MODE));
+ test_set_comparator_mode!(window, Window, Config::default().with_high(BitFlags::COMP_MODE));
+}
+
+
+