Circuits.I2C.Backend behaviour (circuits_i2c v2.1.0)

View Source

Backends provide the connection to the real or virtual I2C controller

Summary

Types

I2C transfer options

Callbacks

Return the I2C bus names on this system

Return information about this backend

Open an I2C bus

Types

transfer_options()

@type transfer_options() :: keyword()

I2C transfer options

Support for options is backend-specific. Backends are encouraged to implement the following:

  • :retries - the number of retries for this transaction

Callbacks

bus_names(options)

@callback bus_names(options :: keyword()) :: [binary()]

Return the I2C bus names on this system

See backend documentation for options.

info()

@callback info() :: map()

Return information about this backend

open(bus_name, options)

@callback open(bus_name :: String.t(), options :: keyword()) ::
  {:ok, Circuits.I2C.Bus.t()} | {:error, term()}

Open an I2C bus

Bus names are typically of the form "i2c-n" and available buses may be found by calling bus_names/1.

See Circuits.I2C.open_options/0 for guidance on options.