Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

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