File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ edition = "2021"
6
6
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
7
8
8
[dependencies ]
9
- embedded-hal = " 1.0.0-rc.1 "
9
+ embedded-hal = " 1.0.0-rc.2 "
10
10
embedded-hal-async = { version = " 1.0.0-rc.1" , optional = true }
11
11
riscv = { git = " https://github.com/rust-embedded/riscv" , branch = " master" }
12
12
Original file line number Diff line number Diff line change 1
1
//! Delay trait implementation for (A)CLINT peripherals
2
2
3
3
use crate :: aclint:: mtimer:: MTIME ;
4
- pub use crate :: hal:: delay:: DelayUs ;
4
+ pub use crate :: hal:: delay:: DelayNs ;
5
5
6
6
/// Delay implementation for (A)CLINT peripherals.
7
7
pub struct Delay {
@@ -35,11 +35,12 @@ impl Delay {
35
35
}
36
36
}
37
37
38
- impl DelayUs for Delay {
38
+ impl DelayNs for Delay {
39
39
#[ inline]
40
- fn delay_us ( & mut self , us : u32 ) {
40
+ fn delay_ns ( & mut self , ns : u32 ) {
41
41
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 ;
43
44
while self . mtime . read ( ) . wrapping_sub ( t0) < n_ticks { }
44
45
}
45
46
}
You can’t perform that action at this time.
0 commit comments