Hardware Reference
In-Depth Information
Figure 8-2. Diagram for wiring a pushbutton and LED with the LED attached to P9_13
bone#
cd cd /sys/class/gpio/
bone#
echo 31 > export
bone#
cd gpio31
bone#
echo out > direction
bone#
echo 1 > value
bone#
echo 0 > value
The LED will turn on when
1
is echoed into
value
and off when
0
is echoed.
Now that you know the LED is working, look up its memory address. This is where things
get very detailed. First, download the
AM335x Technical Reference Manual
.
Look up
GPIO0
in the Memory Map chapter (sensors). Table 2-2 indicates that
GPIO0
starts at
address
0x44E0_7000
. Then go to Section 25.4.1, “GPIO Registers.” This shows that
GPIO_DATAIN
has an offset of
0x138
,
GPIO_CLEARDATAOUT
has an offset of
0x190
, and
GPIO_SETDATAOUT
has an offset of
0x194
.
This means you read from address
0x44E0_7000
+
0x138
=
0x44E0_7138
to see
the status of the LED:
bone#
devmem2 0x44E07138
/dev/mem opened.
Memory mapped at address 0xb6f8e000.