From cd403a91e6078956445aeb21d6509e863b0592ae Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sun, 8 Dec 2024 12:01:31 +0000 Subject: Modify to use async 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? --- tests/mux.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/mux.rs') diff --git a/tests/mux.rs b/tests/mux.rs index ac335b5..1b2575b 100644 --- a/tests/mux.rs +++ b/tests/mux.rs @@ -13,8 +13,8 @@ macro_rules! mux_test { mod $name { use super::*; - #[test] - fn can_read() { + #[futures_test::test] + async fn can_read() { let default_config = Config::default(); let config = Config::default().with_high(BF::OS).with_high($config_bits); let transactions = [ @@ -32,13 +32,13 @@ macro_rules! mux_test { I2cTrans::write_read(DEV_ADDR, vec![Register::CONVERSION], vec![0x80, 0x00]), ]; let mut dev = new(&transactions); - let measurement = block!(dev.read(channel::$CS)).unwrap(); + let measurement = block!(dev.read(channel::$CS).await).unwrap(); assert_eq!(-2048, measurement); destroy(dev); } - #[test] - fn read_then_read_different_triggers_new_measurement() { + #[futures_test::test] + async fn read_then_read_different_triggers_new_measurement() { let default_config = Config::default(); let config = Config::default().with_high(BF::OS).with_high($config_bits); let other_config = Config::default().with_high($other_config_bits); @@ -66,14 +66,14 @@ macro_rules! mux_test { I2cTrans::write_read(DEV_ADDR, vec![Register::CONVERSION], vec![0x80, 0x00]), ]; let mut dev = new(&transactions); - assert_would_block!(dev.read(channel::$CS)); - let measurement = block!(dev.read(channel::$other_CS)).unwrap(); + assert_would_block!(dev.read(channel::$CS).await); + let measurement = block!(dev.read(channel::$other_CS).await).unwrap(); assert_eq!(-2048, measurement); destroy(dev); } - #[test] - fn continuous_can_select_channel() { + #[futures_test::test] + async fn continuous_can_select_channel() { let config1 = Config::default().with_low(BF::OP_MODE); let config2 = config1.with_high($config_bits); let transactions = [ @@ -87,8 +87,8 @@ macro_rules! mux_test { ), ]; let dev = new(&transactions); - let mut dev = dev.into_continuous().ok().unwrap(); - dev.select_channel(channel::$CS).unwrap(); + let mut dev = dev.into_continuous().await.ok().unwrap(); + dev.select_channel(channel::$CS).await.unwrap(); destroy(dev); } } -- cgit v1.2.3-54-g00ecf