日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CM3计算板I/O编程

發(fā)布時間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CM3计算板I/O编程 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、CM3計算板的IO資源

CM3支持的I/O管腳數(shù)為54個,每個管腳包括一個或多個復(fù)用功能,分別位于ALT0~ALT5,如下表:

2、設(shè)備樹啟用IO外設(shè)的方式

通過在/boot/config.txt 文件中描述IO行為,可以在系統(tǒng)啟動時,初始化IO外設(shè)的初始狀態(tài),例如,配置為輸入輸出、上下拉狀態(tài)以及復(fù)選功能。

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

例如:

# 選擇 復(fù)用功能2 Alt2 GPIO0~GPIO27 gpio=0-27=a2# 設(shè)置GPIO12 輸出拉高 gpio=12=op,dh# 設(shè)置GPIO18 20 為輸入上拉 gpio=18,20=pu# 設(shè)置GPIO17~GPIO21 為輸入 gpio=17-21=ip

3、使用wiringPi C庫對IO編程

  • 安裝最新wiringPi,安裝方法見:安裝wiringPi??
  • 使用gpio readall 查看是否讀取到CM3的所有IO。
  • 編程示例:CM3 GPIO27交替拉高拉低。
  • 編譯: gcc -c testGPIO3.c -o run -l wiringPi
  • 執(zhí)行:./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; }

?

總結(jié)

以上是生活随笔為你收集整理的CM3计算板I/O编程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。