本章以YY3588的GPIO1_PA4为例讲解GPIO用户接口的使用
将GPIO 36设置为用户态操作
echo 36 > /sys/class/gpio/export
将GPIO 101设置为输出
echo out > /sys/class/gpio/gpio36/direction
在GPIO 36为输出的情形下,设置电平
高电平
echo 1 > /sys/class/gpio/gpio36/value
低电平
echo 0 > /sys/class/gpio/gpio36/value
将GPIO 36设置为输入
echo in > /sys/class/gpio/gpio36/direction
在GPIO 36为输入的情形下,读取其电平,1为高,0为低
cat sys/class/gpio/gpio36/value
取消GPIO 36用户态操作
echo 36 > /sys/class/gpio/unexport
cat GPOI_PWM.sh
#!/bin/bash
#GPIO1_PA4 --- gpio36
echo 36 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio36/direction
echo 1 > /sys/class/gpio/gpio36/value
while true; do
echo 1 > /sys/class/gpio/gpio36/value
sleep $1 && echo "delay $1"
echo 0 > /sys/class/gpio/gpio36/value
sleep $1 && echo "delay $1"
done
root@linaro-alip:/# ./GPIO_PWM.sh 0.01
delay 0.01
delay 0.01
delay 0.01
...