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.

преди 8 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 8 години
преди 8 години
преди 11 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 11 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 11 години
преди 12 години
преди 8 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 11 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 8 години
преди 11 години
преди 8 години
преди 11 години
преди 8 години
преди 11 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 8 години
преди 11 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 12 години
преди 8 години
преди 12 години
преди 12 години
преди 11 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. .TH GPIO 1 "September 2015" 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/clock ...
  11. .PP
  12. .B gpio
  13. .B [ \-x extension:params ]
  14. .B mode/read/write/aread/awrite/pwm/pwmTone ...
  15. .PP
  16. .B gpio
  17. .B [ \-p ]
  18. .B read/write/toggle/wb
  19. .B ...
  20. .PP
  21. .B gpio
  22. .B readall
  23. .PP
  24. .B gpio
  25. .B unexportall/exports
  26. .PP
  27. .B gpio
  28. .B export/edge/unexport
  29. .B ...
  30. .PP
  31. .B gpio
  32. .B wfi
  33. .B ...
  34. .PP
  35. .B gpio
  36. .B drive
  37. group value
  38. .PP
  39. .B gpio
  40. .B usbp
  41. high | low
  42. .PP
  43. .B gpio
  44. .B pwm-bal/pwm-ms
  45. .PP
  46. .B gpio
  47. .B pwmr
  48. range
  49. .PP
  50. .B gpio
  51. .B load \ i2c/spi ...
  52. .PP
  53. .B gpio
  54. .B gbr
  55. channel
  56. .PP
  57. .B gpio
  58. .B gbw
  59. channel value
  60. .SH DESCRIPTION
  61. .B GPIO
  62. is a swiss army knife of a command line tool to allow the user easy
  63. access to the GPIO pins on the Raspberry Pi and the SPI A/D and D/A
  64. converters on the Gertboard. It's designed for simple testing and
  65. diagnostic purposes, but can be used in shell scripts for general if
  66. somewhat slow control of the GPIO pins.
  67. It can also control the IO's on the PiFace IO board and load the SPI and I2C
  68. kernel modules if required.
  69. Additionally, it can be used to set the exports in the \fI/sys/class/gpio\fR
  70. system directory to allow subsequent programs to use the \fR/sys/class/gpio\fR
  71. interface without needing to be run as root.
  72. .SH OPTIONS
  73. .TP
  74. .B \-v
  75. Output the current version including the board revision of the Raspberry Pi.
  76. .TP
  77. .B \-g
  78. Use the BCM_GPIO pins numbers rather than wiringPi pin numbers.
  79. \fINote:\fR The BCM_GPIO pin numbers are always used with the
  80. export and edge commands.
  81. .TP
  82. .B \-1
  83. Use the physical pin numbers rather than wiringPi pin numbers.
  84. \fINote:\fR that this applies to the P1 connector only. It is not possible to
  85. use pins on the Revision 2 P5 connector this way, and as with \-g the
  86. BCM_GPIO pin numbers are always used with the export and edge commands.
  87. .TP
  88. .B \-x extension
  89. This causes the named extension to be initialised. Extensions
  90. comprise of a name (e.g. mcp23017) followed by a colon, then the
  91. pin-base, then more optional parameters depending on the extension type.
  92. See the web page on http://wiringpi.com/the-gpio-utility/
  93. .TP
  94. .B \-p
  95. Use the PiFace interface board and its corresponding pin numbers. The PiFace
  96. will always appear at pin number 200 in the gpio command. You can assign any
  97. pin numbers you like in your own programs though.
  98. .TP
  99. .B read <pin>
  100. Read the digital value of the given pin and print 0 or 1 to represent the
  101. respective logic levels.
  102. .TP
  103. .B write <pin> <value>
  104. Write the given value (0 or 1) to the pin. You need to set the pin
  105. to output mode first.
  106. .TP
  107. .B aread <pin>
  108. Read the analog value of the given pin. This needs to be uses in
  109. conjunction with a -x flag to add in an extension that handles analog
  110. inputs. respective logic levels.
  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. respective logic levels.
  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 unexportall
  150. Un-Export all the GPIO pins in the /sys/class/gpio directory.
  151. .TP
  152. .B exports
  153. Print a list (if any) of all the exported GPIO pins and their current values.
  154. .TP
  155. .B export
  156. Export a GPIO pin in the \fI/sys/class/gpio\fR directory. Use like the
  157. mode command above however only \fIin\fR, \fIout\fR, \fIhigh\fR and
  158. \fRlow\fR are supported at this time. Note that the pin number is the
  159. \fBBCM_GPIO\fR number and not the wiringPi number. The \fIhigh\fR and
  160. \fIlow\fR commands pre-set the output value at the same time as the
  161. export to output mode.
  162. Once a GPIO pin has been exported, the \fBgpio\fR program changes the
  163. ownership of the \fI/sys/class/gpio/gpioX/value\fR and if present in
  164. later kernels, the \fI/sys/class/gpio/gpioX/edge\fR pseudo files to
  165. that of the user running the \fBgpio\fR program. This means that you
  166. can have a small script of gpio exports to setup the gpio pins as your
  167. program requires without the need to run anything as root, or with the
  168. sudo command.
  169. .TP
  170. .B edge
  171. This exports a GPIO pin in the \fI/sys/class/gpio\fR directory, set
  172. the direction to input and set the edge interrupt method to \fInone\fR,
  173. \fIrising\fR, \fIfalling\fR or \fIboth\fR. Use like the export command
  174. above and note that \fBBCM_GPIO\fR pin number is used not not wiringPi pin
  175. numbering.
  176. Like the export commands above, ownership is set to that of the
  177. calling user, allowing subsequent access from user programs without
  178. requiring root/sudo.
  179. .TP
  180. .B unexport
  181. Un-Export a GPIO pin in the /sys/class/gpio directory.
  182. .TP
  183. .B wfi <pin> <mode>
  184. This set the given pin to the supplied interrupt mode: rising, falling
  185. or both then waits for the interrupt to happen. It's a non-busy wait,
  186. so does not consume and CPU while it's waiting.
  187. .TP
  188. .B drive
  189. group value
  190. Change the pad driver value for the given pad group to the supplied drive
  191. value. Group is 0, 1 or 2 and value is 0-7. Do not use unless you are
  192. absolutely sure you know what you're doing.
  193. .TP
  194. .B usbp
  195. high | low
  196. Change the USB current limiter to high (1.2 amps) or low (the default, 600mA)
  197. This is only applicable to the model B+
  198. .TP
  199. .B pwm-bal/pwm-ms
  200. Change the PWM mode to balanced (the default) or mark:space ratio (traditional)
  201. .TP
  202. .B pwmr
  203. Change the PWM range register. The default is 1024.
  204. .TP
  205. .B load i2c [baudrate]
  206. This loads the i2c or drivers into the kernel and changes the permissions
  207. on the associated /dev/ entries so that the current user has access to
  208. them. Optionally it will set the I2C baudrate to that supplied in Kb/sec
  209. (or as close as the Pi can manage) The default speed is 100Kb/sec.
  210. Note: On recent kernels with the device tree enabled you should use the
  211. raspi-config program to load/unload the I2C device at boot time.
  212. (or disable the device tree to continue to use this method)
  213. .TP
  214. .B load spi
  215. This loads the spi drivers into the kernel and changes the permissions
  216. on the associated /dev/ entries so that the current user has access to
  217. them. It used to have the ability to change the buffer size from the
  218. default of 4096 bytes to an arbitrary value, however for some time the
  219. Pi Foundation have compiled the SPI device driver into the kernel and
  220. this has fixed the buffer size. The way to change it now is to edit
  221. the /boot/cmdline.txt file and add on spdev.bufsiz=8192 to set it to
  222. e.g. 8192 bytes then reboot.
  223. Note: On recent kernels with the device tree enabled you should use the
  224. raspi-config program to load/unload the SPI device at boot time.
  225. (or disable the device tree to continue to use this method)
  226. .TP
  227. .B gbr
  228. channel
  229. This reads the analog to digital converter on the Gertboard on the given
  230. channel. The board jumpers need to be in-place to do this operation.
  231. .TP
  232. .B gbw
  233. channel value
  234. This writes the supplied value to the output channel on the Gertboards
  235. SPI digital to analogue converter.
  236. The board jumpers need to be in-place to do this operation.
  237. .SH "WiringPi vs. BCM_GPIO Pin numbering vs. Physical pin numbering"
  238. .PP
  239. The quickest way to get a list of the pin differences is to run the command
  240. .TP
  241. gpio readall
  242. .SH FILES
  243. .TP 2.2i
  244. .I gpio
  245. executable
  246. .SH EXAMPLES
  247. .TP 2.2i
  248. gpio mode 4 output # Set pin 4 to output
  249. .PP
  250. gpio -g mode 23 output # Set GPIO pin 23 to output (same as WiringPi pin 4)
  251. .PP
  252. gpio mode 1 pwm # Set pin 1 to PWM mode
  253. .PP
  254. gpio pwm 1 512 # Set pin 1 to PWM value 512 - half brightness
  255. .PP
  256. gpio export 17 out # Set GPIO Pin 17 to output
  257. .PP
  258. gpio export 0 in # Set GPIO Pin 0 (SDA0) to input.
  259. .PP
  260. gpio -g read 0 # Read GPIO Pin 0 (SDA0)
  261. .SH "NOTES"
  262. When using the \fIexport\fR, \fIedge\fR or \fIunexport\fR commands, the
  263. pin numbers are \fBalways\fR native BCM_GPIO numbers and never wiringPi
  264. pin numbers.
  265. As of kernels 4.1.7, a user-level GPIO access mechanism is available,
  266. however wiringPi will not use this by default - because at this time
  267. there appears to be issues when trying to program the PWM or clock output
  268. hardware. If you can live without PWM or GPIO clocks and you want to use
  269. the GPIO from a non-root program, then you need to make sure that the
  270. module \fIbcm2835_gpiomem\fR is loaded at boot time. This should happen
  271. automatically when you enable the device tree in raspi-config. You may
  272. also need some additional information in /etc/udev/rules.d/ to change the
  273. mode and ownership of the /dev/gpiomem file. Finally, you need to set
  274. the environment variable \fIWIRINGPI_GPIOMEM\fR. This will go-away
  275. in future releases once the /dev/gpiomem interface is fully operational.
  276. .SH "SEE ALSO"
  277. .LP
  278. WiringPi's home page
  279. .IP
  280. http://wiringpi.com/
  281. .SH AUTHOR
  282. Gordon Henderson
  283. .SH "REPORTING BUGS"
  284. Please report bugs to <projects@drogon.net>
  285. .SH COPYRIGHT
  286. Copyright (c) 2012-2015 Gordon Henderson
  287. This is free software; see the source for copying conditions. There is NO
  288. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  289. .SH TRADEMARKS AND ACKNOWLEDGEMENTS
  290. Raspberry Pi is a trademark of the Raspberry Pi Foundation. See
  291. http://raspberrypi.org/ for full details.