Skip to main content

spi

Function spi 

Source
pub fn spi(
    path: impl AsRef<Path>,
    mode: u8,
    max_speed_hz: u32,
) -> Result<SpidevDevice, OpenError>
Expand description

Opens an SPI device, such as /dev/spidev0.0, at a clock mode and speed.

§Arguments

  • path - the device file, one per chip-select line.
  • mode - the clock mode, 0 to 3, as the part’s datasheet quotes it.
  • max_speed_hz - the fastest clock the part accepts.

§Returns

The device, implementing SpiDevice with 8-bit words.

§Errors

Returns OpenError::SpiMode for a mode above 3, or OpenError::Spi if the device cannot be opened or configured.