Skip to content

Commit 205b197

Browse files
Merge pull request #2 from purplethunder/embedded-hal-1.0.0-rc.2
Track DelayNs changes in embedded-hal-1.0.0-rc.2
2 parents 147285e + a74f311 commit 205b197

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
embedded-hal = "1.0.0-rc.1"
9+
embedded-hal = "1.0.0-rc.2"
1010
embedded-hal-async = { version = "1.0.0-rc.1", optional = true }
1111
riscv = { git = "https://github.com/rust-embedded/riscv", branch = "master" }
1212

src/hal/aclint.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Delay trait implementation for (A)CLINT peripherals
22
33
use crate::aclint::mtimer::MTIME;
4-
pub use crate::hal::delay::DelayUs;
4+
pub use crate::hal::delay::DelayNs;
55

66
/// Delay implementation for (A)CLINT peripherals.
77
pub struct Delay {
@@ -35,11 +35,12 @@ impl Delay {
3535
}
3636
}
3737

38-
impl DelayUs for Delay {
38+
impl DelayNs for Delay {
3939
#[inline]
40-
fn delay_us(&mut self, us: u32) {
40+
fn delay_ns(&mut self, ns: u32) {
4141
let t0 = self.mtime.read();
42-
let n_ticks = us as u64 * self.freq as u64 / 1_000_000;
42+
let ns_64: u64 = ns.into();
43+
let n_ticks = ns_64 * self.freq as u64 / 1_000_000_000;
4344
while self.mtime.read().wrapping_sub(t0) < n_ticks {}
4445
}
4546
}

0 commit comments

Comments
 (0)