Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade embedded-hal 1.0 dependency to 1.0.0-rc.3 #734

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
jannic marked this conversation as resolved.
Show resolved Hide resolved
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
Loading