Skip to content

Commit 75467ef

Browse files
committed
update for transactional landed in e-h master
1 parent 4acac31 commit 75467ef

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ edition = "2018"
1212
[features]
1313
gpio_sysfs = ["sysfs_gpio"]
1414
gpio_cdev = ["gpio-cdev"]
15-
transactional-spi = [] # Guard for transactional SPI feature (https://github.com/rust-embedded/embedded-hal/pull/191)
1615

1716
default = [ "gpio_cdev", "gpio_sysfs" ]
1817

1918
[dependencies]
20-
embedded-hal = "=1.0.0-alpha.1"
19+
embedded-hal = "=1.0.0-alpha.2"
2120
gpio-cdev = { version = "0.3", optional = true }
2221
sysfs_gpio = { version = "0.5", optional = true }
2322

@@ -36,4 +35,5 @@ default-features = false
3635
version = "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+

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ impl hal::blocking::spi::Write<u8> for Spidev {
259259
}
260260
}
261261

262-
#[cfg(feature = "transactional-spi")]
263262
pub use hal::blocking::spi::{Operation as SpiOperation};
264263

265-
#[cfg(feature = "transactional-spi")]
264+
/// Transactional implementation batches SPI operations into a single transaction
266265
impl 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())

0 commit comments

Comments
 (0)