HAN Pilot Platform
Demonstration Manual
47
www.terasic.com
September 6, 2019
Figure 3-4 Pin assignment of LED and KEY
gpio_swporta_ddr
register of the GPIO1 controller. The bit-0 controls the
pin direction of GPIO1_IO0. The bit-1 controls the pin direction of GPIO1_IO1, which connects to
HPS_LED, the bit-4 controls the pin direction of GPIO1_IO4, which connects to HPS_KEY and so
on. The pin direction of HPS_LED and HPS_KEY are controlled by the bit-1 and bit-4 in the
gpio_swporta_ddr
register of the GPIO1 controller, respectively. Similarly, the output status of
HPS_LED is controlled by the bit-1 in the
gpio_swporta_dr
register of the GPIO1 controller. The
status of KEY can be queried by reading the value of the bit-4 in the
gpio_ext_porta
register of the
GPIO1 controller.
Figure 3-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
output value.
define USER_IO_DIR (0x00000002)
define BIT_LED (0x00000002)
define BUTTON_MASK (0x00000010)
The following statement is used to configure the LED associated pins as output pins.
alt_setbits_word( ( virtua ALT_GPIO_SWPORTA_DDR_OFST ), USER_IO_DIR );
The following statement is used to turn on the LED.
alt_clrbits_word( ( virtua ALT_GPIO_SWPORTA_DR_OFST ), BIT_LED );
The following statement is used to read the content of
gpio_ext_porta
register. The bit mask is used
to check the status of the key.
alt_read_word( virtua ALT_GPIO_EXT_PORTA_OFST );
Содержание HAN Pilot Platform
Страница 1: ......
Страница 92: ...HAN Pilot Platform Demonstration Manual 91 www terasic com September 6 2019...