CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: wiz Date: Wed Feb 13 11:40:41 UTC 2019 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/gpioctl/gpioctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.21 src/usr.sbin/gpioctl/gpioctl.8:1.22 --- src/usr.sbin/gpioctl/gpioctl.8:1.21 Tue Feb 12 21:41:38 2019 +++ src/usr.sbin/gpioctl/gpioctl.8 Wed Feb 13 11:40:41 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpioctl.8,v 1.21 2019/02/12 21:41:38 mlelstv Exp $ +.\" $NetBSD: gpioctl.8,v 1.22 2019/02/13 11:40:41 wiz Exp $ .\" .\" Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer .\" Copyright (c) 2004 Alexander Yurchenko @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd May 19, 2013 +.Dd February 12, 2019 .Dt GPIOCTL 8 .Os .Sh NAME
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mlelstv Date: Tue Feb 12 21:41:39 UTC 2019 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 Log Message: Document options to select alternate GPIO modes. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/gpioctl/gpioctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.20 src/usr.sbin/gpioctl/gpioctl.8:1.21 --- src/usr.sbin/gpioctl/gpioctl.8:1.20 Tue Mar 18 18:20:46 2014 +++ src/usr.sbin/gpioctl/gpioctl.8 Tue Feb 12 21:41:38 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpioctl.8,v 1.20 2014/03/18 18:20:46 riastradh Exp $ +.\" $NetBSD: gpioctl.8,v 1.21 2019/02/12 21:41:38 mlelstv Exp $ .\" .\" Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer .\" Copyright (c) 2004 Alexander Yurchenko @@ -141,6 +141,8 @@ invert input invert output .It pulsate pulsate output at a hardware-defined frequency and duty cycle +.It alt0 - alt7 +select alternate pin function 0 to 7 .El .Pp Note that not all the flags may be supported by the particular GPIO controller.
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: christos Date: Fri Oct 19 22:51:13 UTC 2018 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: add __RCSID To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.24 src/usr.sbin/gpioctl/gpioctl.c:1.25 --- src/usr.sbin/gpioctl/gpioctl.c:1.24 Sat May 19 09:59:07 2018 +++ src/usr.sbin/gpioctl/gpioctl.c Fri Oct 19 18:51:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.24 2018/05/19 13:59:07 thorpej Exp $ */ +/* $NetBSD: gpioctl.c,v 1.25 2018/10/19 22:51:13 christos Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer @@ -16,6 +16,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +__RCSID("$NetBSD: gpioctl.c,v 1.25 2018/10/19 22:51:13 christos Exp $"); /* * Program to control GPIO devices.
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: bouyer Date: Tue Apr 5 10:58:04 UTC 2016 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: Fix pasto for GPIO_PIN_EVENTS/GPIO_PIN_LEVEL/GPIO_PIN_FALLING (not used at this time) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.22 src/usr.sbin/gpioctl/gpioctl.c:1.23 --- src/usr.sbin/gpioctl/gpioctl.c:1.22 Sun Dec 6 07:31:28 2015 +++ src/usr.sbin/gpioctl/gpioctl.c Tue Apr 5 10:58:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.22 2015/12/06 07:31:28 mlelstv Exp $ */ +/* $NetBSD: gpioctl.c,v 1.23 2016/04/05 10:58:04 bouyer Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer@@ -72,9 +72,9 @@ static const struct bitstr { { GPIO_PIN_ALT5, "alt5" }, { GPIO_PIN_ALT6, "alt6" }, { GPIO_PIN_ALT7, "alt7" }, - { GPIO_PIN_ALT7, "events" }, - { GPIO_PIN_ALT7, "level" }, - { GPIO_PIN_ALT7, "falling" }, + { GPIO_PIN_EVENTS, "events" }, + { GPIO_PIN_LEVEL, "level" }, + { GPIO_PIN_FALLING, "falling" }, { GPIO_PIN_USER, "user" }, { 0, NULL }, };
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mlelstv Date: Sun Dec 6 07:31:28 UTC 2015 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: pass new pin configuration flags to driver. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.21 src/usr.sbin/gpioctl/gpioctl.c:1.22 --- src/usr.sbin/gpioctl/gpioctl.c:1.21 Thu Jan 29 03:30:06 2015 +++ src/usr.sbin/gpioctl/gpioctl.c Sun Dec 6 07:31:28 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.21 2015/01/29 03:30:06 christos Exp $ */ +/* $NetBSD: gpioctl.c,v 1.22 2015/12/06 07:31:28 mlelstv Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer@@ -64,6 +64,18 @@ static const struct bitstr { { GPIO_PIN_INVIN, "iin" }, { GPIO_PIN_INVOUT, "iout" }, { GPIO_PIN_PULSATE, "pulsate" }, + { GPIO_PIN_ALT0, "alt0" }, + { GPIO_PIN_ALT1, "alt1" }, + { GPIO_PIN_ALT2, "alt2" }, + { GPIO_PIN_ALT3, "alt3" }, + { GPIO_PIN_ALT4, "alt4" }, + { GPIO_PIN_ALT5, "alt5" }, + { GPIO_PIN_ALT6, "alt6" }, + { GPIO_PIN_ALT7, "alt7" }, + { GPIO_PIN_ALT7, "events" }, + { GPIO_PIN_ALT7, "level" }, + { GPIO_PIN_ALT7, "falling" }, + { GPIO_PIN_USER, "user" }, { 0, NULL }, };
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: christos Date: Thu Jan 29 03:30:06 UTC 2015 Modified Files: src/usr.sbin/gpioctl: Makefile gpioctl.c Removed Files: src/usr.sbin/gpioctl: strtonum.c Log Message: use strtonum from libc (Kamil Rytarowski) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/gpioctl/Makefile cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/gpioctl/gpioctl.c cvs rdiff -u -r1.1 -r0 src/usr.sbin/gpioctl/strtonum.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/Makefile diff -u src/usr.sbin/gpioctl/Makefile:1.4 src/usr.sbin/gpioctl/Makefile:1.5 --- src/usr.sbin/gpioctl/Makefile:1.4 Sat Jul 25 12:18:09 2009 +++ src/usr.sbin/gpioctl/Makefile Wed Jan 28 22:30:06 2015 @@ -1,7 +1,8 @@ -# $NetBSD: Makefile,v 1.4 2009/07/25 16:18:09 mbalmer Exp $ +# $NetBSD: Makefile,v 1.5 2015/01/29 03:30:06 christos Exp $ PROG= gpioctl -SRCS= gpioctl.c strtonum.c +SRCS= gpioctl.c +CPPFLAGS+=-D_OPENBSD_SOURCE MAN= gpioctl.8 Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.20 src/usr.sbin/gpioctl/gpioctl.c:1.21 --- src/usr.sbin/gpioctl/gpioctl.c:1.20 Sun May 19 11:31:23 2013 +++ src/usr.sbin/gpioctl/gpioctl.c Wed Jan 28 22:30:06 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.20 2013/05/19 15:31:23 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.21 2015/01/29 03:30:06 christos Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer mbal...@netbsd.org @@ -49,9 +49,6 @@ static void gpiounset(int pin, char *nam static void devattach(char *, int, uint32_t, uint32_t); __dead static void usage(void); -extern long long strtonum(const char *numstr, long long minval, -long long maxval, const char **errstrp); - static const struct bitstr { unsigned int mask; const char *string;
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Sun May 19 14:06:35 UTC 2013 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 Log Message: Remove stray 'To'. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/gpioctl/gpioctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.16 src/usr.sbin/gpioctl/gpioctl.8:1.17 --- src/usr.sbin/gpioctl/gpioctl.8:1.16 Sun Nov 13 14:39:42 2011 +++ src/usr.sbin/gpioctl/gpioctl.8 Sun May 19 14:06:35 2013 @@ -1,6 +1,6 @@ -.\ $NetBSD: gpioctl.8,v 1.16 2011/11/13 14:39:42 mbalmer Exp $ +.\ $NetBSD: gpioctl.8,v 1.17 2013/05/19 14:06:35 mbalmer Exp $ .\ -.\ Copyright (c) 2009, 2010, 2011 Marc Balmer m...@msys.ch +.\ Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org .\ .\ Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ .\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\ -.Dd November 13, 2011 +.Dd May 19, 2013 .Dt GPIOCTL 8 .Os .Sh NAME @@ -98,8 +98,6 @@ or .Ar toggle can be used. .Pp -To -.Pp Only pins that have been configured at securelevel 0, typically during system startup, are accessible once the securelevel has been raised. Pins can be given symbolic names for easier use.
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Sun May 19 15:31:23 UTC 2013 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 gpioctl.c Log Message: Make it easier to use gpioctl(8) in shell scripts: Add a -s flag which instructs gpioctl(8) to only output a single numeric value, either the number of pins if no pin number was passed as argumenti, or, the current state of the pin. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/gpioctl/gpioctl.8 cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.17 src/usr.sbin/gpioctl/gpioctl.8:1.18 --- src/usr.sbin/gpioctl/gpioctl.8:1.17 Sun May 19 14:06:35 2013 +++ src/usr.sbin/gpioctl/gpioctl.8 Sun May 19 15:31:23 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: gpioctl.8,v 1.17 2013/05/19 14:06:35 mbalmer Exp $ +.\ $NetBSD: gpioctl.8,v 1.18 2013/05/19 15:31:23 mbalmer Exp $ .\ .\ Copyright (c) 2009, 2010, 2011, 2013 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org @@ -23,6 +23,9 @@ .Nd control GPIO devices .Sh SYNOPSIS .Nm gpioctl +.Op Fl qs +.Ar device +.Nm gpioctl .Op Fl q .Ar device .Cm attach @@ -31,12 +34,12 @@ .Ar mask .Op Ar flag .Nm gpioctl -.Op Fl q +.Op Fl qs .Ar device .Ar pin .Op Ar 0 | 1 | 2 .Nm gpioctl -.Op Fl q +.Op Fl qs .Ar device .Ar pin .Op Ar on | off | toggle @@ -156,6 +159,12 @@ The options are as follows: .Bl -tag -width Ds .It Fl q Operate quietly i.e. nothing is printed to stdout. +.It Fl s +Only output a single number on stdout, representing either the state of the +pin or the number of available pins if no pin number was passed as argument. +This option is useful e.g. when +.Nm +is used in shell scripts to query the state of a pin. .El .Sh FILES .Bl -tag -width /dev/gpiou -compact Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.19 src/usr.sbin/gpioctl/gpioctl.c:1.20 --- src/usr.sbin/gpioctl/gpioctl.c:1.19 Sun Nov 13 13:20:02 2011 +++ src/usr.sbin/gpioctl/gpioctl.c Sun May 19 15:31:23 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: gpioctl.c,v 1.19 2011/11/13 13:20:02 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.20 2013/05/19 15:31:23 mbalmer Exp $ */ /* - * Copyright (c) 2008, 2010, 2011 Marc Balmer mbal...@netbsd.org + * Copyright (c) 2008, 2010, 2011, 2013 Marc Balmer mbal...@netbsd.org * Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org * * Permission to use, copy, modify, and distribute this software for any @@ -39,6 +39,7 @@ static char *dev; static int devfd = -1; static int quiet = 0; +static int state = 0; static void getinfo(void); static void gpioread(int, char *); @@ -84,11 +85,14 @@ main(int argc, char *argv[]) char *flags; char devn[32]; - while ((ch = getopt(argc, argv, q)) != -1) + while ((ch = getopt(argc, argv, qs)) != -1) switch (ch) { case 'q': quiet = 1; break; + case 's': + quiet = state = 1; + break; default: usage(); /* NOTREACHED */ @@ -192,7 +196,6 @@ main(int argc, char *argv[]) } else gpioread(pin, nm); } - return EXIT_SUCCESS; } @@ -204,6 +207,9 @@ getinfo(void) if (ioctl(devfd, GPIOINFO, info) == -1) err(EXIT_FAILURE, GPIOINFO); + if (state) + printf(%d\n, info.gpio_npins); + if (quiet) return; @@ -224,6 +230,9 @@ gpioread(int pin, char *gp_name) if (ioctl(devfd, GPIOREAD, req) == -1) err(EXIT_FAILURE, GPIOREAD); + if (state) + printf(%d\n, req.gp_value); + if (quiet) return; @@ -256,6 +265,9 @@ gpiowrite(int pin, char *gp_name, int va err(EXIT_FAILURE, GPIOTOGGLE); } + if (state) + printf(%d\n, value 2 ? value : 1 - req.gp_value); + if (quiet) return; @@ -344,7 +356,7 @@ usage(void) const char *progname; progname = getprogname(); - fprintf(stderr, usage: %s [-q] device [pin] [0 | 1 | 2 | + fprintf(stderr, usage: %s [-qs] device [pin] [0 | 1 | 2 | on | off | toggle]\n, progname); fprintf(stderr,%s [-q] device pin set [flags] [name]\n, progname);
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Sun Nov 13 14:39:42 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 Log Message: Fix a lonely name. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/gpioctl/gpioctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.15 src/usr.sbin/gpioctl/gpioctl.8:1.16 --- src/usr.sbin/gpioctl/gpioctl.8:1.15 Sun Nov 13 13:20:02 2011 +++ src/usr.sbin/gpioctl/gpioctl.8 Sun Nov 13 14:39:42 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: gpioctl.8,v 1.15 2011/11/13 13:20:02 mbalmer Exp $ +.\ $NetBSD: gpioctl.8,v 1.16 2011/11/13 14:39:42 mbalmer Exp $ .\ .\ Copyright (c) 2009, 2010, 2011 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org @@ -41,7 +41,6 @@ .Ar pin .Op Ar on | off | toggle .Nm gpioctl -.Nm gpioctl .Op Fl q .Ar device .Ar pin
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Sat Nov 12 15:44:36 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.16 src/usr.sbin/gpioctl/gpioctl.c:1.17 --- src/usr.sbin/gpioctl/gpioctl.c:1.16 Mon Oct 3 11:16:48 2011 +++ src/usr.sbin/gpioctl/gpioctl.c Sat Nov 12 15:44:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.16 2011/10/03 11:16:48 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.17 2011/11/12 15:44:36 mbalmer Exp $ */ /* * Copyright (c) 2008, 2010, 2011 Marc Balmer mbal...@netbsd.org @@ -330,10 +330,10 @@ gpiopulse(int pin, char *gp_name, double return; if (gp_name) - printf(pin %s: pulse at %.f Hz with a %.f%% duty cylce\n, + printf(pin %s: pulse at %.f Hz with a %.f%% duty cyclce\n, gp_name, freq, dc); else - printf(pin %d: pulse at %.f Hz with a %.f%% duty cylce\n, + printf(pin %d: pulse at %.f Hz with a %.f%% duty cyclce\n, pin, freq, dc); }
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Sat Nov 12 16:34:03 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: Second part of typo fixing cycle... To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.17 src/usr.sbin/gpioctl/gpioctl.c:1.18 --- src/usr.sbin/gpioctl/gpioctl.c:1.17 Sat Nov 12 15:44:36 2011 +++ src/usr.sbin/gpioctl/gpioctl.c Sat Nov 12 16:34:03 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.17 2011/11/12 15:44:36 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.18 2011/11/12 16:34:03 mbalmer Exp $ */ /* * Copyright (c) 2008, 2010, 2011 Marc Balmer mbal...@netbsd.org @@ -330,10 +330,10 @@ gpiopulse(int pin, char *gp_name, double return; if (gp_name) - printf(pin %s: pulse at %.f Hz with a %.f%% duty cyclce\n, + printf(pin %s: pulse at %.f Hz with a %.f%% duty cycle\n, gp_name, freq, dc); else - printf(pin %d: pulse at %.f Hz with a %.f%% duty cyclce\n, + printf(pin %d: pulse at %.f Hz with a %.f%% duty cycle\n, pin, freq, dc); }
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: wiz Date: Thu Oct 6 11:06:44 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 Log Message: Sort SEE ALSO. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/gpioctl/gpioctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.13 src/usr.sbin/gpioctl/gpioctl.8:1.14 --- src/usr.sbin/gpioctl/gpioctl.8:1.13 Mon Oct 3 11:16:48 2011 +++ src/usr.sbin/gpioctl/gpioctl.8 Thu Oct 6 11:06:44 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: gpioctl.8,v 1.13 2011/10/03 11:16:48 mbalmer Exp $ +.\ $NetBSD: gpioctl.8,v 1.14 2011/10/06 11:06:44 wiz Exp $ .\ .\ Copyright (c) 2009, 2010, 2011 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org @@ -212,8 +212,8 @@ Toggle the error_led: .Pp .Dl # gpioctl gpio0 error_led 2 .Sh SEE ALSO -.Xr drvctl 8 , -.Xr gpio 4 +.Xr gpio 4 , +.Xr drvctl 8 .Sh HISTORY The .Nm
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Thu Sep 15 11:46:32 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: Bump (c) year. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.12 src/usr.sbin/gpioctl/gpioctl.c:1.13 --- src/usr.sbin/gpioctl/gpioctl.c:1.12 Tue Aug 30 18:50:48 2011 +++ src/usr.sbin/gpioctl/gpioctl.c Thu Sep 15 11:46:32 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: gpioctl.c,v 1.12 2011/08/30 18:50:48 joerg Exp $ */ +/* $NetBSD: gpioctl.c,v 1.13 2011/09/15 11:46:32 mbalmer Exp $ */ /* - * Copyright (c) 2008, 2010 Marc Balmer mbal...@netbsd.org + * Copyright (c) 2008, 2010, 2011 Marc Balmer mbal...@netbsd.org * Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org * * Permission to use, copy, modify, and distribute this software for any
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: joerg Date: Tue Aug 30 18:50:48 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.11 src/usr.sbin/gpioctl/gpioctl.c:1.12 --- src/usr.sbin/gpioctl/gpioctl.c:1.11 Sun Aug 28 07:48:50 2011 +++ src/usr.sbin/gpioctl/gpioctl.c Tue Aug 30 18:50:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: gpioctl.c,v 1.11 2011/08/28 07:48:50 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.12 2011/08/30 18:50:48 joerg Exp $ */ /* * Copyright (c) 2008, 2010 Marc Balmer mbal...@netbsd.org @@ -36,9 +36,9 @@ #include string.h #include unistd.h -char *dev; -int devfd = -1; -int quiet = 0; +static char *dev; +static int devfd = -1; +static int quiet = 0; static void getinfo(void); static void gpioread(int, char *); @@ -48,12 +48,12 @@ static void gpiounset(int pin, char *name); static void devattach(char *, int, uint32_t); static void devdetach(char *); -static void usage(void); +__dead static void usage(void); extern long long strtonum(const char *numstr, long long minval, long long maxval, const char **errstrp); -const struct bitstr { +static const struct bitstr { unsigned int mask; const char *string; } pinflags[] = {
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: wiz Date: Sun Aug 28 17:10:38 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 Log Message: Use Cm to mark up command arguments. Use An -nosplit to avoid linebreak in sentence. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/gpioctl/gpioctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.9 src/usr.sbin/gpioctl/gpioctl.8:1.10 --- src/usr.sbin/gpioctl/gpioctl.8:1.9 Sun Aug 28 07:48:50 2011 +++ src/usr.sbin/gpioctl/gpioctl.8 Sun Aug 28 17:10:37 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: gpioctl.8,v 1.9 2011/08/28 07:48:50 mbalmer Exp $ +.\ $NetBSD: gpioctl.8,v 1.10 2011/08/28 17:10:37 wiz Exp $ .\ .\ Copyright (c) 2009, 2010, 2011 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org @@ -25,14 +25,14 @@ .Nm gpioctl .Op Fl q .Ar device -attach +.Cm attach .Ar device .Ar offset .Ar mask .Nm gpioctl .Op Fl q .Ar device -detach +.Cm detach .Ar device .Nm gpioctl .Op Fl q @@ -48,20 +48,20 @@ .Op Fl q .Ar device .Ar pin -pulse +.Cm pulse .Op Ar frequency Op Ar duty cycle .Nm gpioctl .Op Fl q .Ar device .Ar pin -set +.Cm set .Op Ar flags .Op Ar name .Nm gpioctl .Op Fl q .Ar device .Ar pin -unset +.Cm unset .Sh DESCRIPTION The .Nm @@ -222,6 +222,7 @@ and .Nx 4.0 . .Sh AUTHORS +.An -nosplit The .Nm program was written by
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Fri Aug 12 08:02:34 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.8 gpioctl.c Log Message: Make some functions static, use getprogname() instead of 'extern char *__progname'. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/gpioctl/gpioctl.8 cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.7 src/usr.sbin/gpioctl/gpioctl.8:1.8 --- src/usr.sbin/gpioctl/gpioctl.8:1.7 Fri Sep 25 20:27:50 2009 +++ src/usr.sbin/gpioctl/gpioctl.8 Fri Aug 12 08:02:33 2011 @@ -1,6 +1,6 @@ -.\ $NetBSD: gpioctl.8,v 1.7 2009/09/25 20:27:50 mbalmer Exp $ +.\ $NetBSD: gpioctl.8,v 1.8 2011/08/12 08:02:33 mbalmer Exp $ .\ -.\ Copyright (c) 2009 Marc Balmer m...@msys.ch +.\ Copyright (c) 2009, 2010 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org .\ .\ Permission to use, copy, modify, and distribute this software for any Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.8 src/usr.sbin/gpioctl/gpioctl.c:1.9 --- src/usr.sbin/gpioctl/gpioctl.c:1.8 Fri Sep 25 20:27:50 2009 +++ src/usr.sbin/gpioctl/gpioctl.c Fri Aug 12 08:02:33 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: gpioctl.c,v 1.8 2009/09/25 20:27:50 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.9 2011/08/12 08:02:33 mbalmer Exp $ */ /* - * Copyright (c) 2008 Marc Balmer mbal...@openbsd.org + * Copyright (c) 2008, 2010 Marc Balmer mbal...@openbsd.org * Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org * * Permission to use, copy, modify, and distribute this software for any @@ -40,15 +40,14 @@ int devfd = -1; int quiet = 0; -void getinfo(void); -void gpioread(int, char *); -void gpiowrite(int, char *, int); -void gpioset(int pin, char *name, int flags, char *alias); -void gpiounset(int pin, char *name); -void devattach(char *, int, u_int32_t); -void devdetach(char *); - -__dead void usage(void); +static void getinfo(void); +static void gpioread(int, char *); +static void gpiowrite(int, char *, int); +static void gpioset(int pin, char *name, int flags, char *alias); +static void gpiounset(int pin, char *name); +static void devattach(char *, int, u_int32_t); +static void devdetach(char *); +static void usage(void); extern long long strtonum(const char *numstr, long long minval, long long maxval, const char **errstrp); @@ -187,7 +186,7 @@ return EXIT_SUCCESS; } -void +static void getinfo(void) { struct gpio_info info; @@ -201,7 +200,7 @@ printf(%s: %d pins\n, dev, info.gpio_npins); } -void +static void gpioread(int pin, char *gp_name) { struct gpio_req req; @@ -224,7 +223,7 @@ printf(pin %d: state %d\n, pin, req.gp_value); } -void +static void gpiowrite(int pin, char *gp_name, int value) { struct gpio_req req; @@ -257,7 +256,7 @@ (value 2 ? value : 1 - req.gp_value)); } -void +static void gpioset(int pin, char *name, int fl, char *alias) { struct gpio_set set; @@ -299,7 +298,7 @@ printf(\n); } -void +static void gpiounset(int pin, char *name) { struct gpio_set set; @@ -314,7 +313,7 @@ err(EXIT_FAILURE, GPIOUNSET); } -void +static void devattach(char *dvname, int offset, u_int32_t mask) { struct gpio_attach attach; @@ -327,7 +326,7 @@ err(EXIT_FAILURE, GPIOATTACH); } -void +static void devdetach(char *dvname) { struct gpio_attach attach; @@ -338,19 +337,20 @@ err(EXIT_FAILURE, GPIODETACH); } -void +static void usage(void) { - extern char *__progname; + const char *progname; + progname = getprogname(); fprintf(stderr, usage: %s [-q] device [pin] [0 | 1 | 2 | - on | off | toggle]\n, __progname); + on | off | toggle]\n, progname); fprintf(stderr,%s [-q] device pin set [flags] [name]\n, - __progname); - fprintf(stderr,%s [-q] device pin unset\n, __progname); + progname); + fprintf(stderr,%s [-q] device pin unset\n, progname); fprintf(stderr,%s [-q] device attach device offset mask\n, - __progname); - fprintf(stderr,%s [-q] device detach device\n, __progname); + progname); + fprintf(stderr,%s [-q] device detach device\n, progname); exit(EXIT_FAILURE); }
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Fri Aug 12 08:06:23 UTC 2011 Modified Files: src/usr.sbin/gpioctl: gpioctl.c Log Message: use my NetBSD email address To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/gpioctl/gpioctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/gpioctl.c diff -u src/usr.sbin/gpioctl/gpioctl.c:1.9 src/usr.sbin/gpioctl/gpioctl.c:1.10 --- src/usr.sbin/gpioctl/gpioctl.c:1.9 Fri Aug 12 08:02:33 2011 +++ src/usr.sbin/gpioctl/gpioctl.c Fri Aug 12 08:06:23 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: gpioctl.c,v 1.9 2011/08/12 08:02:33 mbalmer Exp $ */ +/* $NetBSD: gpioctl.c,v 1.10 2011/08/12 08:06:23 mbalmer Exp $ */ /* - * Copyright (c) 2008, 2010 Marc Balmer mbal...@openbsd.org + * Copyright (c) 2008, 2010 Marc Balmer mbal...@netbsd.org * Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org * * Permission to use, copy, modify, and distribute this software for any
CVS commit: src/usr.sbin/gpioctl
Module Name:src Committed By: mbalmer Date: Sat Jul 25 16:18:09 UTC 2009 Modified Files: src/usr.sbin/gpioctl: Makefile gpioctl.8 gpioctl.c Added Files: src/usr.sbin/gpioctl: strtonum.c Log Message: Reworked gpioctl(8) command to reflect recent gpio(4) changes. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/gpioctl/Makefile cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/gpioctl/gpioctl.8 cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/gpioctl/gpioctl.c cvs rdiff -u -r0 -r1.1 src/usr.sbin/gpioctl/strtonum.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/gpioctl/Makefile diff -u src/usr.sbin/gpioctl/Makefile:1.3 src/usr.sbin/gpioctl/Makefile:1.4 --- src/usr.sbin/gpioctl/Makefile:1.3 Wed Apr 22 15:23:03 2009 +++ src/usr.sbin/gpioctl/Makefile Sat Jul 25 16:18:09 2009 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.3 2009/04/22 15:23:03 lukem Exp $ +# $NetBSD: Makefile,v 1.4 2009/07/25 16:18:09 mbalmer Exp $ PROG= gpioctl -SRCS= gpioctl.c +SRCS= gpioctl.c strtonum.c MAN= gpioctl.8 Index: src/usr.sbin/gpioctl/gpioctl.8 diff -u src/usr.sbin/gpioctl/gpioctl.8:1.4 src/usr.sbin/gpioctl/gpioctl.8:1.5 --- src/usr.sbin/gpioctl/gpioctl.8:1.4 Wed Jan 9 15:56:27 2008 +++ src/usr.sbin/gpioctl/gpioctl.8 Sat Jul 25 16:18:09 2009 @@ -1,6 +1,6 @@ -.\ $NetBSD: gpioctl.8,v 1.4 2008/01/09 15:56:27 xtraeme Exp $ -.\ $OpenBSD: gpioctl.8,v 1.5 2004/12/02 05:11:40 grange Exp $ +.\ $NetBSD: gpioctl.8,v 1.5 2009/07/25 16:18:09 mbalmer Exp $ .\ +.\ Copyright (c) 2009 Marc Balmer m...@msys.ch .\ Copyright (c) 2004 Alexander Yurchenko gra...@openbsd.org .\ .\ Permission to use, copy, modify, and distribute this software for any @@ -15,66 +15,71 @@ .\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\ -.Dd January 9, 2008 +.Dd July 15, 2009 .Dt GPIOCTL 8 .Os .Sh NAME .Nm gpioctl .Nd control GPIO devices .Sh SYNOPSIS -.Nm -.Op Fl hq -.Op Fl d Ar device -.Op Ar pin +.Nm gpioctl +.Op Fl q +.Ar device +attach +.Ar device +.Ar offset +.Ar mask +.Nm gpioctl +.Op Fl q +.Ar device +detach +.Ar device +.Nm gpioctl +.Op Fl q +.Ar device +.Ar pin .Op Ar 0 | 1 | 2 -.Nm -.Op Fl hq -.Op Fl d Ar device -.Fl c +.Nm gpioctl +.Op Fl q +.Ar device .Ar pin +.Op Ar on | off | toggle +.Nm gpioctl +.Op Fl q +.Ar device +.Ar pin +set .Op Ar flags +.Op Ar name +.Nm gpioctl +.Op Fl q +.Ar device +.Ar pin +unset .Sh DESCRIPTION The .Nm -program allows manipulation of -.Tn GPIO +program allows manipulation of GPIO (General Purpose Input/Output) device pins. -Such devices can be either part of the chipset or embedded -.Tn CPU , +Such devices can be either part of the chipset or embedded CPU, or a separate chip. -The usual way of using -.Tn GPIO -is to connect some simple devices such as LEDs, 1-wire thermal sensors, -etc., to its pins. +The usual way of using GPIO +is to connect some simple devices such as LEDs and 1-wire thermal sensors +to its pins. .Pp -Each -.Tn GPIO -device has an associated device file in the +Each GPIO device has an associated device file in the .Pa /dev directory. -By default -.Nm -uses -.Pa /dev/gpio0 , -which corresponds to the first found -.Tn GPIO -device in the system. -If more than one -.Tn GPIO -device is present, an alternative device file can be specified with the -.Fl d -option in order to access a particular -.Tn GPIO -device. -.Pp -When executed without any arguments, -.Nm -reads information about the -.Tn GPIO -device and displays it. +.Ar device +can be specified with or without the +.Pa /dev +prefix. +For example, +.Pa /dev/gpio0 +or +.Pa gpio0 . .Pp -.Tn GPIO -pins can be either +GPIO pins can be either .Dq read or .Dq written @@ -82,9 +87,7 @@ If only a .Ar pin number is specified on the command line, the pin state will be read -from the -.Tn GPIO -controller and displayed. +from the GPIO controller and displayed. To write to a pin, a value must be specified after the .Ar pin number. @@ -92,15 +95,28 @@ A value of 2 has a special meaning: it .Dq toggles the pin, i.e. changes its state to the opposite. +Instead of the numerical values, the word +.Ar on , +.Ar off , +or +.Ar toggle +can be used. .Pp -Each pin can be configured with different flags with the -.Fl c -option. -The following configuration flags are supported by the -.Tn GPIO -framework: +Only pins that have been configured at securelevel 0, typically during system +startup, are accessible once the securelevel has been raised. +Pins can be given symbolic names for easier use. +Besides using individual pins, device drivers that use GPIO pins can be +attached to a +.Xr gpio 4 +device using the +.Nm +command. +.Pp +The following configuration +.Ar flags +are supported by the GPIO framework: .Pp -.Bl -tag -width XXX -offset indent -compact +.Bl -tag -width Ds -offset indent -compact .It in