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.
 
 
 
 
 

294 rivejä
7.2 KiB

  1. .TH GPIO 1 "March 2018" wiringPi "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/pwnTone/clock/toggle/blink ...
  11. .PP
  12. .B gpio
  13. .B [ \-x extension:params ]
  14. .B mode/read/write/aread/awrite/pwm/toggle/blink ...
  15. .PP
  16. .B gpio
  17. .B [ \-p ]
  18. .B read/write/toggle/blink
  19. .B ...
  20. .PP
  21. .B gpio
  22. .B [ \-p ]
  23. .B pwnTone pin frequency
  24. .B ...
  25. .PP
  26. .B gpio
  27. .B readall
  28. .PP
  29. .B gpio
  30. .B wfi
  31. .B ...
  32. .PP
  33. .B gpio
  34. .B drive
  35. group value
  36. .PP
  37. .B gpio
  38. .B usbp
  39. high | low
  40. .PP
  41. .B gpio
  42. .B pwm-bal/pwm-ms
  43. .PP
  44. .B gpio
  45. .B pwmr
  46. range
  47. .PP
  48. .B gpio
  49. .B i2cd
  50. .PP
  51. .B gpio
  52. .B gbr
  53. channel
  54. .PP
  55. .B gpio
  56. .B gbw
  57. channel value
  58. .SH DESCRIPTION
  59. .B GPIO
  60. is a swiss army knife of a command line tool to allow the user easy
  61. access to the GPIO pins on the Raspberry Pi and the SPI A/D and D/A
  62. converters on the Gertboard. It's designed for simple testing and
  63. diagnostic purposes, but can be used in shell scripts for general if
  64. somewhat slow control of the GPIO pins.
  65. It can also control the IO's on the PiFace IO board.
  66. .SH OPTIONS
  67. .TP
  68. .B \-v
  69. Output the current version including the board revision of the Raspberry Pi.
  70. .TP
  71. .B \-g
  72. Use the BCM_GPIO pins numbers rather than wiringPi pin numbers.
  73. .\" \fINote:\fR The BCM_GPIO pin numbers are always used with character device ABI.
  74. .TP
  75. .B \-1
  76. Use the physical pin numbers rather than wiringPi pin numbers.
  77. \fINote:\fR that this applies to the P1 connector only. It is not possible to
  78. use pins on the Revision 2 P5 connector this way, and as with \-g the
  79. .\" BCM_GPIO pin numbers are always used with character device ABI.
  80. .TP
  81. .B \-x extension
  82. This causes the named extension to be initialised. Extensions
  83. comprise of a name (e.g. mcp23017) followed by a colon, then the
  84. pin-base, then more optional parameters depending on the extension type.
  85. .TP
  86. .B \-p
  87. Use the PiFace interface board and its corresponding pin numbers. The PiFace
  88. will always appear at pin number 200 in the gpio command. You can assign any
  89. pin numbers you like in your own programs though.
  90. .TP
  91. .B read <pin>
  92. Read the digital value of the given pin and print 0 or 1 to represent the
  93. respective logic levels.
  94. .TP
  95. .B write <pin> <value>
  96. Write the given value (0 or 1) to the pin. You need to set the pin
  97. to output mode first.
  98. .TP
  99. .B toggle <pin>
  100. Changes the state of a GPIO pin; 0 to 1, or 1 to 0.
  101. Note unlike the blink command, the pin must be in output mode first.
  102. .TP
  103. .B blink <pin>
  104. Blinks the given pin on/off. Press Control-C to exit.
  105. Note: This command explicitly sets the pin to output mode.
  106. .TP
  107. .B aread <pin>
  108. Read the analog value of the given pin. This needs to be used in
  109. conjunction with a -x flag to add in an extension that handles analog
  110. inputs.
  111. e.g. gpio -x mcp3002:200:0 aread 200
  112. will read the first analog input on an mcp3002 SPI ADC chip.
  113. .TP
  114. .B awrite <pin> <value>
  115. Write the analog value to the given pin. This needs to be used in
  116. conjunction with a -x flag to add in an extension that handles analog
  117. inputs.
  118. e.g. gpio -x mcp4802:200:0 awrite 200 128
  119. will write the value 128 to the first DAC port on an mcp4802 chip on
  120. the Pi's SPI bus 0.
  121. .TP
  122. .B wb <value>
  123. Write the given byte to the 8 main GPIO pins. You can prefix it with 0x
  124. to specify a hexadecimal number. You need to set pins to output mode
  125. first.
  126. .TP
  127. .B readall
  128. Output a table of all GPIO pins values. The values represent the actual values read
  129. if the pin is in input mode, or the last value written if the pin is in output
  130. mode.
  131. The readall command is usable with an extension module (via the -x parameter),
  132. but it's unable to determine pin modes or states, so will perform both a
  133. digital and analog read on each pin in-turn.
  134. .TP
  135. .B pwm <pin> <value>
  136. Write a PWM value (0-1023) to the given pin. The pin needs to be put
  137. into PWM mode first.
  138. .TP
  139. .B clock <pin> <frequency>
  140. Set the output frequency on the given pin. The pin needs to be put into
  141. clock mode first.
  142. .TP
  143. .B mode <pin> <mode>
  144. Set a pin into \fIinput\fR, \fIoutput\fR or \fIpwm\fR mode. Can also
  145. use the literals \fIup\fR, \fIdown\fR or \fItri\fR to set the internal
  146. pull-up, pull-down or tristate (off) controls.
  147. The ALT modes can also be set using \fIalt0\fR, \fIalt1\fR, ... \fIalt5\fR.
  148. .TP
  149. .B wfi <pin> <mode>
  150. This set the given pin to the supplied interrupt mode: rising, falling
  151. or both then waits for the interrupt to happen. It's a non-busy wait,
  152. so does not consume and CPU while it's waiting.
  153. .TP
  154. .B drive
  155. group value
  156. Change the pad driver value for the given pad group to the supplied drive
  157. value. Group is 0, 1 or 2 and value is 0-7. Do not use unless you are
  158. absolutely sure you know what you're doing.
  159. .TP
  160. .B usbp
  161. high | low
  162. Change the USB current limiter to high (1.2 amps) or low (the default, 600mA)
  163. This is only applicable to the Model B+ and the Model B, v2.
  164. .TP
  165. .B pwm-bal/pwm-ms
  166. Change the PWM mode to balanced (the default) or mark:space ratio (traditional)
  167. .TP
  168. .B pwmr
  169. Change the PWM range register. The default is 1024.
  170. .TP
  171. .B i2cd
  172. Executes i2c-detect for the default I2C port on the P1 connector.
  173. .TP
  174. .B gbr
  175. channel
  176. This reads the analog to digital converter on the Gertboard on the given
  177. channel. The board jumpers need to be in-place to do this operation.
  178. .TP
  179. .B gbw
  180. channel value
  181. This writes the supplied value to the output channel on the Gertboards
  182. SPI digital to analogue converter.
  183. The board jumpers need to be in-place to do this operation.
  184. .SH "WiringPi vs. BCM_GPIO Pin numbering vs. Physical pin numbering"
  185. .PP
  186. The quickest way to get a list of the pin differences is to run the command
  187. .TP
  188. gpio readall
  189. .SH FILES
  190. .TP 2.2i
  191. .I gpio
  192. executable
  193. .SH EXAMPLES
  194. .TP 2.2i
  195. gpio mode 4 output # Set pin 4 to output
  196. .PP
  197. gpio -g mode 23 output # Set GPIO pin 23 to output (same as WiringPi pin 4)
  198. .PP
  199. gpio mode 1 pwm # Set pin 1 to PWM mode
  200. .PP
  201. gpio pwm 1 512 # Set pin 1 to PWM value 512 - half brightness
  202. .PP
  203. gpio -g read 0 # Read GPIO Pin 0 (SDA0)
  204. .SH "NOTES"
  205. As of kernels 4.1.7, a user-level GPIO access mechanism is available,
  206. however wiringPi will not use this by default - because at this time
  207. there appears to be issues when trying to program the PWM or clock output
  208. hardware. If you can live without PWM or GPIO clocks and you want to use
  209. the GPIO from a non-root program, then you need to make sure that the
  210. module \fIbcm2835_gpiomem\fR is loaded at boot time. This should happen
  211. automatically when you enable the device tree in raspi-config. You may
  212. also need some additional information in /etc/udev/rules.d/ to change the
  213. mode and ownership of the /dev/gpiomem file. Finally, you need to set
  214. the environment variable \fIWIRINGPI_GPIOMEM\fR. This will go-away
  215. in future releases once the /dev/gpiomem interface is fully operational.
  216. .SH "SEE ALSO"
  217. .LP
  218. WiringPi's development
  219. .IP
  220. https://github.com/WiringPi/WiringPi/
  221. .SH AUTHOR
  222. Gordon Henderson and contributors
  223. .SH "REPORTING BUGS"
  224. Please report bugs to https://github.com/WiringPi/WiringPi/issues
  225. .SH COPYRIGHT
  226. Copyright (c) 2012-2024 Gordon Henderson and contributors
  227. .br
  228. This is free software; see the source for copying conditions. There is NO
  229. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  230. .SH TRADEMARKS AND ACKNOWLEDGEMENTS
  231. Raspberry Pi is a trademark of the Raspberry Pi Foundation. See
  232. http://raspberrypi.org/ for full details.