diff --git a/Cargo.toml b/Cargo.toml index 464d11b..bb740e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,11 @@ categories = ["embedded", "no-std"] license = "MIT/Apache-2.0" [dependencies] -embedded-hal = "0.2.3" +nb = "0.1.2" + +[dependencies.embedded-hal] +version = "0.2.3" +features=["unproven"] [dev-dependencies] embedded-hal-mock = "0.7.0" diff --git a/src/proxy.rs b/src/proxy.rs index 844249a..5a93713 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -1,3 +1,4 @@ +use hal::adc::{Channel, OneShot}; use hal::blocking::i2c; use hal::blocking::spi; @@ -151,3 +152,19 @@ where }) } } + +impl<'a, M, ADC, WORD, PIN, AS: OneShot> OneShot + for BusProxy<'a, M, AS> +where + PIN: Channel, + M: 'a + mutex::BusMutex>, +{ + type Error = AS::Error; + + fn read(&mut self, pin: &mut PIN) -> nb::Result { + self.0.lock(|lock| { + let mut i = lock.borrow_mut(); + i.read(pin) + }) + } +}