Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

295 rindas
6.9 KiB

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