Raspberry GPIO


wiringpi

    http://wiringpi.com/download-and-install/

git clone git://git.drogon.net/wiringPi
pi@raspberrypi:/sys/class/gpio$ gpio -v
gpio version: 2.44
Copyright (c) 2012-2017 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Pi 3, Revision: 02, Memory: 1024MB, Maker: Sony 
  * Device tree is enabled.
  *--> Raspberry Pi 3 Model B Rev 1.2
  * This Raspberry Pi supports user-level GPIO access.
pi@raspberrypi:/sys/class/gpio$ gpio readall
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 0 | IN   | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | IN   | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+

man gpio

GPIO(1)                            Command-Line access to Raspberry Pi's GPIO                            GPIO(1)

NAME
       gpio - Command-line access to Raspberry Pi's GPIO

SYNOPSIS
       gpio -v

       gpio [ -g | -1 ] mode/read/write/aread/awrite/wb/pwm/clock/toggle/blink ...

       gpio [ -x extension:params ] mode/read/write/aread/awrite/pwm/toggle/blink ...

       gpio [ -p ] read/write/toggle/blink ...

       gpio readall

       gpio unexportall/exports

       gpio export/edge/unexport ...

       gpio wfi ...

       gpio drive group value

       gpio usbp high | low

       gpio pwm-bal/pwm-ms

       gpio pwmr range

       gpio load  i2c/spi ...

       gpio gbr channel

       gpio gbw channel value

DESCRIPTION
       GPIO  is  a swiss army knife of a command line tool to allow the user easy access to the GPIO pins on the
       Raspberry Pi and the SPI A/D and D/A converters on the Gertboard. It's designed for  simple  testing  and
       diagnostic  purposes,  but  can be used in shell scripts for general if somewhat slow control of the GPIO
       pins.

       It can also control the IO's on the PiFace IO board and load the SPI and I2C kernel modules if required.

       Additionally, it can be used to set the exports in the /sys/class/gpio system directory to  allow  subseâ€
       quent programs to use the /sys/class/gpio interface without needing to be run as root.
EXAMPLES
       gpio mode 4 output # Set pin 4 to output

       gpio -g mode 23 output # Set GPIO pin 23 to output (same as WiringPi pin 4)

       gpio mode 1 pwm # Set pin 1 to PWM mode

       gpio pwm 1 512 # Set pin 1 to PWM value 512 - half brightness

       gpio export 17 out # Set GPIO Pin 17 to output

       gpio export 0 in # Set GPIO Pin 0 (SDA0) to input.

       gpio -g read 0 # Read GPIO Pin 0 (SDA0)


Reference:

  1. Compute_Module_IO_Board_Plus, http://www.waveshare.net/wiki/Compute_Module_IO_Board_Plus


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值