@@ -25,7 +25,6 @@ pub use sysfs_gpio;
25
25
#[ cfg( feature = "gpio_cdev" ) ]
26
26
pub use gpio_cdev;
27
27
28
-
29
28
use core:: convert:: Infallible ;
30
29
use std:: io:: { self , Write } ;
31
30
use std:: path:: { Path , PathBuf } ;
@@ -202,19 +201,19 @@ impl embedded_hal::blocking::i2c::WriteRead for I2cdev {
202
201
buffer : & mut [ u8 ] ,
203
202
) -> Result < ( ) , Self :: Error > {
204
203
self . set_address ( address) ?;
205
- let mut messages = [
206
- LinuxI2CMessage :: write ( bytes) ,
207
- LinuxI2CMessage :: read ( buffer) ,
208
- ] ;
204
+ let mut messages = [ LinuxI2CMessage :: write ( bytes) , LinuxI2CMessage :: read ( buffer) ] ;
209
205
self . inner . transfer ( & mut messages) . map ( drop)
210
206
}
211
207
}
212
208
213
209
impl embedded_hal:: blocking:: i2c:: Transactional for I2cdev {
214
210
type Error = i2cdev:: linux:: LinuxI2CError ;
215
211
216
- fn try_exec ( & mut self , address : u8 , operations : & mut [ I2cOperation ] ) -> Result < ( ) , Self :: Error >
217
- {
212
+ fn try_exec (
213
+ & mut self ,
214
+ address : u8 ,
215
+ operations : & mut [ I2cOperation ] ,
216
+ ) -> Result < ( ) , Self :: Error > {
218
217
// Map operations from generic to linux objects
219
218
let mut messages: Vec < _ > = operations
220
219
. as_mut ( )
@@ -280,30 +279,32 @@ impl embedded_hal::blocking::spi::Write<u8> for Spidev {
280
279
}
281
280
}
282
281
283
- pub use embedded_hal:: blocking:: spi:: { Operation as SpiOperation } ;
282
+ pub use embedded_hal:: blocking:: spi:: Operation as SpiOperation ;
284
283
285
284
/// Transactional implementation batches SPI operations into a single transaction
286
285
impl embedded_hal:: blocking:: spi:: Transactional < u8 > for Spidev {
287
286
type Error = io:: Error ;
288
287
289
288
fn try_exec < ' a > ( & mut self , operations : & mut [ SpiOperation < ' a , u8 > ] ) -> Result < ( ) , Self :: Error > {
290
-
291
289
// Map types from generic to linux objects
292
- let mut messages: Vec < _ > = operations. iter_mut ( ) . map ( |a| {
293
- match a {
294
- SpiOperation :: Write ( w) => SpidevTransfer :: write ( w) ,
295
- SpiOperation :: Transfer ( r) => {
296
- // Clone read to write pointer
297
- // SPIdev is okay with having w == r but this is tricky to achieve in safe rust
298
- let w = unsafe {
299
- let p = r. as_ptr ( ) ;
300
- std:: slice:: from_raw_parts ( p, r. len ( ) )
301
- } ;
302
-
303
- SpidevTransfer :: read_write ( w, r)
304
- } ,
305
- }
306
- } ) . collect ( ) ;
290
+ let mut messages: Vec < _ > = operations
291
+ . iter_mut ( )
292
+ . map ( |a| {
293
+ match a {
294
+ SpiOperation :: Write ( w) => SpidevTransfer :: write ( w) ,
295
+ SpiOperation :: Transfer ( r) => {
296
+ // Clone read to write pointer
297
+ // SPIdev is okay with having w == r but this is tricky to achieve in safe rust
298
+ let w = unsafe {
299
+ let p = r. as_ptr ( ) ;
300
+ std:: slice:: from_raw_parts ( p, r. len ( ) )
301
+ } ;
302
+
303
+ SpidevTransfer :: read_write ( w, r)
304
+ }
305
+ }
306
+ } )
307
+ . collect ( ) ;
307
308
308
309
// Execute transfer
309
310
self . 0 . transfer_multiple ( & mut messages)
0 commit comments