SoCKit User Manual
78
www.terasic.com
December 1, 2015
In this demo code, the following mask is defined to control LED direction and output value.
The following statement can be used to configure the LED associated pins as output pins.
alt_setbits_word( ( virtua
( ( uint32_t )( ALT_GPIO1_SWPORTA_DDR_ADDR ) &
( uint32_t )( HW_REGS_MASK ) ) ),
BIT_LED_ALL
);
The following statement can be used to turn on all LED.
alt_setbits_word( ( virtua
( ( uint32_t )( ALT_GPIO1_SWPORTA_DR_ADDR ) &
( uint32_t )( HW_REGS_MASK ) ) ),
BIT_LED_ALL
);
Switches and Keys Control
Figure 6-6
shows the pin assignment of HPS users key and switch for the SoCKit board. The
controller pin HPS_GPI4 ~ HPS_GPI11 are controlled by the GPIO2 controller. It is not necessary
to configure the direction of these pins before using because they are input-only. The status of
switches and keys can be queried by reading the
gpio_ext_porta
register in the GPIO2 controller.
Figure 6-6 HPS Switches and Keys Pin Assignment
Figure 6-7
shows the
gpio_ext_porta
register of the GPIO2 controller. The bit-0 represents the
input value of HPS_GPIO54. The bit-17 represents the input value of HPS_GPI4, which is