gpioctl - control GPIO devices
gpioctl [-hq] [-d device] [pin] [0 | 1 | 2]
gpioctl [-hq] [-d device] -c pin [flags]
The gpioctl program allows manipulation of GPIO (General
Purpose Input/Output)
device pins. Such devices can be either part of
the chipset
or embedded CPU, or a separate chip. The usual way of using
GPIO is to
connect some simple devices such as LEDs, 1-wire termal sensors, etc., to
its pins.
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:
in input direction
out output direction
inout bi-directional
od open-drain output
pp push-pull output
tri tri-state (output disabled)
pu internal pull-up enabled
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.
/dev/gpiou GPIO device unit u file.
Configure pin 20 to have push-pull output:
# gpioctl -c 20 out pp
Write logical 1 to pin 20:
# gpioctl 20 1
gpio(4), gscpcib(4), nsclpcsio(4)
The gpioctl command first appeared in OpenBSD 3.6.
The gpioctl program was written by Alexander Yurchenko
<grange@openbsd.org>.
OpenBSD 3.6 May 3, 2004
[ Back ] |