You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

244 line
5.1 KiB

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