说明:
gpio的MAP关系 yx0--20 yx1--16 yx2--12 yx3--10 yx4--14 yx5--4 yx6--2 yx7--0
使用cat方式捕获电平,如果是字符‘1‘,代表输入节点没有闭合,如果是字符‘0‘,代表外部输入节点闭合,
1 配置gpio
[email protected]:~ echo 16 > /sys/class/gpio/export
[email protected]:~ echo 12 > /sys/class/gpio/export
[email protected]:~ echo 10 > /sys/class/gpio/export
[email protected]:~ echo 14 > /sys/class/gpio/export
[email protected]:~ echo 4 > /sys/class/gpio/export
[email protected]:~ echo 2 > /sys/class/gpio/export
[email protected]:~ echo 0 > /sys/class/gpio/export
2 配置gpio的方向--输入
[email protected]: echo in > /sys/class/gpio/pioA20/direction
[email protected]: echo in > /sys/class/gpio/pioA16/direction
[email protected]: echo in > /sys/class/gpio/pioA12/direction
[email protected]: echo in > /sys/class/gpio/pioA10/direction
[email protected]: echo in > /sys/class/gpio/pioA14/direction
[email protected]: echo in > /sys/class/gpio/pioA4/direction
[email protected]: echo in > /sys/class/gpio/pioA2/direction
[email protected]: echo in > /sys/class/gpio/pioA0/direction
3 捕获电平:
[email protected]: cat /sys/class/gpio/pioA20/value //如果返回字符‘1‘,代表输入节点没有闭合,如果是字符‘0‘,代表外部输入节点闭合
[email protected]: cat /sys/class/gpio/pioA16/value
[email protected]: cat /sys/class/gpio/pioA12/value
[email protected]: cat /sys/class/gpio/pioA10/value
[email protected]: cat /sys/class/gpio/pioA4/value
[email protected]: cat /sys/class/gpio/pioA2/value
[email protected]: cat /sys/class/gpio/pioA0/value