Merge branch 'master' of git.drogon.net:projects/wiringPi

Conflicts:
	gpio/gpio.c
This commit is contained in:
Gordon Henderson
2012-08-19 15:33:26 +01:00
5 changed files with 161 additions and 25 deletions

View File

@@ -41,7 +41,7 @@ OBJ = gpio.o
all: gpio
gpio: gpio.o
gpio: gpio.o /usr/local/lib/libwiringPi.a
@echo [LD]
@$(CC) -o $@ gpio.o $(LDFLAGS) $(LIBS)

View File

@@ -4,20 +4,38 @@
gpio \- Command-line access to Raspberry Pi and PiFace GPIO
.SH SYNOPSIS
.TP
.B gpio
.RB [ \-v ]
.TP
.B \-v
.PP
.B gpio
.RB [ \-g ]
.RB < read/write/pwm/mode ...>
.TP
.B [ \-g ]
.B read/write/pwm/mode ...
.PP
.B gpio
.RB [ \-p ]
.RB < read/write/mode ...>
.TP
.B [ \-p ]
.B read/write/mode
.B ...
.PP
.B gpio
.RB < export/edge/unexport/unexportall/exports ...>
.B unexportall/exports
.PP
.B gpio
.B export/edge/unexport
.B ...
.PP
.B gpio
.B drive
group value
.PP
.B gpio
.B pwm-bal/pwm-ms
.PP
.B gpio
.B pwmr
range
.PP
.B gpio
.B load \ i2c/spi
.SH DESCRIPTION
@@ -64,6 +82,14 @@ Set a pin into \fIinput\fR, \fIoutput\fR or \fIpwm\fR mode. Can also
use the literals \fIup\fR, \fIdown\fR or \fItri\fR to set the internal
pull-up, pull-down or tristate (off) controls.
.TP
.B unexportall
Un-Export all the GPIO pins in the /sys/class/gpio directory.
.TP
.B exports
Print a list (if any) of all the exported GPIO pins and their current values.
.TP
.B export
Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the
@@ -96,12 +122,26 @@ requiring root/sudo.
Un-Export a GPIO pin in the /sys/class/gpio directory.
.TP
.B unexportall
Un-Export all the GPIO pins in the /sys/class/gpio directory.
.B drive
group value
Change the pad driver value for the given pad group to the supplied drive
value. Group is 0, 1 or 2 and value is 0-7. Do not use unless you are
absolutely sure you know what you're doing.
.TP
.B exports
Print a list (if any) of all the exported GPIO pins and their current values.
.B pwm-bal/pwm-ms
Change the PWM mode to balanced (the default) or mark:space ratio (traditional)
.TP
.B pwmr
Change the PWM range register. The default is 1024.
.TP
.B load i2c/spi
This loads the i2c or the spi drivers into the system and changes the permissions on
the associated /dev/ entries so that the current user has access to them.
.SH "WiringPi vs. GPIO Pin numbering"
@@ -170,7 +210,7 @@ Gordon Henderson
.SH "REPORTING BUGS"
Report bugs to <gordon@drogon.net>
Report bugs to <projects@drogon.net>
.SH COPYRIGHT

View File

@@ -47,6 +47,8 @@ char *usage = "Usage: gpio -v\n"
" gpio [-p] <read/write/mode> ...\n"
" gpio export/edge/unexport/unexportall/exports ...\n"
" gpio drive <group> <value>\n"
" gpio pwm-bal/pwm-ms \n"
" gpio pwmr <range> \n"
" gpio load spi/i2c" ;
@@ -487,7 +489,7 @@ void doMode (int argc, char *argv [])
*********************************************************************************
*/
void doPadDrive (int argc, char *argv [])
static void doPadDrive (int argc, char *argv [])
{
int group, val ;
@@ -522,7 +524,7 @@ void doPadDrive (int argc, char *argv [])
*********************************************************************************
*/
void doWrite (int argc, char *argv [])
static void doWrite (int argc, char *argv [])
{
int pin, val ;
@@ -603,6 +605,39 @@ void doPwm (int argc, char *argv [])
}
/*
* doPwmMode: doPwmRange:
* Change the PWM mode and Range values
*********************************************************************************
*/
static void doPwmMode (int mode)
{
pwmSetMode (mode) ;
}
static void doPwmRange (int argc, char *argv [])
{
unsigned int range ;
if (argc != 3)
{
fprintf (stderr, "Usage: %s pwmr <range>\n", argv [0]) ;
exit (1) ;
}
range = (unsigned int)strtoul (argv [2], NULL, 10) ;
if (range == 0)
{
fprintf (stderr, "%s: range must be > 0\n", argv [0]) ;
exit (1) ;
}
pwmSetRange (range) ;
}
/*
* main:
* Start here
@@ -718,6 +753,15 @@ int main (int argc, char *argv [])
wpMode = WPI_MODE_PINS ;
}
// Check for PWM operations
if (wpMode != WPI_MODE_PIFACE)
{
if (strcasecmp (argv [1], "pwm-bal") == 0) { doPwmMode (PWM_MODE_BAL) ; return 0 ; }
if (strcasecmp (argv [1], "pwm-ms") == 0) { doPwmMode (PWM_MODE_MS) ; return 0 ; }
if (strcasecmp (argv [1], "pwmr") == 0) { doPwmRange (argc, argv) ; return 0 ; }
}
// Check for wiring commands
/**/ if (strcasecmp (argv [1], "read" ) == 0) doRead (argc, argv) ;