Gordon Henderson | f6c40cb | 2015-09-24 22:35:31 +0100 | [diff] [blame] | 1 | .TH GPIO 1 "September 2015" wiringPi "Command-Line access to Raspberry Pi's GPIO" |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 2 | |
| 3 | .SH NAME |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 4 | gpio \- Command-line access to Raspberry Pi's GPIO |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 5 | |
| 6 | .SH SYNOPSIS |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 7 | .B gpio |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 8 | .B \-v |
| 9 | .PP |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 10 | .B gpio |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 11 | .B [ \-g | \-1 ] |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 12 | .B mode/read/write/aread/awrite/wb/pwm/clock/toggle/blink ... |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 13 | .PP |
| 14 | .B gpio |
| 15 | .B [ \-x extension:params ] |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 16 | .B mode/read/write/aread/awrite/pwm/toggle/blink ... |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 17 | .PP |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 18 | .B gpio |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 19 | .B [ \-p ] |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 20 | .B read/write/toggle/blink |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 21 | .B ... |
| 22 | .PP |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 23 | .B gpio |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 24 | .B readall |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 25 | .PP |
| 26 | .B gpio |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 27 | .B unexportall/exports |
| 28 | .PP |
| 29 | .B gpio |
| 30 | .B export/edge/unexport |
| 31 | .B ... |
| 32 | .PP |
| 33 | .B gpio |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 34 | .B wfi |
| 35 | .B ... |
| 36 | .PP |
| 37 | .B gpio |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 38 | .B drive |
| 39 | group value |
| 40 | .PP |
| 41 | .B gpio |
Gordon Henderson | df45388 | 2014-07-17 22:23:57 +0100 | [diff] [blame] | 42 | .B usbp |
| 43 | high | low |
| 44 | .PP |
| 45 | .B gpio |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 46 | .B pwm-bal/pwm-ms |
| 47 | .PP |
| 48 | .B gpio |
| 49 | .B pwmr |
| 50 | range |
| 51 | .PP |
| 52 | .B gpio |
Gordon Henderson | e8f6258 | 2013-01-28 13:00:47 +0000 | [diff] [blame] | 53 | .B load \ i2c/spi ... |
Gordon Henderson | 99095e3 | 2012-08-27 20:56:14 +0100 | [diff] [blame] | 54 | .PP |
| 55 | .B gpio |
| 56 | .B gbr |
| 57 | channel |
| 58 | .PP |
| 59 | .B gpio |
| 60 | .B gbw |
| 61 | channel value |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 62 | |
| 63 | .SH DESCRIPTION |
| 64 | |
| 65 | .B GPIO |
Gordon Henderson | 86a5c68 | 2012-10-02 14:32:12 +0100 | [diff] [blame] | 66 | is a swiss army knife of a command line tool to allow the user easy |
Gordon Henderson | 99095e3 | 2012-08-27 20:56:14 +0100 | [diff] [blame] | 67 | access to the GPIO pins on the Raspberry Pi and the SPI A/D and D/A |
Gordon Henderson | 86a5c68 | 2012-10-02 14:32:12 +0100 | [diff] [blame] | 68 | converters on the Gertboard. It's designed for simple testing and |
Gordon Henderson | 99095e3 | 2012-08-27 20:56:14 +0100 | [diff] [blame] | 69 | diagnostic purposes, but can be used in shell scripts for general if |
| 70 | somewhat slow control of the GPIO pins. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 71 | |
Gordon Henderson | 13bbba7 | 2013-01-14 11:31:56 +0000 | [diff] [blame] | 72 | It can also control the IO's on the PiFace IO board and load the SPI and I2C |
| 73 | kernel modules if required. |
| 74 | |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 75 | Additionally, it can be used to set the exports in the \fI/sys/class/gpio\fR |
| 76 | system directory to allow subsequent programs to use the \fR/sys/class/gpio\fR |
| 77 | interface without needing to be run as root. |
| 78 | |
| 79 | .SH OPTIONS |
| 80 | |
| 81 | .TP |
| 82 | .B \-v |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 83 | Output the current version including the board revision of the Raspberry Pi. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 84 | |
| 85 | .TP |
| 86 | .B \-g |
| 87 | Use the BCM_GPIO pins numbers rather than wiringPi pin numbers. |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 88 | \fINote:\fR The BCM_GPIO pin numbers are always used with the |
Gordon Henderson | 13bbba7 | 2013-01-14 11:31:56 +0000 | [diff] [blame] | 89 | export and edge commands. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 90 | |
| 91 | .TP |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 92 | .B \-1 |
| 93 | Use the physical pin numbers rather than wiringPi pin numbers. |
| 94 | \fINote:\fR that this applies to the P1 connector only. It is not possible to |
| 95 | use pins on the Revision 2 P5 connector this way, and as with \-g the |
| 96 | BCM_GPIO pin numbers are always used with the export and edge commands. |
| 97 | |
| 98 | .TP |
| 99 | .B \-x extension |
| 100 | This causes the named extension to be initialised. Extensions |
| 101 | comprise of a name (e.g. mcp23017) followed by a colon, then the |
| 102 | pin-base, then more optional parameters depending on the extension type. |
| 103 | See the web page on http://wiringpi.com/the-gpio-utility/ |
| 104 | |
| 105 | .TP |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 106 | .B \-p |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 107 | Use the PiFace interface board and its corresponding pin numbers. The PiFace |
| 108 | will always appear at pin number 200 in the gpio command. You can assign any |
| 109 | pin numbers you like in your own programs though. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 110 | |
| 111 | .TP |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 112 | .B read <pin> |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 113 | Read the digital value of the given pin and print 0 or 1 to represent the |
| 114 | respective logic levels. |
| 115 | |
| 116 | .TP |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 117 | .B write <pin> <value> |
Gordon Henderson | 25e4ec5 | 2012-12-06 21:49:41 +0000 | [diff] [blame] | 118 | Write the given value (0 or 1) to the pin. You need to set the pin |
| 119 | to output mode first. |
| 120 | |
| 121 | .TP |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 122 | .B toggle <pin> |
| 123 | Changes the state of a GPIO pin; 0 to 1, or 1 to 0. |
| 124 | |
| 125 | Note unlike the blink command, the pin must be in output mode first. |
| 126 | |
| 127 | .TP |
| 128 | .B blink <pin> |
| 129 | Blinks the given pin on/off. Press Control-C to exit. |
| 130 | |
| 131 | Note: This command explicitly sets the pin to output mode. |
| 132 | |
| 133 | .TP |
Gordon Henderson | 05e2f67 | 2014-05-20 11:43:07 +0100 | [diff] [blame] | 134 | .B aread <pin> |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 135 | Read the analog value of the given pin. This needs to be used in |
Gordon Henderson | 05e2f67 | 2014-05-20 11:43:07 +0100 | [diff] [blame] | 136 | conjunction with a -x flag to add in an extension that handles analog |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 137 | inputs. |
Gordon Henderson | 05e2f67 | 2014-05-20 11:43:07 +0100 | [diff] [blame] | 138 | |
| 139 | e.g. gpio -x mcp3002:200:0 aread 200 |
| 140 | |
| 141 | will read the first analog input on an mcp3002 SPI ADC chip. |
| 142 | |
| 143 | .TP |
| 144 | .B awrite <pin> <value> |
| 145 | Write the analog value to the given pin. This needs to be used in |
| 146 | conjunction with a -x flag to add in an extension that handles analog |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 147 | inputs. |
Gordon Henderson | 05e2f67 | 2014-05-20 11:43:07 +0100 | [diff] [blame] | 148 | |
| 149 | e.g. gpio -x mcp4802:200:0 awrite 200 128 |
| 150 | |
| 151 | will write the value 128 to the first DAC port on an mcp4802 chip on |
| 152 | the Pi's SPI bus 0. |
| 153 | |
| 154 | |
| 155 | .TP |
Gordon Henderson | 25e4ec5 | 2012-12-06 21:49:41 +0000 | [diff] [blame] | 156 | .B wb <value> |
| 157 | Write the given byte to the 8 main GPIO pins. You can prefix it with 0x |
| 158 | to specify a hexadecimal number. You need to set pins to output mode |
| 159 | first. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 160 | |
| 161 | .TP |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 162 | .B readall |
| 163 | Output a table of all GPIO pins values. The values represent the actual values read |
| 164 | if the pin is in input mode, or the last value written if the pin is in output |
| 165 | mode. |
| 166 | |
Gordon Henderson | 348bc73 | 2013-05-25 13:02:02 +0100 | [diff] [blame] | 167 | The readall command is usable with an extension module (via the -x parameter), |
| 168 | but it's unable to determine pin modes or states, so will perform both a |
| 169 | digital and analog read on each pin in-turn. |
| 170 | |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 171 | .TP |
| 172 | .B pwm <pin> <value> |
Gordon Henderson | 56c77b5 | 2013-02-01 20:19:22 +0000 | [diff] [blame] | 173 | Write a PWM value (0-1023) to the given pin. The pin needs to be put |
| 174 | into PWM mode first. |
| 175 | |
| 176 | .TP |
| 177 | .B clock <pin> <frequency> |
| 178 | Set the output frequency on the given pin. The pin needs to be put into |
| 179 | clock mode first. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 180 | |
| 181 | .TP |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 182 | .B mode <pin> <mode> |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 183 | Set a pin into \fIinput\fR, \fIoutput\fR or \fIpwm\fR mode. Can also |
| 184 | use the literals \fIup\fR, \fIdown\fR or \fItri\fR to set the internal |
| 185 | pull-up, pull-down or tristate (off) controls. |
| 186 | |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 187 | The ALT modes can also be set using \fIalt0\fR, \fIalt1\fR, ... \fIalt5\fR. |
| 188 | |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 189 | .TP |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 190 | .B unexportall |
| 191 | Un-Export all the GPIO pins in the /sys/class/gpio directory. |
| 192 | |
| 193 | .TP |
| 194 | .B exports |
| 195 | Print a list (if any) of all the exported GPIO pins and their current values. |
| 196 | |
| 197 | .TP |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 198 | .B export |
| 199 | Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the |
Gordon Henderson | 72b2af2 | 2015-02-03 14:53:32 +0000 | [diff] [blame] | 200 | mode command above however only \fIin\fR, \fIout\fR, \fIhigh\fR and |
| 201 | \fRlow\fR are supported at this time. Note that the pin number is the |
| 202 | \fBBCM_GPIO\fR number and not the wiringPi number. The \fIhigh\fR and |
| 203 | \fIlow\fR commands pre-set the output value at the same time as the |
| 204 | export to output mode. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 205 | |
| 206 | Once a GPIO pin has been exported, the \fBgpio\fR program changes the |
| 207 | ownership of the \fI/sys/class/gpio/gpioX/value\fR and if present in |
| 208 | later kernels, the \fI/sys/class/gpio/gpioX/edge\fR pseudo files to |
| 209 | that of the user running the \fBgpio\fR program. This means that you |
| 210 | can have a small script of gpio exports to setup the gpio pins as your |
| 211 | program requires without the need to run anything as root, or with the |
| 212 | sudo command. |
| 213 | |
| 214 | .TP |
| 215 | .B edge |
| 216 | This exports a GPIO pin in the \fI/sys/class/gpio\fR directory, set |
| 217 | the direction to input and set the edge interrupt method to \fInone\fR, |
| 218 | \fIrising\fR, \fIfalling\fR or \fIboth\fR. Use like the export command |
| 219 | above and note that \fBBCM_GPIO\fR pin number is used not not wiringPi pin |
| 220 | numbering. |
| 221 | |
Gordon Henderson | 86a5c68 | 2012-10-02 14:32:12 +0100 | [diff] [blame] | 222 | Like the export commands above, ownership is set to that of the |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 223 | calling user, allowing subsequent access from user programs without |
| 224 | requiring root/sudo. |
| 225 | |
| 226 | .TP |
| 227 | .B unexport |
| 228 | Un-Export a GPIO pin in the /sys/class/gpio directory. |
| 229 | |
| 230 | .TP |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 231 | .B wfi <pin> <mode> |
| 232 | This set the given pin to the supplied interrupt mode: rising, falling |
| 233 | or both then waits for the interrupt to happen. It's a non-busy wait, |
| 234 | so does not consume and CPU while it's waiting. |
| 235 | |
| 236 | .TP |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 237 | .B drive |
| 238 | group value |
| 239 | |
| 240 | Change the pad driver value for the given pad group to the supplied drive |
| 241 | value. Group is 0, 1 or 2 and value is 0-7. Do not use unless you are |
| 242 | absolutely sure you know what you're doing. |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 243 | |
| 244 | .TP |
Gordon Henderson | df45388 | 2014-07-17 22:23:57 +0100 | [diff] [blame] | 245 | .B usbp |
| 246 | high | low |
| 247 | |
| 248 | Change the USB current limiter to high (1.2 amps) or low (the default, 600mA) |
Gordon Henderson | 70fa99a | 2017-02-27 19:51:32 +0000 | [diff] [blame] | 249 | This is only applicable to the Model B+ and the Model B, v2. |
Gordon Henderson | df45388 | 2014-07-17 22:23:57 +0100 | [diff] [blame] | 250 | |
| 251 | .TP |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 252 | .B pwm-bal/pwm-ms |
| 253 | Change the PWM mode to balanced (the default) or mark:space ratio (traditional) |
| 254 | |
| 255 | .TP |
| 256 | .B pwmr |
| 257 | Change the PWM range register. The default is 1024. |
| 258 | |
| 259 | .TP |
Gordon Henderson | e8f6258 | 2013-01-28 13:00:47 +0000 | [diff] [blame] | 260 | .B load i2c [baudrate] |
| 261 | This loads the i2c or drivers into the kernel and changes the permissions |
| 262 | on the associated /dev/ entries so that the current user has access to |
Gordon Henderson | 348bc73 | 2013-05-25 13:02:02 +0100 | [diff] [blame] | 263 | them. Optionally it will set the I2C baudrate to that supplied in Kb/sec |
| 264 | (or as close as the Pi can manage) The default speed is 100Kb/sec. |
Gordon Henderson | e8f6258 | 2013-01-28 13:00:47 +0000 | [diff] [blame] | 265 | |
Gordon Henderson | f6c40cb | 2015-09-24 22:35:31 +0100 | [diff] [blame] | 266 | Note: On recent kernels with the device tree enabled you should use the |
| 267 | raspi-config program to load/unload the I2C device at boot time. |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 268 | |
Gordon Henderson | e8f6258 | 2013-01-28 13:00:47 +0000 | [diff] [blame] | 269 | .TP |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 270 | .B load spi |
Gordon Henderson | 98bcb20 | 2013-02-07 21:53:49 +0000 | [diff] [blame] | 271 | This loads the spi drivers into the kernel and changes the permissions |
Gordon Henderson | e8f6258 | 2013-01-28 13:00:47 +0000 | [diff] [blame] | 272 | on the associated /dev/ entries so that the current user has access to |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 273 | them. It used to have the ability to change the buffer size from the |
Gordon Henderson | d795066 | 2015-09-30 16:11:42 +0100 | [diff] [blame] | 274 | default of 4096 bytes to an arbitrary value, however for some time the |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 275 | Pi Foundation have compiled the SPI device driver into the kernel and |
| 276 | this has fixed the buffer size. The way to change it now is to edit |
| 277 | the /boot/cmdline.txt file and add on spdev.bufsiz=8192 to set it to |
| 278 | e.g. 8192 bytes then reboot. |
| 279 | |
Gordon Henderson | f6c40cb | 2015-09-24 22:35:31 +0100 | [diff] [blame] | 280 | Note: On recent kernels with the device tree enabled you should use the |
| 281 | raspi-config program to load/unload the SPI device at boot time. |
Gordon Henderson | f99ffed | 2012-08-19 15:12:45 +0100 | [diff] [blame] | 282 | |
Gordon Henderson | 99095e3 | 2012-08-27 20:56:14 +0100 | [diff] [blame] | 283 | .TP |
| 284 | .B gbr |
| 285 | channel |
| 286 | |
Gordon Henderson | 86a5c68 | 2012-10-02 14:32:12 +0100 | [diff] [blame] | 287 | This reads the analog to digital converter on the Gertboard on the given |
Gordon Henderson | 99095e3 | 2012-08-27 20:56:14 +0100 | [diff] [blame] | 288 | channel. The board jumpers need to be in-place to do this operation. |
| 289 | |
| 290 | .TP |
| 291 | .B gbw |
| 292 | channel value |
| 293 | |
| 294 | This writes the supplied value to the output channel on the Gertboards |
Gordon Henderson | 86a5c68 | 2012-10-02 14:32:12 +0100 | [diff] [blame] | 295 | SPI digital to analogue converter. |
Gordon Henderson | 99095e3 | 2012-08-27 20:56:14 +0100 | [diff] [blame] | 296 | The board jumpers need to be in-place to do this operation. |
| 297 | |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 298 | |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 299 | .SH "WiringPi vs. BCM_GPIO Pin numbering vs. Physical pin numbering" |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 300 | |
| 301 | .PP |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 302 | The quickest way to get a list of the pin differences is to run the command |
| 303 | .TP |
| 304 | gpio readall |
Gordon Henderson | 13bbba7 | 2013-01-14 11:31:56 +0000 | [diff] [blame] | 305 | |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 306 | .SH FILES |
| 307 | |
| 308 | .TP 2.2i |
| 309 | .I gpio |
| 310 | executable |
| 311 | |
| 312 | .SH EXAMPLES |
| 313 | .TP 2.2i |
| 314 | gpio mode 4 output # Set pin 4 to output |
| 315 | .PP |
| 316 | gpio -g mode 23 output # Set GPIO pin 23 to output (same as WiringPi pin 4) |
| 317 | .PP |
| 318 | gpio mode 1 pwm # Set pin 1 to PWM mode |
| 319 | .PP |
| 320 | gpio pwm 1 512 # Set pin 1 to PWM value 512 - half brightness |
| 321 | .PP |
| 322 | gpio export 17 out # Set GPIO Pin 17 to output |
| 323 | .PP |
| 324 | gpio export 0 in # Set GPIO Pin 0 (SDA0) to input. |
| 325 | .PP |
| 326 | gpio -g read 0 # Read GPIO Pin 0 (SDA0) |
| 327 | |
| 328 | .SH "NOTES" |
| 329 | |
| 330 | When using the \fIexport\fR, \fIedge\fR or \fIunexport\fR commands, the |
| 331 | pin numbers are \fBalways\fR native BCM_GPIO numbers and never wiringPi |
| 332 | pin numbers. |
| 333 | |
Gordon Henderson | d795066 | 2015-09-30 16:11:42 +0100 | [diff] [blame] | 334 | As of kernels 4.1.7, a user-level GPIO access mechanism is available, |
| 335 | however wiringPi will not use this by default - because at this time |
| 336 | there appears to be issues when trying to program the PWM or clock output |
| 337 | hardware. If you can live without PWM or GPIO clocks and you want to use |
| 338 | the GPIO from a non-root program, then you need to make sure that the |
| 339 | module \fIbcm2835_gpiomem\fR is loaded at boot time. This should happen |
| 340 | automatically when you enable the device tree in raspi-config. You may |
| 341 | also need some additional information in /etc/udev/rules.d/ to change the |
| 342 | mode and ownership of the /dev/gpiomem file. Finally, you need to set |
| 343 | the environment variable \fIWIRINGPI_GPIOMEM\fR. This will go-away |
| 344 | in future releases once the /dev/gpiomem interface is fully operational. |
| 345 | |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 346 | .SH "SEE ALSO" |
| 347 | |
| 348 | .LP |
| 349 | WiringPi's home page |
| 350 | .IP |
Gordon Henderson | da38443 | 2013-05-13 19:43:26 +0100 | [diff] [blame] | 351 | http://wiringpi.com/ |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 352 | |
| 353 | .SH AUTHOR |
| 354 | |
| 355 | Gordon Henderson |
| 356 | |
| 357 | .SH "REPORTING BUGS" |
| 358 | |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 359 | Please report bugs to <projects@drogon.net> |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 360 | |
| 361 | .SH COPYRIGHT |
| 362 | |
Gordon Henderson | eb1fc2c | 2015-01-30 18:14:49 +0000 | [diff] [blame] | 363 | Copyright (c) 2012-2015 Gordon Henderson |
Gordon Henderson | bf0ad86 | 2012-08-16 15:04:43 +0100 | [diff] [blame] | 364 | This is free software; see the source for copying conditions. There is NO |
| 365 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
Gordon Henderson | 183c5a6 | 2012-10-21 15:25:16 +0100 | [diff] [blame] | 366 | |
| 367 | .SH TRADEMARKS AND ACKNOWLEDGEMENTS |
| 368 | |
Gordon Henderson | e8f6258 | 2013-01-28 13:00:47 +0000 | [diff] [blame] | 369 | Raspberry Pi is a trademark of the Raspberry Pi Foundation. See |
| 370 | http://raspberrypi.org/ for full details. |