summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-11 18:01:19 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-11 18:01:19 +0100
commitfbb2099933e6e287d838995836a857127c18efa2 (patch)
tree0245479220872564e33f7884c1995973a903c8fc /tests
parentbc0515cd9960d51fbcf367557b3c102196eb210c (diff)
downloadads1x1x-async-fbb2099933e6e287d838995836a857127c18efa2.tar.gz
ads1x1x-async-fbb2099933e6e287d838995836a857127c18efa2.tar.xz
ads1x1x-async-fbb2099933e6e287d838995836a857127c18efa2.zip
Move data rate tests to tier1 tests
Diffstat (limited to 'tests')
-rw-r--r--tests/ads1x1x_i2c.rs37
-rw-r--r--tests/tier1_i2c.rs26
2 files changed, 25 insertions, 38 deletions
diff --git a/tests/ads1x1x_i2c.rs b/tests/ads1x1x_i2c.rs
deleted file mode 100644
index 9470c01..0000000
--- a/tests/ads1x1x_i2c.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-extern crate embedded_hal;
-extern crate embedded_hal_mock as hal;
-use hal::i2c::Transaction as I2cTrans;
-extern crate ads1x1x;
-use ads1x1x::DataRate12Bit;
-
-#[macro_use]
-mod common;
-use common::{ new_ads1013, destroy_ads1013,
- DEVICE_ADDRESS as DEV_ADDR, Register, BitFlags, Config };
-
-
-macro_rules! test_set_data_rate {
- ($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_ads1013(&transactions);
- dev.set_data_rate(DataRate12Bit::$variant).unwrap();
- destroy_ads1013(dev);
- }
- }
-}
-
-mod data_rate {
- use super::*;
- test_set_data_rate!(sps128, Sps128, Config::default().with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0));
- test_set_data_rate!(sps250, Sps250, Config::default().with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0));
- test_set_data_rate!(sps490, Sps490, Config::default().with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0));
- test_set_data_rate!(sps920, Sps920, Config::default().with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_high(BitFlags::DR0));
- test_set_data_rate!(sps1600, Sps1600, Config::default().with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0));
- test_set_data_rate!(sps2400, Sps2400, Config::default().with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0));
- test_set_data_rate!(sps3300, Sps3300, Config::default().with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0));
-}
-
-
-
diff --git a/tests/tier1_i2c.rs b/tests/tier1_i2c.rs
index 37a68d5..5484a73 100644
--- a/tests/tier1_i2c.rs
+++ b/tests/tier1_i2c.rs
@@ -4,7 +4,7 @@ extern crate embedded_hal;
extern crate embedded_hal_mock as hal;
use hal::i2c::Transaction as I2cTrans;
extern crate ads1x1x;
-use ads1x1x::channel;
+use ads1x1x::{ channel, DataRate12Bit };
#[macro_use]
mod common;
@@ -54,3 +54,27 @@ macro_rules! impl_tests {
impl_tests!(ads1013, new_ads1013, destroy_ads1013, -2048);
impl_tests!(ads1113, new_ads1113, destroy_ads1113, -32768);
+
+
+macro_rules! test_set_data_rate {
+ ($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_ads1013(&transactions);
+ dev.set_data_rate(DataRate12Bit::$variant).unwrap();
+ destroy_ads1013(dev);
+ }
+ }
+}
+
+mod data_rate {
+ use super::*;
+ test_set_data_rate!(sps128, Sps128, Config::default().with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0));
+ test_set_data_rate!(sps250, Sps250, Config::default().with_low( BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0));
+ test_set_data_rate!(sps490, Sps490, Config::default().with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0));
+ test_set_data_rate!(sps920, Sps920, Config::default().with_low( BitFlags::DR2).with_high(BitFlags::DR1).with_high(BitFlags::DR0));
+ test_set_data_rate!(sps1600, Sps1600, Config::default().with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_low( BitFlags::DR0));
+ test_set_data_rate!(sps2400, Sps2400, Config::default().with_high(BitFlags::DR2).with_low( BitFlags::DR1).with_high(BitFlags::DR0));
+ test_set_data_rate!(sps3300, Sps3300, Config::default().with_high(BitFlags::DR2).with_high(BitFlags::DR1).with_low( BitFlags::DR0));
+}