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.

12 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. .TH "GPIO" "14 June 2012" "Command-Line access to Raspberry Pi GPIO"
  2. .SH NAME
  3. gpio \- Command-line access to Raspberry Pi GPIO
  4. .SH SYNOPSIS
  5. .B gpio
  6. .RB [ \-g ]
  7. .RB < read/write/pwm/mode ...>
  8. .TP
  9. .B gpio
  10. .RB < export/unexport/exports ...>
  11. .SH DESCRIPTION
  12. .B GPIO
  13. is a command line tool to allow the user easy access to the GPIO pins
  14. on the Raspberry Pi. It's designed for simple testing and diagnostic
  15. purposes, but can be used in shell scripts for general if somewhat slow
  16. control of the GPIO pins.
  17. Additionally, it can be used to set the exports in the /sys/class/gpio
  18. system directory to allow subsequent programs to use the /sys/class/gpio
  19. interface without needing to be run as root.
  20. .SH OPTIONS
  21. .TP
  22. .B \-g
  23. Use the BCM_GPIO pins numbers rather than WiringPi pin numbers.
  24. .TP
  25. .B read
  26. Read the digital value of the given pin and print 0 or 1 to represent the
  27. respective logic levels.
  28. .TP
  29. .B write
  30. Write the given value (0 or 1) to the pin.
  31. .TP
  32. .B pwm
  33. Write a PWM value (0-1023) to the given pin.
  34. .TP
  35. .B mode
  36. Set a pin into input, output or pwm mode. Can also use the literals up, down or tri
  37. to set the internal pull-up, pull-down or tristate controls.
  38. .TP
  39. .B export
  40. Export a GPIO pin in the /sys/class/gpio directory. Use like the mode command above
  41. however only in and out are supported at this time.
  42. Once a GPIO pin has been exported, the
  43. .B gpio
  44. program changes the ownership of the /sys/class/gpio/gpioX/value pseudo file to
  45. that of the user running the
  46. .B gpio
  47. program. This means that you can have a small script of gpio exports to setup
  48. the gpio pins as your program requires without the need to run anything as
  49. root, or with the sudo command.
  50. .TP
  51. .B unexport
  52. Un-Export a GPIO pin in the /sys/class/gpio directory.
  53. .TP
  54. .B exports
  55. Print a list (if any) of all the exported GPIO pins and their current values.
  56. .SH "WiringPi vs. GPIO Pin numbering"
  57. .PP
  58. .TS
  59. r r l.
  60. WiringPi GPIO Function
  61. _
  62. 0 17
  63. 1 18 (PWM)
  64. 2 21
  65. 3 22
  66. 4 23
  67. 5 24
  68. 6 25
  69. 7 4
  70. 8 0 SDA0
  71. 9 1 SCL0
  72. 10 8 SPI CE0
  73. 11 7 SPI CE1
  74. 12 10 SPI MOSI
  75. 13 9 SPI MISO
  76. 14 11 SPI SCLK
  77. 15 14 TxD
  78. 16 15 RxD
  79. .TE
  80. .SH FILES
  81. .TP 2.2i
  82. .I gpio
  83. executable
  84. .SH EXAMPLES
  85. .TP 2.2i
  86. gpio mode 4 output # Set pin 4 to output
  87. .PP
  88. gpio -g mode 23 output # Set GPIO pin 23 to output (same as WiringPi pin 4)
  89. .PP
  90. gpio mode 1 pwm # Set pin 1 to PWM mode
  91. .PP
  92. gpio pwm 1 512 # Set pin 1 to PWM value 512 - half brightness
  93. .PP
  94. gpio export 17 out # Set GPIO Pin 17 to output
  95. .PP
  96. gpio export 0 in # Set GPIO Pin 0 (SDA0) to input.
  97. .PP
  98. gpio -g read 0 # Read GPIO Pin 0 (SDA0)
  99. .SH "NOTES"
  100. When using the export or unexport commands, the pin numbers are
  101. .B always
  102. native GPIO numbers and never wiringPi pin numbers.
  103. .SH "SEE ALSO"
  104. .LP
  105. WiringPi's home page
  106. .IP
  107. https://projects.drogon.net/raspberry-pi/wiringpi/
  108. .SH AUTHOR
  109. Gordon Henderson
  110. .SH "REPORTING BUGS"
  111. Report bugs to <gordon@drogon.net>
  112. .SH COPYRIGHT
  113. Copyright (c) 2012 Gordon Henderson
  114. This is free software; see the source for copying conditions. There is NO
  115. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.