elixir_ale v0.5.4 I2c
This module allows Elixir code to communicate with devices on an I2C bus.
Summary
Functions
Scan the I2C bus for devices by performing a read at each device address and returning a list of device addresses that respond
Initiate a read transaction on the I2C bus of count
bytes
Initiate a read transaction to the device at the specified address
. This
is the same as read/2
except that an arbitrary device address may be given
Stop the GenServer and release all resources
Start and link the I2c GenServer
Write the specified data
to the device
Write the specified data
to the device at address
Write the specified data
to the device and then read
the specified number of bytes
Write the specified data
to the device and then read
the specified number of bytes. This is similar to write_read/3
except
with an I2C device address
Functions
Scan the I2C bus for devices by performing a read at each device address and returning a list of device addresses that respond.
WARNING: This is intended to be a debugging aid. Reading bytes from devices can advance internal state machines and might cause them to get out of sync with other code.
Initiate a read transaction to the device at the specified address
. This
is the same as read/2
except that an arbitrary device address may be given.
Start and link the I2c GenServer.
devname
is the I2C bus name (e.g., “i2c-1”)
address
is the device’s 7-bit address on the I2C bus
Note that address
can be confusing when reading a datasheet
since sometimes the datasheet mentions the 8-bit address. For an 8-bit
address the least significant bit indicates whether the access is for a
read or a write. Microcontrollers like those on Arduinos often use the 8-bit
address. To convert an 8-bit address to a 7-bit one, divide the address by
two.
All calls to read/2
, write/2
, and write_read/3
access the device
specified by address
. Some I2C devices can be switched into different
modes where they respond to an alternate address. Rather than having to
create a second I2c
process, see read_device/3
and related routines.
Write the specified data
to the device and then read
the specified number of bytes.
Write the specified data
to the device and then read
the specified number of bytes. This is similar to write_read/3
except
with an I2C device address.