ASUS Tinker Board 2S 設定 GPIO(Using the sysfs Interface)
https://tinker-board.asus.com/forum/index.php?/topic/14984-gpio/
方法一:
Using the sysfs Interface
就是直接對 Linux File System 的 /sys/class/gpio/ 文字檔進行讀寫
方法二:
使用 ASUS 提供的 GPIO WiringPi for C library
https://github.com/TinkerBoard/TinkerBoard/wiki/User-Guide#sample-code-for-tinker-board-2-series
http://dlcdnet.asus.com/pub/ASUS/mb/Linux/Tinker_Board_2GB/GPIO_API_for_C.ZIP
方法三:
方法一說明:
1. 先到wiki 查詢 2S GPIO pin對應到 Linux Debian之Device Path
(Tinker Board 2S 每一個GPIO Pin 對應到Linux GPIO Index)
GPIO Config Table for Tinker Board 2 series:
https://github.com/TinkerBoard/TinkerBoard/wiki/User-Guide#gpio-config-table-for-tinker-board-2-series
例如本次要試驗的是 Tinker Board 2S GPIO pin-18
對應到 Debian之Device Path是 GPIO: /sys/class/gpio/gpio87
2. 參考網站
GPIO Programming: Using the sysfs Interface
https://www.ics.com/blog/gpio-programming-using-sysfs-interface
風火輪對 /sys/class/gpio 之解釋文
https://wiki.youyeetoo.cn/tinker/page/DebianSystem/User_GPIO
3. 設定
$ sudo bluefish /boot/config.txt
下面這一行 GPIO pin-18 為 spi5 不可以打開
#intf:spi5=off
4. 指令
> Device Path是 GPIO: /sys/class/gpio/gpio87
$ sudo su
$ cd /sys/class/gpio
$ echo 87 >/sys/class/gpio/export
$ ls /sys/class/gpio/gpio87/
$ echo out >/sys/class/gpio/gpio87/direction
$ echo 0 >/sys/class/gpio/gpio87/value
> 電錶量測 Tinker Board 2S GPIO pin-18 會是 0
$ echo 1 >/sys/class/gpio/gpio87/valu
> 電錶量測 Tinker Board 2S GPIO pin-18 會是 3.3v
沒有留言:
張貼留言