Hello Everyone,
I want to know,
I want to use GPIO pins which are available in COM express.
So, 1.can anyone please tell me how to access COM express GPIO pins?
2. How can I communicate/ transfer data (read and write) through COM express's GPIO pins, can you please a share sample code for this?
Hello Shyubham,
This question has been opened but there is no reply for a long time.We have a tentative answer already, so I will close this question.If you have any updates or want to ask another question…
Hello Shyubham-san
I hope the following helps you.
How to access GPIO via sysfs
Ex) Case of : H3 starter Kit, GP5-17(SW2-1)
1) Build with "CONFIG_GPIO_SYSFS" enabled in the kernel and boot
Device Drivers ->
SGPIO Support ->
[*] /sys/class/gpio/... (sysfs intercase)
2) Access to GPIO via sysfs
The pin's sysfs GPIO index:
# cat /sys/kernel/debug/gpio
This should list all GPIO pins available in the system along with their status.
For example, the following should be listed for GP5:
gpiochip5: GPIOs 392-417, parent: platform/e6055000.gpio, e6055000.gpio:
gpio-393 ( |SDHI0 VccQ ) out hi
gpio-394 ( |regulator-vcc-sdhi0 ) out lo
The first line gives you the following information: GP5_0 sysfs index is 392.
If you want to read GP5_17 (SW2-1) you have to use sysfs index 409 (392 + 17 = 409).
Since gpio-409 is not listed above, it's unused, and you can grab it as follows:
# echo 409 > /sys/class/gpio/export
The following directory should appear under /sys/class/gpio:
# ls /sys/class/gpio/gpio409/
active_low device direction edge power subsystem uevent value
These are the GPIO pin control files. By default, the GPIO is configured an active high input:
# cat /sys/class/gpio/gpio409/active_low
0
# cat /sys/class/gpio/gpio409/direction
in
The following command reads the GPIO pin state:
# cat /sys/class/gpio/gpio409/value
1
If you toggle SW2.1, the following value should be read:
The following command sets GPIO active low:
# echo 1 > /sys/class/gpio/gpio409/active_low
Similarly, the GPIO direction can be changed by writing "out" to the "/sys/class/gpio/gpio<N>/direction" file; although, it's not safe to set output direction for input pins.
For more information, please refer to the following
www.kernel.org/.../sysfs.txt
This question has been opened but there is no reply for a long time.We have a tentative answer already, so I will close this question.If you have any updates or want to ask another question, please post new question.