Hardware Reference
In-Depth Information
The
ls
command shows all the GPIO pins that have be exported. In this case, none have,
so you see only the four GPIO controllers. Export using the
export
command:
bone#
echo 7 > export
bone#
ls
export gpio7 gpiochip0 gpiochip32 gpiochip64 gpiochip96
unexport
Now you can see the
gpio7
directory. Change into the
gpio7
directory and look around:
bone#
cd gpio7
bone#
ls
active_low direction edge power subsystem uevent value
bone#
cat direction
in
bone#
cat value
0
Notice that the pin is already configured to be an input pin. (If it wasn't already con-
figured that way, use
echo in > direction
to configure it.) You can also see that
its current value is
0
— that is, it isn't pressed. Try pressing and holding it and running
again:
bone#
cat value
1
The
1
informs you that the switch is pressed. When you are done with GPIO 7, you can
always
unexport
it:
bone#
cd ..
bone#
echo 7 > unexport
bone#
ls
export gpiochip0 gpiochip32 gpiochip64 gpiochip96 unexport
Writing a GPIO Pin via sysfs
Now, suppose that you want to control an external LED.
Recipe 3.2
shows how to wire an