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.
 
 
 
 
 

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