summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-08 19:04:13 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-08 19:04:13 +0100
commit2c80bf6e016a678728d2255292db708db01172f2 (patch)
tree4c3bde531497a2f6e35a8f46ee4c13d529c2ae70
parentd1065dce04acbc7b46f0dbe105e38c4ba32d4600 (diff)
downloadads1x1x-async-2c80bf6e016a678728d2255292db708db01172f2.tar.gz
ads1x1x-async-2c80bf6e016a678728d2255292db708db01172f2.tar.xz
ads1x1x-async-2c80bf6e016a678728d2255292db708db01172f2.zip
Add tests for setting the thresholds
-rw-r--r--tests/ads1x1x_i2c.rs17
-rw-r--r--tests/common/mod.rs6
2 files changed, 20 insertions, 3 deletions
diff --git a/tests/ads1x1x_i2c.rs b/tests/ads1x1x_i2c.rs
index 0163487..2d8e7e2 100644
--- a/tests/ads1x1x_i2c.rs
+++ b/tests/ads1x1x_i2c.rs
@@ -9,6 +9,23 @@ mod common;
use common::{ new_ads1013, destroy_ads1013,
DEVICE_ADDRESS as DEV_ADDR, Register, BitFlags, Config };
+#[test]
+fn can_set_low_threshold() {
+ let transactions = [ I2cTrans::write(DEV_ADDR, vec![Register::LOW_TH, 0x7F, 0xF0]) ];
+ let mut dev = new_ads1013(&transactions);
+ dev.set_low_threshold(2047).unwrap();
+ destroy_ads1013(dev);
+}
+
+#[test]
+fn can_set_high_threshold() {
+ let transactions = [ I2cTrans::write(DEV_ADDR, vec![Register::HIGH_TH, 0x7F, 0xF0]) ];
+ let mut dev = new_ads1013(&transactions);
+ dev.set_high_threshold(2047).unwrap();
+ destroy_ads1013(dev);
+}
+
+
macro_rules! test_set_data_rate {
($name:ident, $variant:ident, $config:expr) => {
#[test]
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 0a97690..43dfed4 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -5,12 +5,12 @@ use self::ads1x1x::{ Ads1x1x, interface, ic, SlaveAddr, mode };
pub const DEVICE_ADDRESS : u8 = 0b100_1000;
pub struct Register;
-
+#[allow(unused)]
impl Register {
pub const CONVERSION : u8 = 0x00;
pub const CONFIG : u8 = 0x01;
- //const LOW_TH : u8 = 0x02;
- //const HIGH_TH : u8 = 0x03;
+ pub const LOW_TH : u8 = 0x02;
+ pub const HIGH_TH : u8 = 0x03;
}
pub struct BitFlags;