View Source Circuits.GPIO.Backend behaviour (circuits_gpio v2.0.0-pre.4)

Backends provide the connection to the real or virtual GPIO controllers

Summary

Callbacks

Return a list of GPIOs

Return information about this backend

Return information about a GPIO line

Callbacks

@callback enumerate() :: [Circuits.GPIO.Line.t()]

Return a list of GPIOs

See the Line struct for the information that is returned.

@callback info() :: map()

Return information about this backend

Link to this callback

line_info(gpio_spec, options)

View Source
@callback line_info(
  gpio_spec :: Circuits.GPIO.gpio_spec(),
  options :: Circuits.GPIO.open_options()
) :: {:ok, Circuits.GPIO.Line.t()} | {:error, atom()}

Return information about a GPIO line

See t:gpio_spec/0 for the ways of referring to GPIOs. The options contain and backend-specific options that would otherwise be passed to open/3.

If the GPIO is found, this function returns information about the GPIO.

Link to this callback

open(gpio_spec, direction, options)

View Source
@callback open(
  gpio_spec :: Circuits.GPIO.gpio_spec(),
  direction :: Circuits.GPIO.direction(),
  options :: Circuits.GPIO.open_options()
) :: {:ok, Circuits.GPIO.Handle.t()} | {:error, atom()}

Open a GPIO

See t:gpio_spec/0 for the ways of referring to GPIOs. Set direction to either :input or :output. If opening as an output, then be sure to set the :initial_value option to minimize the time the GPIO is in the default state.

Options:

  • :initial_value - Set to 0 or 1. Only used for outputs. Defaults to 0.
  • :pull_mode - Set to :not_set, :pullup, :pulldown, or :none for an input pin. :not_set is the default.

Returns {:ok, handle} on success.