Struct SpidevDevice
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: SpidevImplementations§
§impl SpidevDevice
impl SpidevDevice
Methods from Deref<Target = Spidev>§
pub fn configure(&mut self, options: &SpidevOptions) -> Result<(), Error>
pub fn configure(&mut self, options: &SpidevOptions) -> Result<(), Error>
Write the provided configuration to this device
pub fn query_configuration(&self) -> Result<SpidevOptions, Error>
pub fn query_configuration(&self) -> Result<SpidevOptions, Error>
Read the current configuration from this device
pub 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
pub 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§
§impl Deref for SpidevDevice
impl Deref for SpidevDevice
§impl DerefMut for SpidevDevice
impl DerefMut for SpidevDevice
§fn deref_mut(&mut self) -> &mut <SpidevDevice as Deref>::Target
fn deref_mut(&mut self) -> &mut <SpidevDevice as Deref>::Target
§impl SpiDevice for SpidevDevice
impl SpiDevice for SpidevDevice
§fn transaction(
&mut self,
operations: &mut [Operation<'_, u8>],
) -> Result<(), <SpidevDevice as ErrorType>::Error>
fn transaction( &mut self, operations: &mut [Operation<'_, u8>], ) -> Result<(), <SpidevDevice as ErrorType>::Error>
Perform a transaction against the device. Read more
Delay operations are capped to 65535 microseconds.