标签:board 需要 setup 模块 新版 name set oid wiringpi
wiringPi库最早是由Gordon Henderson所编写并维护的一个用C语言写成的类库,除了GPIO库,还包括了I2C库、SPI库、UART库和软件PWM库等,由于wiringPi的API函数和arduino非常相似,这也使得它广受欢迎。
wiringPi库除了提供wiringPi类库及其头文件外,还提供了一个命令行工具gpio:可以用来设置和读写GPIO管脚,以方便在Shell脚本中控制GPIO管脚。
wiringPi库最初是为BCM2835芯片编写的,现已移植到FriendlyELEC-RK3399平台,目前支持NanoPi M4、NanoPi NEO4、和NanoPC-T4开发板。
当前提供的WiringPi版本:2.44
WiringPi项目主页: http://wiringpi.com
我们同时为FriendlyELEC-RK3399平台提供了wiringPi的Python版本,请前往这里查看: WiringPi-Python for RK3399/zh
注:最新版本ROM中已经默认预装 wiringPi,也可以参照本文的方法手动安装
通过ssh,或者串口终端进入开发板的命令行,用以下命令安装:
# 删除旧的实现
wget http://112.124.9.243:8888/wiringpi/friendlyelec-rk3399/remove_oldversion_wiringPi.sh
chmod 755 remove_oldversion_wiringPi.sh
sudo ./remove_oldversion_wiringPi.sh
# 下载并安装wiringPi for RK3399
wget http://112.124.9.243:8888/wiringpi/friendlyelec-rk3399/wiringpi-v2.44-friendlyelec-rk3399.deb
sudo dpkg -i wiringpi-v2.44-friendlyelec-rk3399.deb
通过以下指令可以测试wiringPi是否安装成功:
gpio readall
如果安装成功会显示开发板的针脚布局,例如NanoPi M4会显示如下信息:
root@NanoPi-M4:~# gpio readall
+------+-----+----------+------+ Model NanoPi-M4 +------+----------+-----+------+
| GPIO | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | GPIO |
+------+-----+----------+------+---+----++----+---+------+----------+-----+------+
| | | 3.3V | | | 1 || 2 | | | 5V | | |
| | | I2C2_SDA | | | 3 || 4 | | | 5V | | |
| | | I2C2_SCL | | | 5 || 6 | | | GND(0V) | | |
| 32 | 7 | GPIO1_A0 | OUT | 0 | 7 || 8 | | ALT | GPIO4_C1 | 15 | 145 |
| | | GND(0V) | | | 9 || 10 | | ALT | GPIO4_C0 | 16 | 144 |
| 33 | 0 | GPIO1_A1 | IN | 0 | 11 || 12 | 1 | IN | GPIO1_C2 | 1 | 50 |
| 35 | 2 | GPIO1_A3 | IN | 0 | 13 || 14 | | | GND(0V) | | |
| 36 | 3 | GPIO1_A4 | IN | 0 | 15 || 16 | 0 | IN | GPIO1_C6 | 4 | 54 |
| | | 3.3V | | | 17 || 18 | 0 | IN | GPIO1_C7 | 5 | 55 |
| | | UART4_TX | | | 19 || 20 | | | GND(0V) | | |
| | | UART4_RX | | | 21 || 22 | 0 | IN | GPIO1_D0 | 6 | 56 |
| | | SPI1_CLK | | | 23 || 24 | | | SPI1_CSn | | |
| | | GND(0V) | | | 25 || 26 | | ALT | GPIO4_C5 | 11 | 149