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/).
77
88## [ Unreleased]
99
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+
1018## [ v0.2.2] - 2018-12-21
1119
1220### Changed
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ version = "0.2.2"
1010
1111[dependencies ]
1212embedded-hal = { version = " 0.2.0" , features = [" unproven" ] }
13- i2cdev = " 0.4"
13+ i2cdev = " 0.4.3 "
1414spidev = " 0.4"
1515sysfs_gpio = " 0.5"
1616serial-unix = " 0.4.0"
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ use std::time::Duration;
2727use std:: { ops, thread} ;
2828
2929use cast:: { u32, u64} ;
30- use i2cdev:: core:: I2CDevice ;
30+ use i2cdev:: core:: { I2CDevice , I2CMessage , I2CTransfer } ;
31+ use i2cdev:: linux:: LinuxI2CMessage ;
3132use spidev:: SpidevTransfer ;
3233
3334mod serial;
@@ -184,7 +185,7 @@ impl I2cdev {
184185
185186 fn set_address ( & mut self , address : u8 ) -> Result < ( ) , i2cdev:: linux:: LinuxI2CError > {
186187 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 ) ) ?;
188189 self . address = Some ( address) ;
189190 }
190191 Ok ( ( ) )
@@ -219,8 +220,11 @@ impl hal::blocking::i2c::WriteRead for I2cdev {
219220 buffer : & mut [ u8 ] ,
220221 ) -> Result < ( ) , Self :: Error > {
221222 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)
224228 }
225229}
226230
You can’t perform that action at this time.
0 commit comments