Each
GPIO
device has an associated device file in the
/dev
directory.
By default
gpioctl
uses
/dev/gpio0
,
which corresponds to the first found
GPIO
device in the system.
If more than one
GPIO
device is present, an alternative device file can be specified with the
-d
option in order to access a particular
GPIO
device.
When executed without any arguments, gpioctl reads information about the GPIO device and displays it.
GPIO pins can be either ``read'' or ``written'' with the values of logical 0 or 1. If only a pin number is specified on the command line, the pin state will be read from the GPIO controller and displayed. To write to a pin, a value must be specified after the pin number. Values can be either 0 or 1. A value of 2 has a special meaning: it ``toggles'' the pin, i.e. changes its state to the opposite.
Each pin can be configured with different flags with the -c option. The following configuration flags are supported by the GPIO framework:
Note that not all the flags can be supported by the particular GPIO controller. The list of supported flags is always displayed when executing gpioctl with the -c option. If only a pin number is specified on the command line, the current pin flags will be displayed. To change pin flags, a new flags set separated by spaces must be specified after the pin number.
The -q option causes gpioctl to operate quietly i.e. nothing is printed to stdout. The -h option displays a usage summary.
#
gpioctl
-c
20
out
pp
Write logical 1 to pin 20:
#
gpioctl
20
1