*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> gpio (4)              
Title
Content
Arch
Section
 

GPIO(4)

Contents


NAME    [Toc]    [Back]

     gpio - General Purpose Input/Output

SYNOPSIS    [Toc]    [Back]

     gpio* at nsclpcsio?
     gpio* at gscpcib?

     #include <sys/types.h>
     #include <sys/gpio.h>
     #include <sys/ioctl.h>

DESCRIPTION    [Toc]    [Back]

     The gpio device attaches to the GPIO controller and provides
a uniform
     programming interface to its pins.

     Each GPIO controller with an attached gpio device has an associated device
 file under the /dev directory, e.g. /dev/gpio0.  Access
from userland
 is performed through ioctl(2) calls on these devices.

IOCTL INTERFACE    [Toc]    [Back]

     The  following  structures  and constants are defined in the
<sys/gpio.h>
     header file:

     GPIOINFO (struct gpio_info)
           Returns information about the GPIO controller  in  the
gpio_info
           structure:

           struct gpio_info {
                   int  gpio_npins;          /*  total  number of
pins available */
           };

     GPIOPINREAD (struct gpio_pin_op)
           Returns the input pin value in the gpio_pin_op  structure:

           struct gpio_pin_op {
                   int gp_pin;             /* pin number */
                   int gp_value;           /* value */
           };

           The gp_pin field must be set before calling.

     GPIOPINWRITE (struct gpio_pin_op)
           Writes  the output value to the pin.  The value set in
the gp_value
           field must  be  either  GPIO_PIN_LOW  (logical  0)  or
GPIO_PIN_HIGH
           (logical  1).   On return, the gp_value field contains
the old pin
           state.

     GPIOPINTOGGLE (struct gpio_pin_op)
           Toggles the pin output value, i.e. changes it  to  the
opposite.
           gp_value  field  is ignored and on return contains the
old pin state.

     GPIOPINCTL (struct gpio_pin_ctl)
           Changes pin configuration flags with the new ones provided in the
           gpio_pin_ctl structure:

           struct gpio_pin_ctl {
                   int gp_pin;             /* pin number */
                   int  gp_caps;             /*  pin capabilities
(read-only) */
                   int gp_flags;           /*  pin  configuration
flags */
           };

           The  gp_flags  field is a combination of the following
flags:

           GPIO_PIN_INPUT      input direction
           GPIO_PIN_OUTPUT     output direction
           GPIO_PIN_INOUT      bi-directional
           GPIO_PIN_OPENDRAIN  open-drain output
           GPIO_PIN_PUSHPULL   push-pull output
           GPIO_PIN_TRISTATE   output disabled
           GPIO_PIN_PULLUP     internal pull-up enabled

           Note that the GPIO controller may not support  all  of
these flags.
           On  return  the  gp_caps field contains flags that are
supported.  If
           no flags are specified, the  pin  configuration  stays
unchanged.

FILES    [Toc]    [Back]

     /dev/gpiou  GPIO device unit u file.

SEE ALSO    [Toc]    [Back]

      
      
     ioctl(2), gscpcib(4), nsclpcsio(4), gpioctl(8)

HISTORY    [Toc]    [Back]

     The gpio device first appeared in OpenBSD 3.6.

AUTHORS    [Toc]    [Back]

     The   gpio   driver   was  written  by  Alexander  Yurchenko
<grange@openbsd.org>.

BUGS    [Toc]    [Back]

     Event capabilities are not supported.

OpenBSD      3.6                            May      3,      2004
[ Back ]
 Similar pages
Name OS Title
xconfirm IRIX general purpose dialog box
extent_alloc_subregion NetBSD general purpose extent manager
extent_free NetBSD general purpose extent manager
extent_print NetBSD general purpose extent manager
extent_alloc_subregion OpenBSD general purpose extent manager
extent_create OpenBSD general purpose extent manager
extent_print OpenBSD general purpose extent manager
extent_free OpenBSD general purpose extent manager
extent_destroy OpenBSD general purpose extent manager
extent_alloc_region NetBSD general purpose extent manager
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service