Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src first shot at documenting gpio(3lua)
details: https://anonhg.NetBSD.org/src/rev/bc9139c44b4b
branches: trunk
changeset: 790908:bc9139c44b4b
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Sat Oct 26 10:48:19 2013 +0000
description:
first shot at documenting gpio(3lua)
diffstat:
distrib/sets/lists/man/mi | 32 +++++++-
share/man/man3lua/Makefile | 14 ++-
share/man/man3lua/gpio.3lua | 178 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 221 insertions(+), 3 deletions(-)
diffs (264 lines):
diff -r 36f9e1bb54e3 -r bc9139c44b4b distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sat Oct 26 09:19:45 2013 +0000
+++ b/distrib/sets/lists/man/mi Sat Oct 26 10:48:19 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1442 2013/10/26 09:16:19 nonaka Exp $
+# $NetBSD: mi,v 1.1443 2013/10/26 10:48:19 mbalmer Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -637,6 +637,16 @@
./usr/share/man/cat3/atari/ahdi_writelabel.0 man-obsolete obsolete
./usr/share/man/cat3/i386 man-obsolete obsolete
./usr/share/man/cat3/i386/keycap.0 man-obsolete obsolete
+./usr/share/man/cat3lua/gpio.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.open.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.info.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.close.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.set.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.unset.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.read.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.write.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.toggle.0 man-sys-catman .cat
+./usr/share/man/cat3lua/gpio.attach.0 man-sys-catman .cat
./usr/share/man/cat3lua/intro.0 man-sys-catman .cat
./usr/share/man/cat4/aac.0 man-sys-catman .cat
./usr/share/man/cat4/ac97.0 man-sys-catman .cat
@@ -3670,6 +3680,16 @@
./usr/share/man/html1/zgrep.html man-util-htmlman html
./usr/share/man/html1/zmore.html man-util-htmlman html
./usr/share/man/html1/znew.html man-util-htmlman html
+./usr/share/man/html3lua/gpio.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.open.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.info.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.close.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.set.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.unset.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.read.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.write.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.toggle.html man-sys-htmlman html
+./usr/share/man/html3lua/gpio.attach.html man-sys-htmlman html
./usr/share/man/html3lua/intro.html man-sys-htmlman html
./usr/share/man/html4/aac.html man-sys-htmlman html
./usr/share/man/html4/ac97.html man-sys-htmlman html
@@ -6377,6 +6397,16 @@
./usr/share/man/man3/atari/ahdi_writelabel.3 man-obsolete obsolete
./usr/share/man/man3/i386 man-obsolete obsolete
./usr/share/man/man3/i386/keycap.3 man-obsolete obsolete
+./usr/share/man/man3lua/gpio.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.open.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.info.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.close.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.set.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.unset.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.read.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.write.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.toggle.3lua man-sys-man .man
+./usr/share/man/man3lua/gpio.attach.3lua man-sys-man .man
./usr/share/man/man3lua/intro.3lua man-sys-man .man
./usr/share/man/man4/aac.4 man-sys-man .man
./usr/share/man/man4/ac97.4 man-sys-man .man
diff -r 36f9e1bb54e3 -r bc9139c44b4b share/man/man3lua/Makefile
--- a/share/man/man3lua/Makefile Sat Oct 26 09:19:45 2013 +0000
+++ b/share/man/man3lua/Makefile Sat Oct 26 10:48:19 2013 +0000
@@ -1,6 +1,16 @@
-# $NetBSD: Makefile,v 1.1 2013/10/25 15:27:03 mbalmer Exp $
+# $NetBSD: Makefile,v 1.2 2013/10/26 10:48:19 mbalmer Exp $
+
+MAN= gpio.3lua intro.3lua
-MAN= intro.3lua
+MLINKS+=gpio.3lua gpio.open.3lua \
+ gpio.3lua gpio.info.3lua \
+ gpio.3lua gpio.close.3lua \
+ gpio.3lua gpio.set.3lua \
+ gpio.3lua gpio.unset.3lua \
+ gpio.3lua gpio.read.3lua \
+ gpio.3lua gpio.write.3lua \
+ gpio.3lua gpio.toggle.3lua \
+ gpio.3lua gpio.attach.3lua
.include <bsd.man.mk>
.include <bsd.subdir.mk>
diff -r 36f9e1bb54e3 -r bc9139c44b4b share/man/man3lua/gpio.3lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man3lua/gpio.3lua Sat Oct 26 10:48:19 2013 +0000
@@ -0,0 +1,178 @@
+.\" $NetBSD: gpio.3lua,v 1.1 2013/10/26 10:48:19 mbalmer Exp $
+.\"
+.\" Copyright (c) 2013 Marc Balmer <mbalmer%NetBSD.org@localhost>. 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.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+.\"
+.\"
+.Dd October 26, 2013
+.Dt GPIO 3lua
+.Os
+.Sh NAME
+.Nm gpio
+.Nd access
+.Xr gpio 4
+pins from Lua
+.Sh SYNOPSIS
+.Cd "require 'gpio'"
+.Pp
+.Bl -tag -width XXXX -compact
+.It Dv gpiodev = gpio.open(path)
+.It Dv pins = gpio.info(gpiodev)
+.It Dv gpio.close(gpiodev)
+.It Dv gpio.set(gpiodev, pin, flags)
+.It Dv gpio.unset(gpiodev, pin)
+.It Dv state = gpio.read(gpiodev, pin)
+.It Dv oldstate = gpio.write(gpiodev, pin, state)
+.It Dv gpio.toggle(gpiodev, pin)
+.It Dv gpio.attach(gpiodev, driver, offset, mask [, flags])
+.El
+.Sh DESCRIPTION
+The
+.Nm
+Lua provides access to a
+.Xr gpio 4
+device using the
+.Xr ioctl 2
+interface.
+.Pp
+.Bl -tag -width XXXX -compact
+.Pp
+.It Dv gpiodev = gpio.open(path)
+Open the gpio device and return an object to access its pins.
+.Pp
+.It Dv pins = gpio.info(gpiodev)
+Returns the number of pins.
+As with all remaining functions, this can also be called using the :
+notation, i.e. as
+.Em gpiodev:info() .
+.Pp
+.It Dv gpio.close(gpiodev)
+Close the gpio device.
+.Pp
+.It Dv gpio.set(gpiodev, pin, flags)
+Set gpio pin flags.
+Note that the pin number in this and all remaining functions is zero based and
+not one based, this to avoid confusion with tools like
+.Xr gpioctl 8
+which also number pins starting at zero.
+The following flags are defined:
+.Pp
+.Bl -tag -width XXXX -compact
+.It Dv gpio.PIN_INPUT
+Pin is an input.
+.Pp
+.It Dv gpio.PIN_OUTPUT
+Pin is an output.
+.Pp
+.It Dv gpio.PIN_INOUT
+Pin is birectional.
+.Pp
+.It Dv gpio.PIN_OPENDRAIN
+Pin is an open-drain output.
+.Pp
+.It Dv gpio.PIN_PUSHPULL
+Pin is a push-pull output.
+.Pp
+.It Dv gpio.PIN_TRISTATE
+Pin is tri-state (output disabled).
+.Pp
+.It Dv gpio.PIN_PULLUP
+Pin has an internal pull-up enabled.
+.Pp
+.It Dv gpio.PIN_PULLDOWN
+Pin has an internal pull-down enabled.
+.Pp
+.It Dv gpio.PIN_INVIN
+Invert input.
+.Pp
+.It Dv gpio.PIN_INVOUT
+Invert output.
+.Pp
+.It Dv gpio.PIN_USER
+Pin accessible by users.
+.Pp
+.It Dv gpio.PIN_PULSATE
+Pulsate pin at a hardware set frequency.
+.Pp
+.It Dv gpio.PIN_SET
+Pin is set.
+.El
+.Pp
+.It Dv gpio.unset(gpiodev, pin)
+Unset gpio pin.
+.Pp
+.It Dv stat = gpio.read(gpiodev, pin)
+Read the current pin state.
+.Pp
+.It Dv oldstate = gpio.write(gpiodev, pin, state)
+Write the pin state returning the old state.
+The following states are defined:
+.Pp
+.Bl -tag -width XXXX -compact
+.It Dv gpio.PIN_LOW
+Pin is in the low state.
+.Pp
+.It Dv gpio.PIN_HIGH
+Pin is in the high state.
+.El
+.Pp
+.It Dv gpio.toggle(gpiodev, pin)
+Toggle pin state.
+.Pp
+.It Dv gpio.attach(gpiodev, driver, offset, mask [, flags])
+Attach a device driver with offset, mask, and optional flags at a pin.
+.El
+.Sh EXAMPLES
+The following example code opens
+.Pa /dev/gpio0
+and prints all pin values:
+.Bd -literal
+local gpio = require 'gpio'
+
+gpiodev = gpio.open('/dev/gpio0')
+
+local npins = gpiodev:info()
+
+for n = 1, npins do
+ print('pin ' .. n .. ': ' .. gpiodev:read(n - 1))
+end
+.Ed
+.Sh SEE ALSO
+.Xr lua 1 ,
+.Xr luac 1 ,
+.Xr intro 3lua ,
+.Xr gpio 4
+.Sh HISTORY
+An
+.Nm
+manual appeared in
+.Nx 7.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+Lua binding was written by
+.An Marc Balmer Aq Mt mbalmer%NetBSD.org@localhost .
Home |
Main Index |
Thread Index |
Old Index