树莓派GPIO

树莓派GPIO

before upgrade

pi@raspberrypi:~ gpio readall
Oops - unable to determine board type... model: 13
pi@raspberrypi:~ 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: Unknown13, Revision: 03, Memory: 1024MB, Maker: Sony 
  * Device tree is enabled.
  *--> Raspberry Pi 3 Model B Plus Rev 1.3
  * This Raspberry Pi supports user-level GPIO access.

修改镜像

pi@raspberrypi:~/install/WiringPi $ sudo vi  /etc/apt/sources.list

#deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

pi@raspberrypi:~/install/WiringPi $ sudo vi  /etc/apt/sources.list.d/raspi.list
#deb http://archive.raspberrypi.org/debian/ stretch main ui

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ stretch main ui


deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui

sudo apt-get update
sudo apt-get upgrade 

after upgrade

pi@raspberrypi:~/install/WiringPi gpio -v
gpio version: 2.50
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Pi 3B+, Revision: 03, Memory: 1024MB, Maker: Sony  * Device tree is enabled.
  *--> Raspberry Pi 3 Model B Plus Rev 1.3
  * This Raspberry Pi supports user-level GPIO access.
pi@raspberrypi:~/install/WiringPi gpio readall
 +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |  OUT | 0 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 |  OUT | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |  OUT | 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 |  OUT | 1 | 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 3B+-+---+------+---------+-----+-----+
pi@raspberrypi:~/install/WiringPi $ 
pi@raspberrypi:~ dpkg -l | grep wiringpi
ii  wiringpi                              2.44+1                               armhf        The wiringPi libraries, headers and gpio command
pi@raspberrypi:~ sudo apt-get upgrade wiringpi
pi@raspberrypi:~/install/WiringPi dpkg -l | grep wiringpi
ii  wiringpi                              2.50                                 armhf        The wiringPi libraries, headers and gpio command
pi@raspberrypi:~/install/WiringPi 

GPIO 引脚和T型扩展卡对应

image-20240421152636216

整理表格:

C_Name C_Pin T_Name C_Name C_Pin T_Name C_Name C_Pin T_Name
11 GPIO17 G17 12 GPIO18 G18 1 3.3V 3.3V
36 GPIO16 G16 35 GPIO19 G19 2 5V 5V
33 GPIO13 G13 38 GPIO20 G20 3 GPIO2 SDA
32 GPIO12 G12 40 GPIO21 G21 4 5V 5V
31 GPIO5 G6 15 GPIO22 G22 5 GPIO3 SCL
29 GPIO5 G5 16 GPIO23 G23 6 GND GND
7 GPIO4 G4 18 GPIO24 G24 7 GPIO4 G4
26 GPIO7 CE1 22 GPIO25 G25 8 GPIO14 TX0
24 GPIO8 CE0 37 GPIO26 G26 9 GND GND
19 GPIO10 MOS1 13 GPIO27 G27 10 GPIO15 RXI
21 GPIO9 MOS0 5 GPIO3 SCL 11 GPIO17 G17
23 GPIO11 SCK 3 GPIO2 SDA 12 GPIO18 G18
10 GPIO15 RXI 28 DNC IDSC GPIO1 13 GPIO27 G27
8 GPIO14 TX0 27 DNC IDSD GPIO0 14 GND GND
2 5V 5V 4 5V 5V 15 GPIO22 G22
17 3.3V 3.3V 1 3.3V 3.3V 16 GPIO23 G23
6 GND GND 9 GND GND 17 3.3V 3.3V
18 GPIO24 G24
19 GPIO10 MOS1
C_Name C_Pin T_Name C_Name C_Pin T_Name 20 GND GND
1 3.3V 3.3V 2 5V 5V 21 GPIO9 MOS0
3 GPIO2 SDA 4 5V 5V 22 GPIO25 G25
5 GPIO3 SCL 6 GND GND 23 GPIO11 SCK
7 GPIO4 G4 8 GPIO14 TX0 24 GPIO8 CE0
9 GND GND 10 GPIO15 RXI 25 GND GND
11 GPIO17 G17 12 GPIO18 G18 26 GPIO7 CE1
13 GPIO27 G27 14 GND GND 27 DNC IDSD
15 GPIO22 G22 16 GPIO23 G23 28 DNC IDSC
17 3.3V 3.3V 18 GPIO24 G24 29 GPIO5 G5
19 GPIO10 MOS1 20 GND GND 30 GND GND
21 GPIO9 MOS0 22 GPIO25 G25 31 GPIO5 G6
23 GPIO11 SCK 24 GPIO8 CE0 32 GPIO12 G12
25 GND GND 26 GPIO7 CE1 33 GPIO13 G13
27 DNC IDSD GPIO0 28 DNC IDSC GPIO1 34 GND GND
29 GPIO5 G5 30 GND GND 35 GPIO19 G19
31 GPIO5 G6 32 GPIO12 G12 36 GPIO16 G16
33 GPIO13 G13 34 GND GND 37 GPIO26 G26
35 GPIO19 G19 36 GPIO16 G16 38 GPIO20 G20
37 GPIO26 G26 38 GPIO20 G20 39 GND GND
39 GND GND 40 GPIO21 G21 40 GPIO21 G21

发表评论