Hardware Reference
In-Depth Information
To provide glitch-free configuration, the following can be done instead:
# echo high >/sys/class/gpio/gpio7/direction
This way, the driver takes the necessary steps to establish the correct output level
prior to making the pin an output.
The settings of the file named edge affect how a C program (for example) would
process poll(2) on the file named value (reading). A poll(2) system call could block the
execution of the program until the required event occurred (like a rising edge).
Active Low
Sometimes it is desirable to have the logic inverted for the GPIO pin being used. For
example, when driving an LED in the circuit configuration of Figure 10-5 , a logic low is
required to light the LED.
Value
Description
0
Noninverted logic
1
Inverted logic
Inverting the logic allows you to light the LED with a logic 1:
# echo 1 >/sys/class/gpio/gpio7/active_low
# echo 1 >/sys/class/gpio/gpio7/value
Conversely, if you don't want inverted logic, you should be certain to establish that
by writing a 0:
# echo 0 >/sys/class/gpio/gpio7/active_low
Chip Level
You will also notice the presence of a subdirectory named gpiochipN in /sys/class/
gpio , where N is a numeric digit. The following main pseudo files exist within that
directory:
base : The value read should be the same value N , which is the
first GPIO managed by this chip.
label : The label (for example, bcm2708_gpio ) of the chip,
which is not necessarily unique. Used for diagnostic purposes.
ngpio : The value read indicates how many GPIOs this chip
manages, starting with the value read from base .
 
 
Search WWH ::




Custom Search