From d1289bb4d530352a7520eb56851e30a3f63e8b94 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Tue, 19 Dec 2023 19:15:28 +0000 Subject: [PATCH] Upgrade embedded-hal 1.0 dependency to 1.0.0-rc.3 --- rp2040-hal/Cargo.toml | 4 ++-- rp2040-hal/src/gpio/mod.rs | 12 ++++++------ rp2040-hal/src/timer.rs | 10 +++++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/rp2040-hal/Cargo.toml b/rp2040-hal/Cargo.toml index 293120799..0a8b2fc38 100644 --- a/rp2040-hal/Cargo.toml +++ b/rp2040-hal/Cargo.toml @@ -18,8 +18,8 @@ targets = ["thumbv6m-none-eabi"] [dependencies] cortex-m = "0.7.2" embedded-hal = { version = "0.2.5", features = ["unproven"] } -eh1_0_alpha = { package = "embedded-hal", version = "=1.0.0-rc.1", optional = true } -eh_nb_1_0_alpha = { package = "embedded-hal-nb", version = "=1.0.0-rc.1", optional = true } +eh1_0_alpha = { package = "embedded-hal", version = "=1.0.0-rc.3", optional = true } +eh_nb_1_0_alpha = { package = "embedded-hal-nb", version = "=1.0.0-rc.3", optional = true } embedded-dma = "0.2.0" fugit = "0.3.6" itertools = { version = "0.10.1", default-features = false } diff --git a/rp2040-hal/src/gpio/mod.rs b/rp2040-hal/src/gpio/mod.rs index 00923ad12..b54f71f67 100644 --- a/rp2040-hal/src/gpio/mod.rs +++ b/rp2040-hal/src/gpio/mod.rs @@ -1434,11 +1434,11 @@ mod eh1 { I: PinId, P: PullType, { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self._is_set_high()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self._is_set_low()) } } @@ -1459,11 +1459,11 @@ mod eh1 { I: PinId, P: PullType, { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self._is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self._is_low()) } } @@ -1480,11 +1480,11 @@ mod eh1 { impl<'a, I: PinId, F: super::func::Function, P: PullType> InputPin for super::AsInputPin<'a, I, F, P> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.0._is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.0._is_low()) } } diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs index ca6832a3c..402205f7d 100644 --- a/rp2040-hal/src/timer.rs +++ b/rp2040-hal/src/timer.rs @@ -167,7 +167,15 @@ macro_rules! impl_delay_traits { impl_delay_traits!(u8, u16, u32, i32); #[cfg(feature = "eh1_0_alpha")] -impl eh1_0_alpha::delay::DelayUs for Timer { +impl eh1_0_alpha::delay::DelayNs for Timer { + fn delay_ns(&mut self, ns: u32) { + // For now, just use microsecond delay, internally. Of course, this + // might cause a much longer delay than necessary. So a more advanced + // implementation would be desirable for sub-microsecond delays. + let us = ns.div_ceil(1000); + self.delay_us_internal(us) + } + fn delay_us(&mut self, us: u32) { self.delay_us_internal(us) }