Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/spidevioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> {
}
}

/// Create a read/write transfer using the same buffer for reading
/// and writing (in-place transfer).
pub fn read_write_in_place(buf: &'a mut [u8]) -> Self {
// This is allowed according to a comment in the linux source tree:
// https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/spi/spi.h?id=211ddde0823f1442e4ad052a2f30f050145ccada#n1073
spi_ioc_transfer {
rx_buf: buf.as_ptr() as *const () as usize as u64,
tx_buf: buf.as_ptr() as *const () as usize as u64,
len: buf.len() as u32,
..Default::default()
}
}

/// Create a delay transfer of a number of microseconds
pub fn delay(microseconds: u16) -> Self {
spi_ioc_transfer {
Expand Down