nerves_config_pin
A BeagleBone config-pin
wrapper for use in Elixir Nerves projects.
Usage
Overlays
The BeagleBone cape manager is not available in a Nerves system. Instead, the
overlays are specified by setting U-Boot environment variables. Configuration of
capes/overlays is out of the scope of this library.
Utilize Nerves.Runtime.KV
or provisioning.conf
to configure overlays.
Example Commands
The following functions accept the number of the header followed by the number of the pin on that header. See the system reference manual for the pin mux table.
Set header 9, pin 12 to gpio pull-up:
iex> ConfigPin.set(9, 12, :gpio_pu)
:ok
Query the pin configuration for header 9, pin 12:
iex> ConfigPin.query(9, 12)
{:ok, %{direction: :in, header: 9, mode: :default, pin: 12, value: 1}}
List the valid pin mux modes for header 9, pin 12:
iex> ConfigPin.list_modes(9, 12)
{:ok, [:default, :gpio, :gpio_pu, :gpio_pd, :gpio_input]}
Print info for header 9, pin 12:
iex> ConfigPin.info(9, 12)
# Pin name: P9_12
# Function if no cape loaded: gpio
# Function if cape loaded: default gpio gpio_pu gpio_pd gpio_input
# Function information: gpio1_28 default gpio1_28 gpio1_28 gpio1_28 gpio1_28
# Kernel GPIO id: 60
# PRU GPIO id: 92
:ok
Set Configuration From A File
A list of pin configurations can be defined in a text file. The format is
<header>_<pin> <mode>\n
. Comments and white-space are allowed. Each
configuration must end with a line terminator.
The file is passed directly to config-pin
and is not processed
by this library.
Example file:
# <header>_<pin> <mode>
P9_11 gpio_pu
P9_12 gpio_pd
Setting the configuration:
iex> ConfigPin.set_from_file("/root/pinmux")
:ok