diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-17 07:47:40 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-17 07:47:40 +0100 |
commit | 5f58ec2dbf656e9c29e14c28103a87c125797d52 (patch) | |
tree | 40f6903ef8eaa2ae10b0d05b6bd6479ada2332a9 /tests | |
parent | 3301638b091780c73fdbfba05be051507cd5b382 (diff) | |
download | ads1x1x-async-5f58ec2dbf656e9c29e14c28103a87c125797d52.tar.gz ads1x1x-async-5f58ec2dbf656e9c29e14c28103a87c125797d52.tar.xz ads1x1x-async-5f58ec2dbf656e9c29e14c28103a87c125797d52.zip |
Add mode conversion tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/common/mod.rs | 2 | ||||
-rw-r--r-- | tests/tier1_i2c.rs | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs index dc66431..ee78ffe 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -16,11 +16,11 @@ impl Register { pub struct BitFlags; #[allow(unused)] impl BitFlags { - //pub const OP_MODE : u16 = 0b0000_0001_0000_0000; pub const OS : u16 = 0b1000_0000_0000_0000; pub const MUX2 : u16 = 0b0100_0000_0000_0000; pub const MUX1 : u16 = 0b0010_0000_0000_0000; pub const MUX0 : u16 = 0b0001_0000_0000_0000; + pub const OP_MODE : u16 = 0b0000_0001_0000_0000; pub const DR2 : u16 = 0b0000_0000_1000_0000; pub const DR1 : u16 = 0b0000_0000_0100_0000; pub const DR0 : u16 = 0b0000_0000_0010_0000; diff --git a/tests/tier1_i2c.rs b/tests/tier1_i2c.rs index 15e5514..5ffff60 100644 --- a/tests/tier1_i2c.rs +++ b/tests/tier1_i2c.rs @@ -97,3 +97,24 @@ mod data_rate_16bit { test!(sps475, Sps475, Config::default().with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0)); test!(sps860, Sps860, Config::default().with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_high(BitFlags::DR0)); } + +#[test] +fn can_convert_to_continuous() { + let config = Config::default().with_low(BitFlags::OP_MODE); + let transactions = [ I2cTrans::write(DEV_ADDR, vec![Register::CONFIG, config.msb(), config.lsb()]) ]; + let dev = new_ads1013(&transactions); + let dev = dev.into_continuous().unwrap(); + destroy_ads1013(dev); +} + +#[test] +fn can_convert_to_one_shot() { + let config_cont = Config::default().with_low(BitFlags::OP_MODE); + let config_os = Config::default(); + let transactions = [ I2cTrans::write(DEV_ADDR, vec![Register::CONFIG, config_cont.msb(), config_cont.lsb()]), + I2cTrans::write(DEV_ADDR, vec![Register::CONFIG, config_os.msb(), config_os.lsb()]) ]; + let dev = new_ads1013(&transactions); + let dev = dev.into_continuous().unwrap(); + let dev = dev.into_one_shot().unwrap(); + destroy_ads1013(dev); +} |