No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

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