I2cServer (i2c_server v0.1.3) View Source

I2C Server wraps Circuits.I2C reference in a GenServer, creating a separate process for each I2C device. I2C device processes are identified with a composite key of bus name and bus address. By default, I2C device processes are stored in Registry, but you can alternatively use :global.

Link to this section Summary

Functions

Initiates a read transaction to the I2C device.

Returns the module atom of currently-used registry.

Returns the PID for a specified bus name and bus address.

Writes data to the I2C device.

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

Link to this section Types

Specs

registry() :: I2cServer.DeviceRegistry | :global | atom()

Link to this section Functions

Link to this function

read(server, read_count)

View Source

Specs

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

Initiates a read transaction to the I2C device.

Specs

registry() :: registry()

Returns the module atom of currently-used registry.

Link to this function

server_process(bus_name, bus_address)

View Source

Specs

server_process(binary(), 0..127) :: pid()

Returns the PID for a specified bus name and bus address.

Link to this function

write(server, register_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(), binary() | integer(), integer()) :: any()

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