diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2024-12-08 12:01:31 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2024-12-08 12:01:31 +0000 |
commit | cd403a91e6078956445aeb21d6509e863b0592ae (patch) | |
tree | b1bb59ed526081be31494544f8920c39f0588711 /tests/tier2.rs | |
parent | 0edd5527161809dfbc0c76e39c462e3a4f00beb7 (diff) | |
download | ads1x1x-async-async.tar.gz ads1x1x-async-async.tar.xz ads1x1x-async-async.zip |
Modify to use asyncasync
A changeover from embedded_hal::i2c::I2c to embedded_hal_async::i2c::I2c
including changes to all the relevant functions into async functions.
Tests have been updated to work using futures-test and embedded-hal-mock
with the embedded-hal-async feature.
Examples have been kept the same meaning they no longer compile.
Currently it doesn't _seem_ like the linux embedded hal can do async
i2c so maybe these should be re-written to use embassy?
Diffstat (limited to 'tests/tier2.rs')
-rw-r--r-- | tests/tier2.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/tier2.rs b/tests/tier2.rs index e29b67b..270d3ce 100644 --- a/tests/tier2.rs +++ b/tests/tier2.rs @@ -10,11 +10,11 @@ use crate::common::{ macro_rules! set_value_test { ($name:ident, $method:ident, $value:expr, $reg:ident, $msb:expr, $lsb:expr) => { - #[test] - fn $name() { + #[futures_test::test] + async fn $name() { let transactions = [I2cTrans::write(DEV_ADDR, vec![Register::$reg, $msb, $lsb])]; let mut dev = new_ads1014(&transactions); - dev.$method($value).unwrap(); + dev.$method($value).await.unwrap(); destroy_ads1014(dev); } }; @@ -80,8 +80,8 @@ mod can_set_comparator_latching { ); } -#[test] -fn can_disable_comparator() { +#[futures_test::test] +async fn can_disable_comparator() { let config = Config::default() .with_high(BF::COMP_QUE1) .with_high(BF::COMP_QUE0); @@ -90,7 +90,7 @@ fn can_disable_comparator() { vec![Register::CONFIG, config.msb(), config.lsb()], )]; let mut dev = new_ads1014(&transactions); - dev.disable_comparator().unwrap(); + dev.disable_comparator().await.unwrap(); destroy_ads1014(dev); } @@ -122,19 +122,19 @@ mod can_set_comparator_queue { ); } -#[test] -fn can_use_alert_rdy_pin_as_rdy_does_not_disable_comparator_if_already_disabled() { +#[futures_test::test] +async fn can_use_alert_rdy_pin_as_rdy_does_not_disable_comparator_if_already_disabled() { let transactions = [ I2cTrans::write(DEV_ADDR, vec![Register::HIGH_TH, 0b1000_0000, 0]), I2cTrans::write(DEV_ADDR, vec![Register::LOW_TH, 0, 0]), ]; let mut dev = new_ads1014(&transactions); - dev.use_alert_rdy_pin_as_ready().unwrap(); + dev.use_alert_rdy_pin_as_ready().await.unwrap(); destroy_ads1014(dev); } -#[test] -fn can_use_alert_rdy_pin_as_rdy_disabled_comparator() { +#[futures_test::test] +async fn can_use_alert_rdy_pin_as_rdy_disabled_comparator() { let config = Config::default() .with_low(BF::COMP_QUE1) .with_low(BF::COMP_QUE0); @@ -155,8 +155,10 @@ fn can_use_alert_rdy_pin_as_rdy_disabled_comparator() { I2cTrans::write(DEV_ADDR, vec![Register::LOW_TH, 0, 0]), ]; let mut dev = new_ads1014(&transactions); - dev.set_comparator_queue(ComparatorQueue::One).unwrap(); - dev.use_alert_rdy_pin_as_ready().unwrap(); + dev.set_comparator_queue(ComparatorQueue::One) + .await + .unwrap(); + dev.use_alert_rdy_pin_as_ready().await.unwrap(); destroy_ads1014(dev); } |