Difference between revisions of "AFE-E630 GPIO"
From ESS-WIKI
Xingxing.li (talk | contribs) (Created page with " File:AFE-E630 DIDO.png File:AFE-E630 DIDO GPIO.png") |
Xingxing.li (talk | contribs) |
||
Line 1: | Line 1: | ||
− | [[File:AFE-E630 DIDO.png]] | + | [[File:AFE-E630 DIDO.png|RTENOTITLE]] |
− | [[File:AFE-E630 DIDO GPIO.png]] | + | [[File:AFE-E630 DIDO GPIO.png|RTENOTITLE]] |
+ | |||
+ | === '''Test''' === | ||
+ | |||
+ | Export GPIO then you can use control GPIO from userr space through sysfs. | ||
+ | |||
+ | Export GPIO0 | ||
+ | <pre># echo 8 > /sys/class/gpio/export | ||
+ | </pre> | ||
+ | |||
+ | Set GPIO direction to in/out | ||
+ | <pre># echo "out" > /sys/class/gpio/gpio8/direction | ||
+ | </pre> | ||
+ | |||
+ | Set GPIO value 0/1 if GPIO pin define is output | ||
+ | <pre># echo 1 > /sys/class/gpio/gpio8/value | ||
+ | </pre> | ||
+ | |||
+ | Unexport GPIO0 | ||
+ | <pre># echo 8 > /sys/class/gpio/unexport</pre> | ||
+ | |||
+ | === '''GPIO Test''' === | ||
+ | |||
+ | 1. GPIO0 and GPIO1 are taken as an example: Connect GPIO0 and GPIO1 | ||
+ | |||
+ | *'''Export GPIO0 and GPIO1''' | ||
+ | <pre># echo 8 > /sys/class/gpio/export | ||
+ | # echo 98 > /sys/class/gpio/export | ||
+ | </pre> | ||
+ | |||
+ | *'''Set GPIO0 to output and GPIO1 to input''' | ||
+ | <pre># echo "out" > /sys/class/gpio/gpio8/direction | ||
+ | # echo "in" > /sys/class/gpio/gpio98/direction | ||
+ | </pre> | ||
+ | |||
+ | *'''Change GPIO0 to 1 and read GPIO1 value''' | ||
+ | <pre># echo 1 > /sys/class/gpio/gpio8/value | ||
+ | # cat /sys/class/gpio/gpio98/value | ||
+ | 1 | ||
+ | </pre> | ||
+ | |||
+ | *'''Change GPIO0 to 0 and read GPIO1 value''' | ||
+ | <pre># echo 0 > /sys/class/gpio/gpio8/value | ||
+ | # cat /sys/class/gpio/gpio98/value | ||
+ | 0</pre> | ||
+ | |||
+ | [[File:AFE-E630 GPIO Function.png]] | ||
+ | |||
+ | 2. Test GPIO mode 2(Short Pin1->6、2->7、3->4) | ||
+ | <pre># /tools/test/adv/gpio/gpio_autotest.sh</pre> | ||
+ | |||
+ | [[File:AFE-E630 GPIO Loopback.png]] |
Latest revision as of 09:03, 17 December 2024
Test
Export GPIO then you can use control GPIO from userr space through sysfs.
Export GPIO0
# echo 8 > /sys/class/gpio/export
Set GPIO direction to in/out
# echo "out" > /sys/class/gpio/gpio8/direction
Set GPIO value 0/1 if GPIO pin define is output
# echo 1 > /sys/class/gpio/gpio8/value
Unexport GPIO0
# echo 8 > /sys/class/gpio/unexport
GPIO Test
1. GPIO0 and GPIO1 are taken as an example: Connect GPIO0 and GPIO1
- Export GPIO0 and GPIO1
# echo 8 > /sys/class/gpio/export # echo 98 > /sys/class/gpio/export
- Set GPIO0 to output and GPIO1 to input
# echo "out" > /sys/class/gpio/gpio8/direction # echo "in" > /sys/class/gpio/gpio98/direction
- Change GPIO0 to 1 and read GPIO1 value
# echo 1 > /sys/class/gpio/gpio8/value # cat /sys/class/gpio/gpio98/value 1
- Change GPIO0 to 0 and read GPIO1 value
# echo 0 > /sys/class/gpio/gpio8/value # cat /sys/class/gpio/gpio98/value 0
2. Test GPIO mode 2(Short Pin1->6、2->7、3->4)
# /tools/test/adv/gpio/gpio_autotest.sh