File tree 4 files changed +24
-11
lines changed
4 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Changed
11
+ - Updated to ` embedded-hal ` ` 1.0.0-rc.2 ` release ([ API changes] ( https://github.com/rust-embedded/embedded-hal/blob/master/embedded-hal/CHANGELOG.md#v100-rc2---2023-11-28 ) )
12
+ - Updated to ` embedded-hal-nb ` ` 1.0.0-rc.2 ` release ([ API changes] ( https://github.com/rust-embedded/embedded-hal/blob/master/embedded-hal-nb/CHANGELOG.md#v100-rc2---2023-11-28 ) )
13
+
14
+
10
15
## [ v0.4.0-alpha.4] - 2023-11-10
11
16
12
17
### Changed
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ spi = ["spidev"]
22
22
default = [ " gpio_cdev" , " gpio_sysfs" , " i2c" , " spi" ]
23
23
24
24
[dependencies ]
25
- embedded-hal = " =1.0.0-rc.1 "
26
- embedded-hal-nb = " =1.0.0-rc.1 "
25
+ embedded-hal = " =1.0.0-rc.2 "
26
+ embedded-hal-nb = " =1.0.0-rc.2 "
27
27
gpio-cdev = { version = " 0.5.1" , optional = true }
28
28
sysfs_gpio = { version = " 0.6.1" , optional = true }
29
29
i2cdev = { version = " 0.6.0" , optional = true }
Original file line number Diff line number Diff line change 3
3
//! [`embedded-hal`]: https://docs.rs/embedded-hal
4
4
5
5
use cast:: u64;
6
- use embedded_hal:: delay:: DelayUs ;
6
+ use embedded_hal:: delay:: DelayNs ;
7
7
use std:: thread;
8
8
use std:: time:: Duration ;
9
9
10
10
/// Empty struct that provides delay functionality on top of `thread::sleep`
11
11
pub struct Delay ;
12
12
13
- impl DelayUs for Delay {
14
- fn delay_us ( & mut self , n : u32 ) {
15
- let secs = n / 1_000_000 ;
16
- let nsecs = ( n % 1_000_000 ) * 1_000 ;
17
-
18
- thread:: sleep ( Duration :: new ( u64 ( secs) , nsecs) ) ;
13
+ impl DelayNs for Delay {
14
+ fn delay_ns ( & mut self , n : u32 ) {
15
+ thread:: sleep ( Duration :: from_nanos ( u64 ( n) ) ) ;
19
16
}
20
17
}
Original file line number Diff line number Diff line change @@ -220,8 +220,19 @@ mod embedded_hal_impl {
220
220
} ;
221
221
transfers. push ( SpidevTransfer :: read_write ( tx, buf) ) ;
222
222
}
223
- SpiOperation :: DelayUs ( us) => {
224
- let us = ( * us) . try_into ( ) . unwrap_or ( u16:: MAX ) ;
223
+ SpiOperation :: DelayNs ( ns) => {
224
+ let us = {
225
+ if * ns == 0 {
226
+ 0
227
+ } else {
228
+ let us = * ns / 1000 ;
229
+ if us == 0 {
230
+ 1
231
+ } else {
232
+ ( us) . try_into ( ) . unwrap_or ( u16:: MAX )
233
+ }
234
+ }
235
+ } ;
225
236
transfers. push ( SpidevTransfer :: delay ( us) ) ;
226
237
}
227
238
}
You can’t perform that action at this time.
0 commit comments