The sysfs GPIO interface lets people manage and control GPIOs through sets or files. It is located under /sys/class/gpio. The device model is heavily used here, and there are three kinds of entry available:
- /sys/class/gpio/: This is where everything begins. This directory contains two special files, export and unexport:
- export: This allow us to ask the kernel to export control of a given GPIO to the user space by writing its number to this file. An example is echo 21 > export, which will create a GPIO21 node for GPIO #21, if that's not requested by the kernel code.
- unexport: This reverses the effect of exporting to user space. Example: echo 21 > unexport will remove any GPIO21 node exported using the export file.
- /sys/class/gpio/gpioN/ ...