# Manage the GPIO lines using the sysfs user interface (deprecated)

<abstract>
GPIO sysfs is the legacy way to manage the GPIO lines under Linux from user space. 
It uses the directory /sys/class/gpio to set or read any GPIO line.
replaced with the GPIO character device.
</abstract>

Inside this directory there are two directories called:

* export
* unexport

To manage a GPIO line you have to know its kernel ID. The Kernel 
IDs of any Acme Systems SoM are available on:

* @article='pinout_all'
* @article='pinout_kernelid'

Check the port available by typing this command:

	sudo less /sys/kernel/debug/pinctrl/fc038000.pinctrl-atmel_pinctrl/pinconf-pins

The Microchip chips have the GPIO lines organized by 32 bit port called PA,PB, etc.

Before set or read a port you have to export it. Follow an example on how to set, reset 
and read the port PA1 (Kernel ID 1) from the command line:

Set the line status of GPIO line PA1

	sudo sh -c "echo 1 > /sys/class/gpio/export"
	sudo sh -c "echo out > /sys/class/gpio/PA1/direction"
	sudo sh -c "echo 1 > /sys/class/gpio/PA1/value"

Reset the line status of GPIO line PA1

	sudo sh -c "echo 0 > /sys/class/gpio/PA1/value"

Read the line status of GPIO line PA1

	sudo sh -c "echo in > /sys/class/gpio/PA1/direction"
	cat /sys/class/gpio/PA1/value

The official documentation about the GPIO Sysfs interface is available on:

* [GPIO Sysfs Interface for Userspace](https://www.kernel.org/doc/Documentation/gpio/sysfs.txt)

@include='adv_roadrunner'
