Skip to content

Commit

Permalink
Merge pull request #734 from jannic/eh-1.0-rc3
Browse files Browse the repository at this point in the history
Upgrade embedded-hal 1.0 dependency to 1.0.0-rc.3
  • Loading branch information
jannic authored Dec 19, 2023
2 parents 85474db + 87e2fb6 commit 935c92a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions rp2040-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
12 changes: 6 additions & 6 deletions rp2040-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,11 +1434,11 @@ mod eh1 {
I: PinId,
P: PullType,
{
fn is_set_high(&self) -> Result<bool, Self::Error> {
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
Ok(self._is_set_high())
}

fn is_set_low(&self) -> Result<bool, Self::Error> {
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
Ok(self._is_set_low())
}
}
Expand All @@ -1459,11 +1459,11 @@ mod eh1 {
I: PinId,
P: PullType,
{
fn is_high(&self) -> Result<bool, Self::Error> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
Ok(self._is_high())
}

fn is_low(&self) -> Result<bool, Self::Error> {
fn is_low(&mut self) -> Result<bool, Self::Error> {
Ok(self._is_low())
}
}
Expand All @@ -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<bool, Self::Error> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
Ok(self.0._is_high())
}

fn is_low(&self) -> Result<bool, Self::Error> {
fn is_low(&mut self) -> Result<bool, Self::Error> {
Ok(self.0._is_low())
}
}
Expand Down
18 changes: 17 additions & 1 deletion rp2040-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,26 @@ 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 / 1000 + if ns % 1000 == 0 { 0 } else { 1 };
// With rustc 1.73, this can be replaced by:
// let us = ns.div_ceil(1000);
self.delay_us_internal(us)
}

fn delay_us(&mut self, us: u32) {
self.delay_us_internal(us)
}

fn delay_ms(&mut self, ms: u32) {
for _ in 0..ms {
self.delay_us_internal(1000);
}
}
}

/// Implementation of the embedded_hal::Timer traits using rp2040_hal::timer counter
Expand Down

0 comments on commit 935c92a

Please sign in to comment.