【BIGTREETECH PI开发板】 GPIO输出控制
[复制链接]
本帖最后由 TL-LED 于 2023-7-7 17:38 编辑
这款开发板针对外设的操作资料不是很多,下面来使用第三方的wiringPI库来测试下外设的使用。
一、下载和安装wiringOP
wiringOP是在wiringPI的基础上针对开发板的端口进行封装。
下载地址: git clone
命令:biqu@BTT-CB1:/opt$ sudo git clone
命令:biqu@BTT-CB1:/opt$ cd wiringOP/
命令:biqu@BTT-CB1:/opt/wiringOP$ ./build clean
命令:biqu@BTT-CB1:/opt/wiringOP$ ./build
安装完成后,测试下
执行命令:biqu@BTT-CB1:/opt/wiringOP$ gpio readall
读取到设备端口号,这个是其他型号的开发板端口外设引脚定义,和测试使用的板卡引脚定义不一样,使用的处理器型号都是H616,可以在这个库的基础上进行修改和测试。
二、测试GPIO端口
2.1、测试板卡引脚定义
in |
BTT Pi |
CB1 eMMC |
CB1 |
CM4 |
CM4 |
CB1 |
CB1 eMMC |
BTT Pi |
Pin |
Signal |
Description |
Signal |
Description |
Signal |
Description |
Signal |
Description |
Signal |
Description |
Signal |
Description |
Signal |
Description |
Signal |
Description |
1 |
3.3V |
3.3V |
3.3V |
3.3V |
5V |
5V |
5V |
5V |
2 |
3 |
PC3 |
GPIO67 |
NC |
NC |
GPIO2 |
I2C1 SDA |
5V |
5V |
5V |
5V |
4 |
5 |
PC0 |
GPIO64 |
NC |
NC |
GPIO3 |
I2C1 SCL |
GND |
GND |
GND |
GND |
6 |
7 |
PC7 |
GPIO71 |
PI14 |
GPIO170 |
PC7 |
GPIO71 |
GPIO4 |
GPCLK0 |
GPIO14 |
UART TX |
PH0 |
GPIO224, UART0_TX |
PH0 |
GPIO224, UART0_TX |
PH0 |
GPIO224, UART0_TX |
8 |
9 |
GND |
GND |
GND |
GND |
GPIO15 |
UART RX |
PH1 |
GPIO225, UART0_RX |
PH1 |
GPIO225, UART0_RX |
PH1 |
GPIO225, UART0_RX |
10 |
11 |
PC14 |
GPIO78 |
PI15 |
GPIO271 |
PC14 |
GPIO78 |
GPIO17 |
SPI1 CE1 |
GPIO18 |
PCM CLK |
PC13 |
GPIO77 |
PI7 |
GPIO263 |
PC13 |
GPIO77 |
12 |
13 |
PC12 |
GPIO76 |
PI6 |
GPIO262 |
PC12 |
GPIO76 |
GPIO27 |
|
GND |
GND |
GND |
GND |
14 |
15 |
PC10 |
74 |
PI4 |
GPIO260 |
PC10 |
GPIO74 |
GPIO22 |
|
GPIO23 |
|
PC11 |
GPIO75 |
PI5 |
GPIO261 |
PC11 |
GPIO75 |
16 |
17 |
3.3V |
3.3V |
3.3V |
3.3V |
GPIO24 |
|
PC9 |
GPIO73 |
PI3 |
GPIO259 |
PC9 |
GPIO73 |
18 |
19 |
PH7 |
GPIO231, SPI1_MOSI |
PH7 |
GPIO231, SPI1_MOSI |
PH7 |
GPIO231, SPI1_MOSI |
GPIO10 |
SPI0 MOSI |
GND |
GND |
GND |
GND |
20 |
21 |
PH8 |
GPIO232, SPI1_MISO |
PH8 |
GPIO232, SPI1_MISO |
PH8 |
GPIO232, SPI1_MISO |
GPIO9 |
SPI0 MISO |
GPIO25 |
|
NC |
NC |
PG13 |
GPIO205 |
22 |
23 |
PH6 |
GPIO230, SPI1_CLK |
PH6 |
GPIO230, SPI1_CLK |
PH6 |
GPIO230, SPI1_CLK |
GPIO11 |
SPI0 SCLK |
GPIO8 |
SPI0 CE0 |
NC |
NC |
PG12 |
GPIO204 |
24 |
25 |
GND |
GND |
GND |
GND |
GPIO7 |
SPI0 CE1 |
PG8 |
GPIO200 |
PI11 |
GPIO267 |
PI9 |
GPIO265 |
26 |
27 |
PC2 |
GPIO66 |
NC |
NC |
GPIO0 |
EEPROM SDA |
GPIO1 |
EEPROM SCL |
PG7 |
GPIO199 |
PI10 |
GPIO266 |
PI10 |
GPIO266 |
28 |
29 |
PC4 |
GPIO68 |
NC |
NC |
GPIO5 |
GPCLK1 |
GND |
GND |
GND |
GND |
30 |
31 |
PI5 |
GPIO261 |
PI9 |
GPIO265 |
PG6 |
GPIO198 |
GPIO6 |
GPCLK2 |
GPIO12 |
PWM0 |
PG9 |
GPIO201 |
PI12 |
GPIO268 |
PI6 |
GPIO262 |
32 |
33 |
PI14 |
GPIO270 |
NC |
NC |
GPIO13 |
PWM1 |
GND |
GND |
GND |
GND |
34 |
35 |
PC6 |
GPIO70 |
PI1 |
GPIO257 |
PC6 |
GPIO70 |
GPIO19 |
PCM FS |
GPIO16 |
SPI1 CE2 |
NC |
NC |
PG11 |
GPIO203 |
36 |
37 |
PC15 |
GPIO79 |
PI13 |
GPIO269 |
PC15 |
GPIO79 |
GPIO26 |
|
GPIO20 |
PCM DIN |
PH10 |
GPIO234, IR_RX |
PH10 |
GPIO234, IR_RX |
PH4 |
GPIO228 |
38 |
39 |
GND |
GND |
GND |
GND |
GPIO21 |
PCM DOUT |
PC8 |
GPIO72 |
PI2 |
GPIO258 |
PC8 |
GPIO72 |
40 |
2.2、使用PC7端口,来测试下输出
程序部分:
pc_test.c
#include <stdio.h>
#include <wiringPi.h>
#define NUM 13
int main (void)
{
wiringPiSetup () ;
pinMode (NUM, OUTPUT) ;
for ( ;; )
{
digitalWrite (NUM, HIGH) ;
printf("pc7 -> high!\r\n");
delay (1000) ; // mS
digitalWrite (NUM, LOW) ;
printf("pc7 -> low!\r\n");
delay (1000) ;
}
return 0;
}
2.3、编译
命令:biqu@BTT-CB1:/opt/wiringOP/examples$ sudo make pc7_test
三、运行程序
3.1、执行命令
biqu@BTT-CB1:/opt/wiringOP/examples$ sudo ./pc7_test
3.2、运行视频
103
|