How to use GPIO in C language

Hi fuqiang.song, for accessing GPIO from userspace, you can use the sysfs file nodes under /sys/class/gpio/

Reading and writing to these files is how languages like C/C++, Python, and other libraries implement it under the covers. You can see the documentation for it here: [url]https://www.kernel.org/doc/Documentation/gpio/sysfs.txt[/url]

Also see slide #35 from this presentation for a high level overview.

And here is a code example in C of using these files for GPIO: [url]https://developer.ridgerun.com/wiki/index.php/Gpio-int-test.c[/url]

1 Like