CM3计算板I/O编程
生活随笔
收集整理的這篇文章主要介紹了
CM3计算板I/O编程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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?- Input
- op?- Output
- a0-a5?- Alt0-Alt5
- dh?- Driving high (for outputs)
- dl?- Driving low (for outputs)
- pu?- Pull up
- pd?- Pull down
- pn/np?- No pull
例如:
# 選擇 復用功能2 Alt2 GPIO0~GPIO27 gpio=0-27=a2# 設置GPIO12 輸出拉高 gpio=12=op,dh# 設置GPIO18 20 為輸入上拉 gpio=18,20=pu# 設置GPIO17~GPIO21 為輸入 gpio=17-21=ip3、使用wiringPi C庫對IO編程
- 安裝最新wiringPi,安裝方法見:安裝wiringPi??
- 使用gpio readall 查看是否讀取到CM3的所有IO。
- 編程示例:CM3 GPIO27交替拉高拉低。
- 編譯: gcc -c testGPIO3.c -o run -l wiringPi
- 執行:./run
?
總結
以上是生活随笔為你收集整理的CM3计算板I/O编程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux open函数使用方法记录
- 下一篇: [转贴]搜索引擎优化(SEO)菜鸟版@搜