summaryrefslogtreecommitdiffstats
path: root/lib/libgpio
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /lib/libgpio
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'lib/libgpio')
-rw-r--r--lib/libgpio/Makefile36
-rw-r--r--lib/libgpio/Makefile.depend20
-rw-r--r--lib/libgpio/gpio.3198
-rw-r--r--lib/libgpio/gpio.c278
-rw-r--r--lib/libgpio/libgpio.h110
5 files changed, 642 insertions, 0 deletions
diff --git a/lib/libgpio/Makefile b/lib/libgpio/Makefile
new file mode 100644
index 0000000..4393c79
--- /dev/null
+++ b/lib/libgpio/Makefile
@@ -0,0 +1,36 @@
+# $FreeBSD$
+
+LIB= gpio
+SHLIB_MAJOR= 0
+
+SRCS= gpio.c
+INCS= libgpio.h
+MAN+= gpio.3
+
+CFLAGS+= -I${.CURDIR}
+
+MLINKS= gpio.3 gpio_open.3 \
+ gpio.3 gpio_open_device.3 \
+ gpio.3 gpio_close.3 \
+ gpio.3 gpio_pin_list.3 \
+ gpio.3 gpio_pin_config.3 \
+ gpio.3 gpio_pin_set_flags.3 \
+ gpio.3 gpio_pin_set_name.3 \
+ gpio.3 gpio_pin_get.3 \
+ gpio.3 gpio_pin_set.3 \
+ gpio.3 gpio_pin_low.3 \
+ gpio.3 gpio_pin_high.3 \
+ gpio.3 gpio_pin_input.3 \
+ gpio.3 gpio_pin_output.3 \
+ gpio.3 gpio_pin_opendrain.3 \
+ gpio.3 gpio_pin_pushpull.3 \
+ gpio.3 gpio_pin_tristate.3 \
+ gpio.3 gpio_pin_pullup.3 \
+ gpio.3 gpio_pin_pulldown.3 \
+ gpio.3 gpio_pin_invin.3 \
+ gpio.3 gpio_pin_invout.3 \
+ gpio.3 gpio_pin_pulsate.3
+
+WARNS?= 6
+
+.include <bsd.lib.mk>
diff --git a/lib/libgpio/Makefile.depend b/lib/libgpio/Makefile.depend
new file mode 100644
index 0000000..467741f
--- /dev/null
+++ b/lib/libgpio/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ usr.bin/xinstall.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libgpio/gpio.3 b/lib/libgpio/gpio.3
new file mode 100644
index 0000000..70f6b38
--- /dev/null
+++ b/lib/libgpio/gpio.3
@@ -0,0 +1,198 @@
+.\"
+.\" Copyright (c) 2014 Rui Paulo
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 8, 2015
+.Dt GPIO 3
+.Os
+.Sh NAME
+.Nm gpio_open ,
+.Nm gpio_close
+.Nd "library to handle GPIO pins"
+.Sh LIBRARY
+.Lb libgpio
+.Sh SYNOPSIS
+.In libgpio.h
+.Ft "gpio_handle_t"
+.Fn gpio_open "unsigned int unit"
+.Ft "gpio_handle_t"
+.Fn gpio_open_device "const char *device"
+.Ft void
+.Fn gpio_close "gpio_handle_t handle"
+.Ft int
+.Fn gpio_pin_list "gpio_handle_t handle" "gpio_config_t **pcfgs"
+.Ft int
+.Fn gpio_pin_config "gpio_handle_t handle" "gpio_config_t *cfg"
+.Ft int
+.Fn gpio_pin_set_name "gpio_handle_t handle" "gpio_pin_t pin" "char *name"
+.Ft int
+.Fn gpio_pin_set_flags "gpio_handle_t handle" "gpio_config_t *cfg"
+.Ft gpio_value_t
+.Fn gpio_pin_get "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_set "gpio_handle_t handle" "gpio_pin_t pin" "gpio_value_t value"
+.Ft int
+.Fn gpio_pin_toggle "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_low "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_high "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_input "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_output "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_opendrain "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_pushpull "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_tristate "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_pullup "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_pulldown "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_invin "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_invout "gpio_handle_t handle" "gpio_pin_t pin"
+.Ft int
+.Fn gpio_pin_pulsate "gpio_handle_t handle" "gpio_pin_t pin"
+.Sh DESCRIPTION
+The
+.Nm libgpio
+library provides an interface to configure GPIO pins.
+The library operates with a
+.Ft gpio_handle_t
+opaque type which can be created with
+.Fn gpio_open
+or
+.Fn gpio_open_device .
+When no more GPIO operations are needed, this handle can be destroyed
+with
+.Fn gpio_close .
+.Pp
+To get a list of all available pins, one can call
+.Fn gpio_pin_list .
+This function takes a pointer to a
+.Ft gpio_config_t
+which is dynamically allocated.
+This pointer should be freed with
+.Xr free 3
+when it is no longer necessary.
+.Pp
+The function
+.Fn gpio_pin_config
+retrieves the current configuration of a pin.
+The pin number should be passed in via the
+.Ft g_pin
+variable which is part of the
+.Ft gpio_config_t
+structure.
+.Pp
+The function
+.Fn gpio_pin_set_name
+sets the name used to describe a pin.
+.Pp
+The function
+.Fn gpio_pin_set_flags
+configures a pin with the flags passed in by the
+.Ft gpio_config_t
+structure.
+The pin number should also be passed in through the
+.Ft g_pin
+variable.
+All other structure members will be ignored by this function.
+The list of flags can be found in
+.Pa /usr/include/sys/gpio.h .
+.Pp
+The get or set the state of a GPIO pin, the functions
+.Fn gpio_pin_get
+and
+.Fn gpio_pin_set
+are available, respectively.
+To toggle the state, use
+.Fn gpio_pin_toggle .
+.Pp
+The functions
+.Fn gpio_pin_low
+and
+.Fn gpio_pin_high
+are wrappers around
+.Fn gpio_pin_set .
+.Pp
+The functions
+.Fn gpio_pin_input ,
+.Fn gpio_pin_output ,
+.Fn gpio_pin_opendrain ,
+.Fn gpio_pin_pushpull ,
+.Fn gpio_pin_tristate ,
+.Fn gpio_pin_pullup ,
+.Fn gpio_pin_pulldown ,
+.Fn gpio_pin_invin ,
+.Fn gpio_pin_invout
+and
+.Fn gpio_pin_pulsate
+are wrappers around
+.Fn gpio_pin_set_flags .
+.Sh EXAMPLES
+The following example shows how to configure pin 16 as output and then
+drive it high:
+.Bd -literal
+#include <err.h>
+#include <libgpio.h>
+
+gpio_handle_t handle;
+
+handle = gpio_open(0);
+if (handle == GPIO_HANDLE_INVALID)
+ err(1, "gpio_open failed");
+gpio_pin_output(handle, 16);
+gpio_pin_high(handle, 16);
+gpio_close(handle);
+.Ed
+.Pp
+The following example shows how to get a configuration of a pin:
+.Bd -literal
+gpio_config_t cfg;
+
+cfg.g_pin = 32;
+gpio_pin_config(handle, &cfg);
+.Ed
+.Pp
+The structure will contain the name of the pin and its flags.
+.Sh SEE ALSO
+.Xr gpiobus 4 ,
+.Xr gpioctl 8
+.Sh HISTORY
+The
+.Nm libgpio
+library first appeared in
+.Fx 11.0 .
+.Sh AUTHORS
+The
+.Nm libgpio
+library was implemented by
+.An Rui Paulo Aq Mt rpaulo@FreeBSD.org .
diff --git a/lib/libgpio/gpio.c b/lib/libgpio/gpio.c
new file mode 100644
index 0000000..7ec0955
--- /dev/null
+++ b/lib/libgpio/gpio.c
@@ -0,0 +1,278 @@
+/*-
+ * Copyright (c) 2013-2014 Rui Paulo <rpaulo@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <libgpio.h>
+
+gpio_handle_t
+gpio_open(unsigned int unit)
+{
+ char device[16];
+
+ snprintf(device, sizeof(device), "/dev/gpioc%u", unit);
+
+ return (gpio_open_device(device));
+}
+
+gpio_handle_t
+gpio_open_device(const char *device)
+{
+ int fd, maxpins;
+ int serr;
+
+ fd = open(device, O_RDONLY);
+ if (fd < 0)
+ return (GPIO_INVALID_HANDLE);
+ /*
+ * Check whether a simple ioctl works.
+ */
+ if (ioctl(fd, GPIOMAXPIN, &maxpins) < 0) {
+ serr = errno;
+ close(fd);
+ errno = serr;
+ return (GPIO_INVALID_HANDLE);
+ }
+
+ return (fd);
+}
+
+void
+gpio_close(gpio_handle_t handle)
+{
+ close(handle);
+}
+
+int
+gpio_pin_list(gpio_handle_t handle, gpio_config_t **pcfgs)
+{
+ int maxpins, i;
+ gpio_config_t *cfgs;
+
+ *pcfgs = NULL;
+ if (ioctl(handle, GPIOMAXPIN, &maxpins) < 0)
+ return (-1);
+ /* Reasonable values. */
+ if (maxpins < 0 || maxpins > 4096) {
+ errno = EINVAL;
+ return (-1);
+ }
+ cfgs = calloc(maxpins + 1, sizeof(*cfgs));
+ if (cfgs == NULL)
+ return (-1);
+ for (i = 0; i <= maxpins; i++) {
+ cfgs[i].g_pin = i;
+ gpio_pin_config(handle, &cfgs[i]);
+ }
+ *pcfgs = cfgs;
+
+ return (maxpins);
+}
+
+int
+gpio_pin_config(gpio_handle_t handle, gpio_config_t *cfg)
+{
+ struct gpio_pin gppin;
+
+ if (cfg == NULL)
+ return (-1);
+ gppin.gp_pin = cfg->g_pin;
+ if (ioctl(handle, GPIOGETCONFIG, &gppin) < 0)
+ return (-1);
+ strlcpy(cfg->g_name, gppin.gp_name, GPIOMAXNAME);
+ cfg->g_caps = gppin.gp_caps;
+ cfg->g_flags = gppin.gp_flags;
+
+ return (0);
+}
+
+int
+gpio_pin_set_name(gpio_handle_t handle, gpio_pin_t pin, char *name)
+{
+ struct gpio_pin gppin;
+
+ if (name == NULL)
+ return (-1);
+ bzero(&gppin, sizeof(gppin));
+ gppin.gp_pin = pin;
+ strlcpy(gppin.gp_name, name, GPIOMAXNAME);
+ if (ioctl(handle, GPIOSETNAME, &gppin) < 0)
+ return (-1);
+
+ return (0);
+}
+
+int
+gpio_pin_set_flags(gpio_handle_t handle, gpio_config_t *cfg)
+{
+ struct gpio_pin gppin;
+
+ if (cfg == NULL)
+ return (-1);
+ gppin.gp_pin = cfg->g_pin;
+ gppin.gp_flags = cfg->g_flags;
+ if (ioctl(handle, GPIOSETCONFIG, &gppin) < 0)
+ return (-1);
+
+ return (0);
+}
+
+gpio_value_t
+gpio_pin_get(gpio_handle_t handle, gpio_pin_t pin)
+{
+ struct gpio_req gpreq;
+
+ bzero(&gpreq, sizeof(gpreq));
+ gpreq.gp_pin = pin;
+ if (ioctl(handle, GPIOGET, &gpreq) < 0)
+ return (GPIO_VALUE_INVALID);
+
+ return (gpreq.gp_value);
+}
+
+int
+gpio_pin_set(gpio_handle_t handle, gpio_pin_t pin, gpio_value_t value)
+{
+ struct gpio_req gpreq;
+
+ if (value == GPIO_VALUE_INVALID)
+ return (-1);
+ bzero(&gpreq, sizeof(gpreq));
+ gpreq.gp_pin = pin;
+ gpreq.gp_value = value;
+ if (ioctl(handle, GPIOSET, &gpreq) < 0)
+ return (-1);
+
+ return (0);
+}
+
+int
+gpio_pin_toggle(gpio_handle_t handle, gpio_pin_t pin)
+{
+ gpio_value_t value;
+
+ value = gpio_pin_get(handle, pin);
+ if (value == GPIO_VALUE_INVALID)
+ return (-1);
+ value = !value;
+
+ return (gpio_pin_set(handle, pin, value));
+}
+
+int
+gpio_pin_low(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set(handle, pin, GPIO_VALUE_LOW));
+}
+
+int
+gpio_pin_high(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set(handle, pin, GPIO_VALUE_HIGH));
+}
+
+static int
+gpio_pin_set_flag(gpio_handle_t handle, gpio_pin_t pin, uint32_t flag)
+{
+ gpio_config_t cfg;
+
+ bzero(&cfg, sizeof(cfg));
+ cfg.g_pin = pin;
+ if (gpio_pin_config(handle, &cfg) < 0)
+ return (-1);
+ cfg.g_flags = flag;
+
+ return (gpio_pin_set_flags(handle, &cfg));
+}
+
+int
+gpio_pin_input(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_INPUT));
+}
+
+int
+gpio_pin_output(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_OUTPUT));
+}
+
+int
+gpio_pin_opendrain(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_OPENDRAIN));
+}
+
+int
+gpio_pin_pushpull(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_PUSHPULL));
+}
+
+int
+gpio_pin_tristate(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_TRISTATE));
+}
+
+int
+gpio_pin_pullup(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_PULLUP));
+}
+
+int
+gpio_pin_pulldown(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_PULLDOWN));
+}
+
+int
+gpio_pin_invin(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_INVIN));
+}
+
+int
+gpio_pin_invout(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_INVOUT));
+}
+
+int
+gpio_pin_pulsate(gpio_handle_t handle, gpio_pin_t pin)
+{
+ return (gpio_pin_set_flag(handle, pin, GPIO_PIN_PULSATE));
+}
diff --git a/lib/libgpio/libgpio.h b/lib/libgpio/libgpio.h
new file mode 100644
index 0000000..a832234
--- /dev/null
+++ b/lib/libgpio/libgpio.h
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2013-2014 Rui Paulo <rpaulo@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBGPIO_H_
+#define _LIBGPIO_H_
+
+#include <sys/gpio.h>
+
+__BEGIN_DECLS
+
+#define GPIO_INVALID_HANDLE -1
+typedef int gpio_handle_t;
+typedef uint32_t gpio_pin_t;
+
+/*
+ * Structure describing a GPIO pin configuration.
+ */
+typedef struct {
+ gpio_pin_t g_pin;
+ char g_name[GPIOMAXNAME];
+ uint32_t g_caps;
+ uint32_t g_flags;
+} gpio_config_t;
+
+typedef enum {
+ GPIO_VALUE_INVALID = -1,
+ GPIO_VALUE_LOW = GPIO_PIN_LOW,
+ GPIO_VALUE_HIGH = GPIO_PIN_HIGH
+} gpio_value_t;
+
+/*
+ * Open /dev/gpiocN or a specific device.
+ */
+gpio_handle_t gpio_open(unsigned int);
+gpio_handle_t gpio_open_device(const char *);
+void gpio_close(gpio_handle_t);
+/*
+ * Get a list of all the GPIO pins.
+ */
+int gpio_pin_list(gpio_handle_t, gpio_config_t **);
+/*
+ * GPIO pin configuration.
+ *
+ * Retrieve the configuration of a specific GPIO pin. The pin number is
+ * passed through the gpio_config_t structure.
+ */
+int gpio_pin_config(gpio_handle_t, gpio_config_t *);
+/*
+ * Sets the GPIO pin name. The pin number and pin name to be set are passed
+ * as parameters.
+ */
+int gpio_pin_set_name(gpio_handle_t, gpio_pin_t, char *);
+/*
+ * Sets the GPIO flags on a specific GPIO pin. The pin number and the flags
+ * to be set are passed through the gpio_config_t structure.
+ */
+int gpio_pin_set_flags(gpio_handle_t, gpio_config_t *);
+/*
+ * GPIO pin values.
+ */
+int gpio_pin_get(gpio_handle_t, gpio_pin_t);
+int gpio_pin_set(gpio_handle_t, gpio_pin_t, int);
+int gpio_pin_toggle(gpio_handle_t, gpio_pin_t);
+/*
+ * Helper functions to set pin states.
+ */
+int gpio_pin_low(gpio_handle_t, gpio_pin_t);
+int gpio_pin_high(gpio_handle_t, gpio_pin_t);
+/*
+ * Helper functions to configure pins.
+ */
+int gpio_pin_input(gpio_handle_t, gpio_pin_t);
+int gpio_pin_output(gpio_handle_t, gpio_pin_t);
+int gpio_pin_opendrain(gpio_handle_t, gpio_pin_t);
+int gpio_pin_pushpull(gpio_handle_t, gpio_pin_t);
+int gpio_pin_tristate(gpio_handle_t, gpio_pin_t);
+int gpio_pin_pullup(gpio_handle_t, gpio_pin_t);
+int gpio_pin_pulldown(gpio_handle_t, gpio_pin_t);
+int gpio_pin_invin(gpio_handle_t, gpio_pin_t);
+int gpio_pin_invout(gpio_handle_t, gpio_pin_t);
+int gpio_pin_pulsate(gpio_handle_t, gpio_pin_t);
+
+__END_DECLS
+
+#endif /* _LIBGPIO_H_ */
OpenPOWER on IntegriCloud