建设网站目的及功能定位,湘潭电大网站,淄博网站建设优惠臻动传媒,网站营销优化方案1、CM3计算板的IO资源
CM3支持的I/O管脚数为54个#xff0c;每个管脚包括一个或多个复用功能#xff0c;分别位于ALT0~ALT5#xff0c;如下表#xff1a; 2、设备树启用IO外设的方式
通过在/boot/config.txt 文件中描述IO行为#xff0c;可以在系统启动时#xff0c;初…1、CM3计算板的IO资源
CM3支持的I/O管脚数为54个每个管脚包括一个或多个复用功能分别位于ALT0~ALT5如下表 2、设备树启用IO外设的方式
通过在/boot/config.txt 文件中描述IO行为可以在系统启动时初始化IO外设的初始状态例如配置为输入输出、上下拉状态以及复选功能。
The gpio directive allows GPIO pins to be set to specific modes and values at boot time in a way that would previously have needed a custom dt-blob.bin file. Each line applies the same settings (or at least makes the same changes) to a set of pins, either a single pin (3), a range of pins (3-4), or a comma-separated list of either (3-4,6,8). The pin set is followed by an and one or more comma-separated attributes from this list:
ip - Inputop - Outputa0-a5 - Alt0-Alt5dh - Driving high (for outputs)dl - Driving low (for outputs)pu - Pull uppd - Pull downpn/np - No pull
例如
# 选择 复用功能2 Alt2 GPIO0~GPIO27
gpio0-27a2# 设置GPIO12 输出拉高
gpio12op,dh# 设置GPIO18 20 为输入上拉
gpio18,20pu# 设置GPIO17~GPIO21 为输入
gpio17-21ip
3、使用wiringPi C库对IO编程
安装最新wiringPi安装方法见安装wiringPi 使用gpio readall 查看是否读取到CM3的所有IO。编程示例CM3 GPIO27交替拉高拉低。编译 gcc -c testGPIO3.c -o run -l wiringPi执行./run
#include wiringPi.h#define TEST_PIN 27int main(void)
{wiringPiSetup();pinMode(TEST_PIN, OUTPUT);while(1){digitalWrite(TEST_PIN, HIGH);delay(1000);digitalWrite(TEST_PIN, LOW);delay(1000);}return 0;
}