pub struct SpidevDevice(pub Spidev);
Expand description
Spidev wrapper providing the embedded-hal SpiDevice
trait.
Use this struct when you want a single spidev device, using a Linux-managed CS (chip-select) pin, which is already defined in your device tree. Linux will handle sharing the bus between different SPI devices, even between different processes.
You get an object that implements SpiDevice
, which is what most drivers require,
but does not implement SpiBus
. In some rare cases, you may require SpiBus
instead; for that refer to SpidevBus
below. You may also want to use SpiBus
if you want to handle all the CS pins yourself using GPIO.
This struct wraps a spidev::Spidev
struct, so it can be constructed directly
and the inner struct accessed if needed, for example to (re)configure the SPI settings.
Note that delay operations on this device are capped to 65535 microseconds.
Tuple Fields§
§0: Spidev
Implementations§
Source§impl SpidevDevice
impl SpidevDevice
Methods from Deref<Target = Spidev>§
Sourcepub fn configure(&mut self, options: &SpidevOptions) -> Result<(), Error>
pub fn configure(&mut self, options: &SpidevOptions) -> Result<(), Error>
Write the provided configuration to this device
Sourcepub fn transfer(
&self,
transfer: &mut spi_ioc_transfer<'_, '_>,
) -> Result<(), Error>
pub fn transfer( &self, transfer: &mut spi_ioc_transfer<'_, '_>, ) -> Result<(), Error>
Perform a single transfer
Sourcepub fn transfer_multiple(
&self,
transfers: &mut [spi_ioc_transfer<'_, '_>],
) -> Result<(), Error>
pub fn transfer_multiple( &self, transfers: &mut [spi_ioc_transfer<'_, '_>], ) -> Result<(), Error>
Perform multiple transfers in a single system call to the kernel
Chaining together multiple requests like this can reduce latency and be used for conveniently and efficient implementing some protocols without extra round trips back to userspace.
Trait Implementations§
Source§impl Deref for SpidevDevice
impl Deref for SpidevDevice
Source§impl DerefMut for SpidevDevice
impl DerefMut for SpidevDevice
Source§impl SpiDevice for SpidevDevice
impl SpiDevice for SpidevDevice
Source§fn transaction(
&mut self,
operations: &mut [SpiOperation<'_, u8>],
) -> Result<(), Self::Error>
fn transaction( &mut self, operations: &mut [SpiOperation<'_, u8>], ) -> Result<(), Self::Error>
Perform a transaction against the device. Read more
Delay operations are capped to 65535 microseconds.