View Source Circuits.I2C.Backend behaviour (circuits_i2c v2.0.6)

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

@type options() :: keyword()

I2C transfer options

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

  • :retries - a number of times to attempt to retry the transaction before failing

Callbacks

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

Return the I2C bus names on this system

No supported options

@callback info() :: map()

Return information about this backend

@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.

Options:

  • :retries - Specify a nonnegative integer for how many times to retry a failed I2C operation.