Circuits.SPI.Backend behaviour (circuits_spi v2.0.4)

Copy Markdown View Source

Backends provide the connection to the real or virtual SPI controller

Summary

Callbacks

Return SPI bus names on this system

Return information about this backend

Open a SPI bus device

Callbacks

bus_names(options)

@callback bus_names(options :: keyword()) :: [String.t()]

Return SPI bus names on this system

No supported options

info()

@callback info() :: map()

Return information about this backend

open(bus_name, list)

@callback open(bus_name :: String.t(), [Circuits.SPI.spi_option()]) ::
  {:ok, Circuits.SPI.Bus.t()} | {:error, term()}

Open a SPI bus device

On success, open/2 returns a reference that may be passed to with transfer/2. The device will be closed automatically when the reference goes out of scope.

SPI is not a standardized interface so appropriate options will different from device-to-device. The defaults use here work on many devices.

Parameters:

  • bus_name is the name of the bus (e.g., "spidev0.0"). See bus_names/0
  • opts is a keyword list to configure the bus