gpio man page on OpenBSD

Man page or keyword search:  
man Server   11362 pages
apropos Keyword Search (all sections)
Output format
OpenBSD logo
[printable version]

GPIO(4)			  OpenBSD Programmer's Manual		       GPIO(4)

NAME
     gpio - General Purpose Input/Output

SYNOPSIS
     gpio* at ath?
     gpio* at elansc? (i386)
     gpio* ar glxpcib? (i386)
     gpio* at gscpcib? (i386)
     gpio* at isagpio?
     gpio* at nsclpcsio?
     gpio* at pcagpio?
     gpio* at pcaled?
     gpio0 at voyager? (loongson)

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

DESCRIPTION
     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.

     The layout of the GPIO device is defined at securelevel 0, i.e. typically
     during system boot, and cannot be changed later.  GPIO pins can be
     configured and given a symbolic name and device drivers that use GPIO
     pins can be attached to the gpio device at securelevel 0.	All other pins
     will not be accessible once the runlevel has been raised.

IOCTL INTERFACE
     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:

	   #define GPIOPINMAXNAME	   64

	   struct gpio_pin_op {
		   char gp_name[GPIOPINMAXNAME];   /* pin name */
		   int gp_pin;			   /* pin number */
		   int gp_value;		   /* value */
	   };

	   The gp_name or 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.

     GPIOPINSET (struct gpio_pin_set)
	   Changes pin configuration flags with the new ones provided in the
	   gpio_pin_set structure:

	   #define GPIOPINMAXNAME	   64

	   struct gpio_pin_set {
		   char gp_name[GPIOPINMAXNAME];   /* pin name */
		   int gp_pin;			   /* pin number */
		   int gp_caps;			   /* pin capabilities (ro) */
		   int gp_flags;		   /* pin configuration flags */
		   char gp_name2[GPIOPINMAXNAME];  /* new name */
	   };

	   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
	   GPIO_PIN_PULLDOWN   internal pull-down enabled
	   GPIO_PIN_INVIN      invert input
	   GPIO_PIN_INVOUT     invert output

	   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.

	   Only GPIO pins that have been set using GPIOPINSET will be
	   accessible at securelevels greater than 0.

     GPIOPINUNSET (struct gpio_pin_set)
	   Unset the specified pin, i.e. clear its name and make it
	   inaccessible at securelevels greater than 0.

     GPIOATTACH (struct gpio_attach)
	   Attach the device described in the gpio_attach structure on this
	   gpio device.

	   struct gpio_attach {
		   char ga_dvname[16];	   /* device name */
		   int ga_offset;	   /* pin number */
		   u_int32_t ga_mask;	   /* binary mask */
	   };

     GPIODETACH (struct gpio_attach)
	   Detach a device from this gpio device that was previously attached
	   using the GPIOATTACH ioctl(2).  The ga_offset and ga_mask fields of
	   the gpio_attach structure are ignored.

FILES
     /dev/gpiou	 GPIO device unit u file.

SEE ALSO
     ioctl(2), gpioctl(8)

HISTORY
     The gpio device first appeared in OpenBSD 3.6.

AUTHORS
     The gpio driver was written by Alexander Yurchenko <grange@openbsd.org>.
     Runtime device attachment was added by
     Marc Balmer <mbalmer@openbsd.org>.

BUGS
     Event capabilities are not supported.

OpenBSD 4.9		       February 18, 2010		   OpenBSD 4.9
[top]

List of man pages available for OpenBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net