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.
 
 
 
 
 

330 líneas
8.2 KiB

  1. .TH "GPIO" "March 2013" "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/clock ...
  11. .PP
  12. .B gpio
  13. .B [ \-x extension:params ]
  14. .B mode/read/write/aread/awrite/pwm ...
  15. .PP
  16. .B gpio
  17. .B [ \-p ]
  18. .B read/write/wb
  19. .B ...
  20. .PP
  21. .B gpio
  22. .B readall/reset
  23. .PP
  24. .B gpio
  25. .B unexportall/exports
  26. .PP
  27. .B gpio
  28. .B export/edge/unexport
  29. .B ...
  30. .PP
  31. .B gpio
  32. .B wfi
  33. .B ...
  34. .PP
  35. .B gpio
  36. .B drive
  37. group value
  38. .PP
  39. .B gpio
  40. .B pwm-bal/pwm-ms
  41. .PP
  42. .B gpio
  43. .B pwmr
  44. range
  45. .PP
  46. .B gpio
  47. .B load \ i2c/spi ...
  48. .PP
  49. .B gpio
  50. .B gbr
  51. channel
  52. .PP
  53. .B gpio
  54. .B gbw
  55. channel value
  56. .SH DESCRIPTION
  57. .B GPIO
  58. is a swiss army knife of a command line tool to allow the user easy
  59. access to the GPIO pins on the Raspberry Pi and the SPI A/D and D/A
  60. converters on the Gertboard. It's designed for simple testing and
  61. diagnostic purposes, but can be used in shell scripts for general if
  62. somewhat slow control of the GPIO pins.
  63. It can also control the IO's on the PiFace IO board and load the SPI and I2C
  64. kernel modules if required.
  65. Additionally, it can be used to set the exports in the \fI/sys/class/gpio\fR
  66. system directory to allow subsequent programs to use the \fR/sys/class/gpio\fR
  67. interface without needing to be run as root.
  68. .SH OPTIONS
  69. .TP
  70. .B \-v
  71. Output the current version including the board revision of the Raspberry Pi.
  72. .TP
  73. .B \-g
  74. Use the BCM_GPIO pins numbers rather than wiringPi pin numbers.
  75. \fINote:\fR The BCM_GPIO pin numbers are always used with the
  76. export and edge commands.
  77. .TP
  78. .B \-1
  79. Use the physical pin numbers rather than wiringPi pin numbers.
  80. \fINote:\fR that this applies to the P1 connector only. It is not possible to
  81. use pins on the Revision 2 P5 connector this way, and as with \-g the
  82. BCM_GPIO pin numbers are always used with the export and edge commands.
  83. .TP
  84. .B \-x extension
  85. This causes the named extension to be initialised. Extensions
  86. comprise of a name (e.g. mcp23017) followed by a colon, then the
  87. pin-base, then more optional parameters depending on the extension type.
  88. See the web page on http://wiringpi.com/the-gpio-utility/
  89. .TP
  90. .B \-p
  91. Use the PiFace interface board and its corresponding pin numbers. The PiFace
  92. will always appear at pin number 200 in the gpio command. You can assign any
  93. pin numbers you like in your own programs though.
  94. .TP
  95. .B read <pin>
  96. Read the digital value of the given pin and print 0 or 1 to represent the
  97. respective logic levels.
  98. .TP
  99. .B write <pin> <value>
  100. Write the given value (0 or 1) to the pin. You need to set the pin
  101. to output mode first.
  102. .TP
  103. .B wb <value>
  104. Write the given byte to the 8 main GPIO pins. You can prefix it with 0x
  105. to specify a hexadecimal number. You need to set pins to output mode
  106. first.
  107. .TP
  108. .B readall
  109. Output a table of all GPIO pins values. The values represent the actual values read
  110. if the pin is in input mode, or the last value written if the pin is in output
  111. mode.
  112. .TP
  113. .B reset
  114. Resets the GPIO - As much as it's possible to do. All pins are set to input
  115. mode and all the internal pull-up/down resistors are disconnected (tristate mode).
  116. .TP
  117. .B pwm <pin> <value>
  118. Write a PWM value (0-1023) to the given pin. The pin needs to be put
  119. into PWM mode first.
  120. .TP
  121. .B clock <pin> <frequency>
  122. Set the output frequency on the given pin. The pin needs to be put into
  123. clock mode first.
  124. .TP
  125. .B mode <pin> <mode>
  126. Set a pin into \fIinput\fR, \fIoutput\fR or \fIpwm\fR mode. Can also
  127. use the literals \fIup\fR, \fIdown\fR or \fItri\fR to set the internal
  128. pull-up, pull-down or tristate (off) controls.
  129. .TP
  130. .B unexportall
  131. Un-Export all the GPIO pins in the /sys/class/gpio directory.
  132. .TP
  133. .B exports
  134. Print a list (if any) of all the exported GPIO pins and their current values.
  135. .TP
  136. .B export
  137. Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the
  138. mode command above however only \fIin\fR and \fIout\fR are supported at
  139. this time. Note that the pin number is the \fBBCM_GPIO\fR number and
  140. not the wiringPi number.
  141. Once a GPIO pin has been exported, the \fBgpio\fR program changes the
  142. ownership of the \fI/sys/class/gpio/gpioX/value\fR and if present in
  143. later kernels, the \fI/sys/class/gpio/gpioX/edge\fR pseudo files to
  144. that of the user running the \fBgpio\fR program. This means that you
  145. can have a small script of gpio exports to setup the gpio pins as your
  146. program requires without the need to run anything as root, or with the
  147. sudo command.
  148. .TP
  149. .B edge
  150. This exports a GPIO pin in the \fI/sys/class/gpio\fR directory, set
  151. the direction to input and set the edge interrupt method to \fInone\fR,
  152. \fIrising\fR, \fIfalling\fR or \fIboth\fR. Use like the export command
  153. above and note that \fBBCM_GPIO\fR pin number is used not not wiringPi pin
  154. numbering.
  155. Like the export commands above, ownership is set to that of the
  156. calling user, allowing subsequent access from user programs without
  157. requiring root/sudo.
  158. .TP
  159. .B unexport
  160. Un-Export a GPIO pin in the /sys/class/gpio directory.
  161. .TP
  162. .B wfi <pin> <mode>
  163. This set the given pin to the supplied interrupt mode: rising, falling
  164. or both then waits for the interrupt to happen. It's a non-busy wait,
  165. so does not consume and CPU while it's waiting.
  166. .TP
  167. .B drive
  168. group value
  169. Change the pad driver value for the given pad group to the supplied drive
  170. value. Group is 0, 1 or 2 and value is 0-7. Do not use unless you are
  171. absolutely sure you know what you're doing.
  172. .TP
  173. .B pwm-bal/pwm-ms
  174. Change the PWM mode to balanced (the default) or mark:space ratio (traditional)
  175. .TP
  176. .B pwmr
  177. Change the PWM range register. The default is 1024.
  178. .TP
  179. .B load i2c [baudrate]
  180. This loads the i2c or drivers into the kernel and changes the permissions
  181. on the associated /dev/ entries so that the current user has access to
  182. them. Optionally it will set the I2C baudrate to that supplied (or as
  183. close as the Pi can manage) The default speed is 100Kb/sec.
  184. .TP
  185. .B load spi [buffer size in KB]
  186. This loads the spi drivers into the kernel and changes the permissions
  187. on the associated /dev/ entries so that the current user has access to
  188. them. Optionally it will set the SPI buffer size to that supplied. The
  189. default is 4KB.
  190. .TP
  191. .B gbr
  192. channel
  193. This reads the analog to digital converter on the Gertboard on the given
  194. channel. The board jumpers need to be in-place to do this operation.
  195. .TP
  196. .B gbw
  197. channel value
  198. This writes the supplied value to the output channel on the Gertboards
  199. SPI digital to analogue converter.
  200. The board jumpers need to be in-place to do this operation.
  201. .SH "WiringPi vs. BCM_GPIO Pin numbering"
  202. .PP
  203. .TS
  204. c c c c l.
  205. WiringPi GPIO-r1 GPIO-r2 P1-Phys Function
  206. _
  207. 0 17 17 11
  208. 1 18 18 12 (PWM)
  209. 2 21 27 13
  210. 3 22 22 15
  211. 4 23 23 16
  212. 5 24 24 18
  213. 6 25 25 22
  214. 7 4 4 7
  215. 8 0 2 3 I2C: SDA0
  216. 9 1 3 5 I2C: SCL0
  217. 10 8 8 24 SPI: CE0
  218. 11 7 7 26 SPI: CE1
  219. 12 10 10 19 SPI: MOSI
  220. 13 9 9 21 SPI: MISO
  221. 14 11 11 23 SPI: SCLK
  222. 15 14 14 8 TxD
  223. 16 15 16 10 RxD
  224. 17 - 28
  225. 18 - 29
  226. 19 - 30
  227. 20 - 31
  228. .TE
  229. Note that "r1" and "r2" above refers to the board revision. Normally
  230. wiringPi detects the correct board revision with use for it's own
  231. numbering scheme, but if you are using a Revision 2 board with some
  232. of the pins which change numbers between revisions you will need
  233. to alter your software.
  234. .SH FILES
  235. .TP 2.2i
  236. .I gpio
  237. executable
  238. .SH EXAMPLES
  239. .TP 2.2i
  240. gpio mode 4 output # Set pin 4 to output
  241. .PP
  242. gpio -g mode 23 output # Set GPIO pin 23 to output (same as WiringPi pin 4)
  243. .PP
  244. gpio mode 1 pwm # Set pin 1 to PWM mode
  245. .PP
  246. gpio pwm 1 512 # Set pin 1 to PWM value 512 - half brightness
  247. .PP
  248. gpio export 17 out # Set GPIO Pin 17 to output
  249. .PP
  250. gpio export 0 in # Set GPIO Pin 0 (SDA0) to input.
  251. .PP
  252. gpio -g read 0 # Read GPIO Pin 0 (SDA0)
  253. .SH "NOTES"
  254. When using the \fIexport\fR, \fIedge\fR or \fIunexport\fR commands, the
  255. pin numbers are \fBalways\fR native BCM_GPIO numbers and never wiringPi
  256. pin numbers.
  257. .SH "SEE ALSO"
  258. .LP
  259. WiringPi's home page
  260. .IP
  261. http://wiringpi.com/
  262. .SH AUTHOR
  263. Gordon Henderson
  264. .SH "REPORTING BUGS"
  265. Please report bugs to <projects@drogon.net>
  266. .SH COPYRIGHT
  267. Copyright (c) 2012-2013 Gordon Henderson
  268. This is free software; see the source for copying conditions. There is NO
  269. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  270. .SH TRADEMARKS AND ACKNOWLEDGEMENTS
  271. Raspberry Pi is a trademark of the Raspberry Pi Foundation. See
  272. http://raspberrypi.org/ for full details.