File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,11 @@ edition = "2018"
1212[features ]
1313gpio_sysfs = [" sysfs_gpio" ]
1414gpio_cdev = [" gpio-cdev" ]
15- transactional-spi = [] # Guard for transactional SPI feature (https://github.com/rust-embedded/embedded-hal/pull/191)
1615
1716default = [ " gpio_cdev" , " gpio_sysfs" ]
1817
1918[dependencies ]
20- embedded-hal = " =1.0.0-alpha.1 "
19+ embedded-hal = " =1.0.0-alpha.2 "
2120gpio-cdev = { version = " 0.3" , optional = true }
2221sysfs_gpio = { version = " 0.5" , optional = true }
2322
@@ -36,4 +35,5 @@ default-features = false
3635version = " 0.2.2"
3736
3837[patch .crates-io ]
39- # embedded-hal = { git = "https://github.com/ryankurte/embedded-hal", branch = "feature/spi-transactions" }
38+ embedded-hal = { git = " https://github.com/rust-embedded/embedded-hal" }
39+
Original file line number Diff line number Diff line change @@ -259,10 +259,9 @@ impl hal::blocking::spi::Write<u8> for Spidev {
259259 }
260260}
261261
262- #[ cfg( feature = "transactional-spi" ) ]
263262pub use hal:: blocking:: spi:: { Operation as SpiOperation } ;
264263
265- # [ cfg ( feature = "transactional-spi" ) ]
264+ /// Transactional implementation batches SPI operations into a single transaction
266265impl hal:: blocking:: spi:: Transactional < u8 > for Spidev {
267266 type Error = io:: Error ;
268267
@@ -273,9 +272,8 @@ impl hal::blocking::spi::Transactional<u8> for Spidev {
273272 match a {
274273 SpiOperation :: Write ( w) => SpidevTransfer :: write ( w) ,
275274 SpiOperation :: Transfer ( r) => {
276- // TODO: is spidev okay with the same array pointer
277- // being used twice? If not, need some kind of vector
278- // pool that will outlive the transfer
275+ // Clone read to write pointer
276+ // SPIdev is okay with having w == r but this is tricky to achieve in safe rust
279277 let w = unsafe {
280278 let p = r. as_ptr ( ) ;
281279 std:: slice:: from_raw_parts ( p, r. len ( ) )
You can’t perform that action at this time.
0 commit comments