File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Fixed
11
+
12
+ - Do write and read in one transaction in WriteRead implementation.
13
+
14
+ ### Changed
15
+
16
+ - updated to i2cdev 0.4.3 (necessary for trasactional write-read).
17
+
10
18
## [ v0.2.2] - 2018-12-21
11
19
12
20
### Changed
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ version = "0.2.2"
10
10
11
11
[dependencies ]
12
12
embedded-hal = { version = " 0.2.0" , features = [" unproven" ] }
13
- i2cdev = " 0.4"
13
+ i2cdev = " 0.4.3 "
14
14
spidev = " 0.4"
15
15
sysfs_gpio = " 0.5"
16
16
serial-unix = " 0.4.0"
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ use std::time::Duration;
27
27
use std:: { ops, thread} ;
28
28
29
29
use cast:: { u32, u64} ;
30
- use i2cdev:: core:: I2CDevice ;
30
+ use i2cdev:: core:: { I2CDevice , I2CMessage , I2CTransfer } ;
31
+ use i2cdev:: linux:: LinuxI2CMessage ;
31
32
use spidev:: SpidevTransfer ;
32
33
33
34
mod serial;
@@ -184,7 +185,7 @@ impl I2cdev {
184
185
185
186
fn set_address ( & mut self , address : u8 ) -> Result < ( ) , i2cdev:: linux:: LinuxI2CError > {
186
187
if self . address != Some ( address) {
187
- self . inner = i2cdev:: linux:: LinuxI2CDevice :: new ( & self . path , address as u16 ) ?;
188
+ self . inner = i2cdev:: linux:: LinuxI2CDevice :: new ( & self . path , u16:: from ( address ) ) ?;
188
189
self . address = Some ( address) ;
189
190
}
190
191
Ok ( ( ) )
@@ -219,8 +220,11 @@ impl hal::blocking::i2c::WriteRead for I2cdev {
219
220
buffer : & mut [ u8 ] ,
220
221
) -> Result < ( ) , Self :: Error > {
221
222
self . set_address ( address) ?;
222
- self . inner . write ( bytes) ?;
223
- self . inner . read ( buffer)
223
+ let mut messages = [
224
+ LinuxI2CMessage :: write ( bytes) ,
225
+ LinuxI2CMessage :: read ( buffer) ,
226
+ ] ;
227
+ self . inner . transfer ( & mut messages) . map ( drop)
224
228
}
225
229
}
226
230
You can’t perform that action at this time.
0 commit comments