说明:

yx0--pioA0 yx1--pioA2  yx2--pioA4  yx3--pioA10  yx4--pioA14  yx5--pioA16 yx6--pioA12 yx7--pioA20

   

使用cat方式捕获电平,如果是字符'1',代表输入节点没有闭合,如果是字符'0',代表外部输入节点闭合,

1 配置gpio

root@sama5d3-linux:~ echo 16  > /sys/class/gpio/export
root@sama5d3-linux:~ echo 12  > /sys/class/gpio/export
root@sama5d3-linux:~ echo 10  > /sys/class/gpio/export
root@sama5d3-linux:~ echo 14  > /sys/class/gpio/export
root@sama5d3-linux:~ echo 4  > /sys/class/gpio/export
root@sama5d3-linux:~ echo 2  > /sys/class/gpio/export
root@sama5d3-linux:~ echo 0  > /sys/class/gpio/export

2 配置gpio的方向--输入

root@sama5d3-linux: echo in > /sys/class/gpio/pioA20/direction
root@sama5d3-linux: echo in > /sys/class/gpio/pioA16/direction
root@sama5d3-linux: echo in > /sys/class/gpio/pioA12/direction
root@sama5d3-linux: echo in > /sys/class/gpio/pioA10/direction
root@sama5d3-linux: echo in > /sys/class/gpio/pioA14/direction                   
root@sama5d3-linux: echo in > /sys/class/gpio/pioA4/direction                    
root@sama5d3-linux: echo in > /sys/class/gpio/pioA2/direction                    
root@sama5d3-linux: echo in > /sys/class/gpio/pioA0/direction

3 捕获电平:

root@sama5d3-linux: cat /sys/class/gpio/pioA20/value //如果返回字符'1',代表输入节点没有闭合,如果是字符'0',代表外部输入节点闭合

root@sama5d3-linux: cat /sys/class/gpio/pioA16/value

root@sama5d3-linux: cat /sys/class/gpio/pioA12/value

root@sama5d3-linux: cat /sys/class/gpio/pioA10/value

root@sama5d3-linux: cat /sys/class/gpio/pioA4/value

root@sama5d3-linux: cat /sys/class/gpio/pioA2/value

root@sama5d3-linux: cat /sys/class/gpio/pioA0/value

05-11 19:40