Hardware Reference
In-Depth Information
Solution
Recipe 7.3 introduces the sysfs . This recipe shows how to read and write a GPIO pin.
Reading a GPIO Pin via sysfs
Suppose that you want to read the state of the P9_42 GPIO pin. ( Recipe 2.3 shows how to
wire a switch to P9_42 .) First, you need to map the P9 header location to GPIO number
using Figure 7-1 , which shows that P9_42 maps to GPIO 7.
Figure 7-1. Mapping P9_42 header position to GPIO 7
Next, change to the GPIO sysfs directory:
bone# cd /sys/class/gpio/
bone# ls
export gpiochip0 gpiochip32 gpiochip64 gpiochip96 unexport
Search WWH ::




Custom Search