Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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