DE10-Standard
User Manual
94
www.terasic.com
January 19, 2017
#include "socal/socal.h"
#include "socal/hps.h"
#include "socal/alt_gpio.h"
LED and KEY Control
Figure 6-4
shows the HPS users LED and KEY pin assignment for the DE1_SoC board. The LED
is connected to HPS_GPIO53 and the KEY is connected to HPS_GPIO54. They are controlled by
the GPIO1 controller, which also controls HPS_GPIO29 ~ HPS_GPIO57.
Figure 6-4 Pin assignment of LED and KEY
Figure 6-5
shows the
gpio_swporta_ddr
register of the GPIO1 controller. The bit-0 controls the
pin direction of HPS_GPIO29. The bit-24 controls the pin direction of HPS_GPIO53, which
connects to HPS_LED, the bit-25 controls the pin direction of HPS_GPIO54, which connects to
HPS_KEY and so on. The pin direction of HPS_LED and HPS_KEY are controlled by the bit-24
and bit-25 in the
gpio_swporta_ddr
register of the GPIO1 controller, respectively. Similarly, the
output status of HPS_LED is controlled by the bit-24 in the
gpio_swporta_dr
register of the
GPIO1 controller. The status of KEY can be queried by reading the value of the bit-24 in the
gpio_ext_porta
register of the GPIO1 controller.
Figure 6-5
gpio_swporta_ddr
register in the GPIO1 controller
The following mask is defined in the demo code to control LED and KEY direction and LED’s