I2cServer (i2c_server v0.2.7) View Source

I2C Server wraps Circuits.I2C reference in a GenServer, creating a separate process per I2C bus.

Link to this section Summary

Functions

Run multiple operations in series blocking the process in favor of consistency.

Returns the module atom of currently-used bus registry.

Returns a specification to start this module under a supervisor.

Initiates a read transaction to the I2C device.

Replaces the currently-used bus registry with a different one.

Writes data to the I2C device.

Writes data to an I2C device and then immediately issue a read.

Link to this section Types

Specs

bus_address() :: 0..127

Specs

bus_name() :: binary()

Specs

bus_registry() :: I2cServer.Busbus_registry | :global | atom()

Specs

init_arg() :: [bus_name: bus_name(), bus_address: bus_address()]

Link to this section Functions

Link to this function

bulk(server, bulk_operations)

View Source

Specs

bulk(GenServer.server(), [
  {:sleep, integer()}
  | {atom(), atom(), list()}
  | {:read, integer()}
  | {:write, integer(), iodata()}
  | {:write, integer(), integer(), binary() | integer()}
  | {:write_read, binary() | integer(), integer()}
  | function()
]) :: list()

Run multiple operations in series blocking the process in favor of consistency.

Specs

bus_registry() :: bus_registry()

Returns the module atom of currently-used bus registry.

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

read(server, read_count)

View Source

Specs

read(GenServer.server(), integer()) :: any()

Initiates a read transaction to the I2C device.

Link to this function

set_bus_registry(bus_registry)

View Source

Specs

set_bus_registry(bus_registry()) :: :ok

Replaces the currently-used bus registry with a different one.

Specs

start_link(init_arg()) :: GenServer.on_start()
Link to this function

write(server, register_and_data)

View Source

Specs

write(GenServer.server(), iodata()) :: any()

Writes data to the I2C device.

Link to this function

write(server, register, data)

View Source

Specs

write(GenServer.server(), integer(), binary() | integer()) :: any()
Link to this function

write_read(server, write_data, read_count)

View Source

Specs

write_read(GenServer.server(), iodata() | integer(), integer()) :: any()

Writes data to an I2C device and then immediately issue a read.