-.TH "GPIO" "21st October 2012" "Command-Line access to Raspberry Pi and PiFace GPIO"
+.TH GPIO 1 "September 2015" wiringPi "Command-Line access to Raspberry Pi's GPIO"
.SH NAME
-gpio \- Command-line access to Raspberry Pi and PiFace GPIO
+gpio \- Command-line access to Raspberry Pi's GPIO
.SH SYNOPSIS
.B gpio
.B \-v
.PP
.B gpio
-.B [ \-g ]
-.B read/write/wb/pwm/clock/mode ...
+.B [ \-g | \-1 ]
+.B mode/read/write/aread/awrite/wb/pwm/clock ...
+.PP
+.B gpio
+.B [ \-x extension:params ]
+.B mode/read/write/aread/awrite/pwm/pwmTone ...
.PP
.B gpio
.B [ \-p ]
-.B read/write/wb
+.B read/write/toggle/wb
.B ...
.PP
.B gpio
.B ...
.PP
.B gpio
+.B wfi
+.B ...
+.PP
+.B gpio
.B drive
group value
.PP
.B gpio
+.B usbp
+high | low
+.PP
+.B gpio
.B pwm-bal/pwm-ms
.PP
.B gpio
.TP
.B \-g
Use the BCM_GPIO pins numbers rather than wiringPi pin numbers.
-\fINOTE:\fR The BCM_GPIO pin numbers are always used with the
+\fINote:\fR The BCM_GPIO pin numbers are always used with the
export and edge commands.
+.TP
+.B \-1
+Use the physical pin numbers rather than wiringPi pin numbers.
+\fINote:\fR that this applies to the P1 connector only. It is not possible to
+use pins on the Revision 2 P5 connector this way, and as with \-g the
+BCM_GPIO pin numbers are always used with the export and edge commands.
+
+.TP
+.B \-x extension
+This causes the named extension to be initialised. Extensions
+comprise of a name (e.g. mcp23017) followed by a colon, then the
+pin-base, then more optional parameters depending on the extension type.
+See the web page on http://wiringpi.com/the-gpio-utility/
+
.TP
.B \-p
-Use the PiFace interface board and its corresponding pin numbers.
+Use the PiFace interface board and its corresponding pin numbers. The PiFace
+will always appear at pin number 200 in the gpio command. You can assign any
+pin numbers you like in your own programs though.
.TP
.B read <pin>
Write the given value (0 or 1) to the pin. You need to set the pin
to output mode first.
+.TP
+.B aread <pin>
+Read the analog value of the given pin. This needs to be uses in
+conjunction with a -x flag to add in an extension that handles analog
+inputs. respective logic levels.
+
+e.g. gpio -x mcp3002:200:0 aread 200
+
+will read the first analog input on an mcp3002 SPI ADC chip.
+
+.TP
+.B awrite <pin> <value>
+Write the analog value to the given pin. This needs to be used in
+conjunction with a -x flag to add in an extension that handles analog
+inputs. respective logic levels.
+
+e.g. gpio -x mcp4802:200:0 awrite 200 128
+
+will write the value 128 to the first DAC port on an mcp4802 chip on
+the Pi's SPI bus 0.
+
+
.TP
.B wb <value>
Write the given byte to the 8 main GPIO pins. You can prefix it with 0x
if the pin is in input mode, or the last value written if the pin is in output
mode.
+The readall command is usable with an extension module (via the -x parameter),
+but it's unable to determine pin modes or states, so will perform both a
+digital and analog read on each pin in-turn.
+
.TP
.B pwm <pin> <value>
Write a PWM value (0-1023) to the given pin. The pin needs to be put
use the literals \fIup\fR, \fIdown\fR or \fItri\fR to set the internal
pull-up, pull-down or tristate (off) controls.
+The ALT modes can also be set using \fIalt0\fR, \fIalt1\fR, ... \fIalt5\fR.
+
.TP
.B unexportall
Un-Export all the GPIO pins in the /sys/class/gpio directory.
.TP
.B export
Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the
-mode command above however only \fIin\fR and \fIout\fR are supported at
-this time. Note that the pin number is the \fBBCM_GPIO\fR number and
-not the wiringPi number.
+mode command above however only \fIin\fR, \fIout\fR, \fIhigh\fR and
+\fRlow\fR are supported at this time. Note that the pin number is the
+\fBBCM_GPIO\fR number and not the wiringPi number. The \fIhigh\fR and
+\fIlow\fR commands pre-set the output value at the same time as the
+export to output mode.
Once a GPIO pin has been exported, the \fBgpio\fR program changes the
ownership of the \fI/sys/class/gpio/gpioX/value\fR and if present in
.B unexport
Un-Export a GPIO pin in the /sys/class/gpio directory.
+.TP
+.B wfi <pin> <mode>
+This set the given pin to the supplied interrupt mode: rising, falling
+or both then waits for the interrupt to happen. It's a non-busy wait,
+so does not consume and CPU while it's waiting.
+
.TP
.B drive
group value
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 usbp
+high | low
+
+Change the USB current limiter to high (1.2 amps) or low (the default, 600mA)
+This is only applicable to the model B+
+
.TP
.B pwm-bal/pwm-ms
Change the PWM mode to balanced (the default) or mark:space ratio (traditional)
.B load i2c [baudrate]
This loads the i2c or drivers into the kernel and changes the permissions
on the associated /dev/ entries so that the current user has access to
-them. Optionally it will set the I2C baudrate to that supplied (or as
-close as the Pi can manage) The default speed is 100Kb/sec.
+them. Optionally it will set the I2C baudrate to that supplied in Kb/sec
+(or as close as the Pi can manage) The default speed is 100Kb/sec.
+
+Note: On recent kernels with the device tree enabled you should use the
+raspi-config program to load/unload the I2C device at boot time.
+(or disable the device tree to continue to use this method)
.TP
-.B load spi [buffer size in KB]
-This loads the the spi drivers into the kernel and changes the permissions
+.B load spi
+This loads the spi drivers into the kernel and changes the permissions
on the associated /dev/ entries so that the current user has access to
-them. Optionally it will set the SPI buffer size to that supplied. The
-default is 4KB.
+them. It used to have the ability to change the buffer size from the
+default of 4096 bytes to an arbitary value, however for some time the
+Pi Foundation have compiled the SPI device driver into the kernel and
+this has fixed the buffer size. The way to change it now is to edit
+the /boot/cmdline.txt file and add on spdev.bufsiz=8192 to set it to
+e.g. 8192 bytes then reboot.
+
+Note: On recent kernels with the device tree enabled you should use the
+raspi-config program to load/unload the SPI device at boot time.
+(or disable the device tree to continue to use this method)
.TP
.B gbr
The board jumpers need to be in-place to do this operation.
-.SH "WiringPi vs. BCM_GPIO Pin numbering"
+.SH "WiringPi vs. BCM_GPIO Pin numbering vs. Physical pin numbering"
.PP
-.TS
-r r r l.
-WiringPi GPIO-r1 GPIO-r2 Function
-_
-0 17 17
-1 18 18 (PWM)
-2 21 27
-3 22 22
-4 23 23
-5 24 24
-6 25 25
-7 4 4
-8 0 2 I2C: SDA0
-9 1 3 I2C: SCL0
-10 8 8 SPI: CE0
-11 7 7 SPI: CE1
-12 10 10 SPI: MOSI
-13 9 9 SPI: MISO
-14 11 11 SPI: SCLK
-15 14 14 TxD
-16 15 16 RxD
-17 - 28
-18 - 29
-19 - 30
-20 - 31
-.TE
-
-Note that "r1" and "r2" above refers to the board revision. Normally
-wiringPi detects the correct board revision with use for it's own
-numbering scheme, but if you are using a Revision 2 board with some
-of the pins which change numbers between revisions you will need
-to alter your software.
+The quickest way to get a list of the pin differences is to run the command
+.TP
+gpio readall
.SH FILES
.LP
WiringPi's home page
.IP
-https://projects.drogon.net/raspberry-pi/wiringpi/
+http://wiringpi.com/
.SH AUTHOR
.SH COPYRIGHT
-Copyright (c) 2012 Gordon Henderson
+Copyright (c) 2012-2015 Gordon Henderson
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.