Ubuntu20.04 GPIO设置
2023-07-25
admin
319
Ubuntu20.04 GPIO设置
设置为输出
以GPIO390 PG.07为例
sudo echo 390 > /sys/class/gpio/export
sudo chmod 777 /sys/class/gpio/PG.07/value
sudo chmod 777 /sys/class/gpio/PG.07/direction
sudo echo "out" > /sys/class/gpio/PG.07/direction
sudo echo 1 > /sys/class/gpio/PG.07/value
sudo echo 0 > /sys/class/gpio/PG.07/value
设置为输入
sudo echo 390 > /sys/class/gpio/export
sudo chmod 777 /sys/class/gpio/PG.07/value
sudo chmod 777 /sys/class/gpio/PG.07/direction
sudo echo "in" > /sys/class/gpio/PG.07/direction
查看状态
sudo cat /sys/kernel/debug/gpio | grep 390