diff options
Diffstat (limited to 'tests/tier2_i2c.rs')
-rw-r--r-- | tests/tier2_i2c.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/tier2_i2c.rs b/tests/tier2_i2c.rs index 1eb2871..5a3c950 100644 --- a/tests/tier2_i2c.rs +++ b/tests/tier2_i2c.rs @@ -2,7 +2,7 @@ extern crate embedded_hal; extern crate embedded_hal_mock as hal; use hal::i2c::Transaction as I2cTrans; extern crate ads1x1x; -use ads1x1x::ComparatorMode; +use ads1x1x::{ ComparatorMode, ComparatorPolarity }; #[macro_use] mod common; @@ -21,12 +21,28 @@ macro_rules! test_set_comparator_mode { } } - 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)); } +macro_rules! test_set_comparator_pol { + ($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_polarity(ComparatorPolarity::$variant).unwrap(); + destroy_ads1014(dev); + } + } +} + +mod can_set_comparator_polarity { + use super::*; + test_set_comparator_pol!(low, ActiveLow, Config::default().with_low( BitFlags::COMP_POL)); + test_set_comparator_pol!(high, ActiveHigh, Config::default().with_high(BitFlags::COMP_POL)); +} |