circuits_spi v0.1.4 Circuits.SPI View Source
This module enables Elixir programs to interact with hardware that's connected via a SPI bus.
Link to this section Summary
Functions
Return a list of available SPI bus names. If nothing is returned,
it's possible that the kernel driver for that SPI bus is not enabled or the
kernel's device tree is not configured. On Raspbian, run raspi-config
and
look in the advanced options.
Release any resources associated with the given file descriptor
Return info about the low level SPI interface
Open SPI channel On success, returns a reference. Use reference in subsequent calls to transfer SPI bus data
Perform a SPI transfer. The data
should be a binary containing the bytes to
send. Since SPI transfers simultaneously send and receive, the return value
will be a binary of the same length or an error.
Link to this section Types
SPI bus
Call open/2
to obtain an SPI bus reference.
spi_option()
View Sourcespi_option() :: {:mode, 0..3} | {:bits_per_word, 0..16} | {:speed_hz, pos_integer()} | {:delay_us, non_neg_integer()}
SPI bus options. See open/2
.
Link to this section Functions
Return a list of available SPI bus names. If nothing is returned,
it's possible that the kernel driver for that SPI bus is not enabled or the
kernel's device tree is not configured. On Raspbian, run raspi-config
and
look in the advanced options.
iex> Circuits.SPI.bus_names
["spidev0.0", "spidev0.1"]
Release any resources associated with the given file descriptor
Return info about the low level SPI interface
This may be helpful when debugging SPI issues.
open(bus_name, opts \\ [])
View Sourceopen(binary() | charlist(), [spi_option()]) :: {:ok, spi_bus()}
Open SPI channel On success, returns a reference. Use reference in subsequent calls to transfer SPI bus data
Parameters:
bus_name
is the name of the bus (e.g., "spidev0.0")opts
is a keyword list to configure the bus
SPI bus options include:
mode
: This specifies the clock polarity and phase to use. (0)bits_per_word
: bits per word on the bus (8)speed_hz
: bus speed (1000000)delay_us
: delay between transaction (10)
Perform a SPI transfer. The data
should be a binary containing the bytes to
send. Since SPI transfers simultaneously send and receive, the return value
will be a binary of the same length or an error.