Introduction This HardwareLibs project is meant as an example for using the GPIO APIs. The project demonstrates the following GPIO Flash API features: - Using GPIO as output port to drive HPS LED - Using GPIO as input port from HPS Push Button The project also demonstrates the following additional API features: - Using Global Timer to implement delays - Using Interrupts Note: This example was tested against SoC EDS 18.0. ==== Target Boards: - Altera Arria10 SoC Development Board rev C. ==== Hardware Design: A hardware design was required for the example, to connect few signals (GPIO1_IO8 and GPIO1_IO19) of the GPIO module to the HPS shared IO on the Arria10 SoC boards. The hardware design is based on the GHRD (Golden Hardware Reference Design with the only modification that the GPIO1_IO8 and GPIO1_IO19 signals are connected to the HPS Shared IO. Note that the Bootloader was also re-generated and compiled for this hardware design. The Bootloader is ran by the debugger script before the program is started. The hardware design is contained in the folder named 'a10_soc_devkit_gpio'. ==== Source Files The following are descriptions of the source and header files contained in this project: gpio_demo_a10.c Contain the main, system initialization and cleanup, delay functions, interrupts setup, functions demonstrating GPIO APIs. ===== Building the Example Before running the example, the target executable first needs to be built. 1. In DS-5, build the application: 1a. Switch to the C/C++ Perspective if not already in that perspective by selecting the menu: Window >> Open Perspective >> C/C++. 1b. In the "Project Explorer" panel, right-mouse-click "Altera-SoCFPGA-HardwareLib-GPIO-A10-GNU" and select "Build Project". The Console panel (bottom of the UI) should detail the progress of the build and report any warnings or errors. ===== Running the Example 1. Configure the FPGA with the FPGA configuration file a10_soc_devkit_gpio/output_files/ghrd_10as066n2.sof This can be achieved by running the following commands from the Embedded Command Shell: cd quartus_pgm --no_banner --mode=jtag -o "p;a10_soc_devkit_gpio/output_files/ghrd_10as066n2.sof" 2. Connect the USB to serial bridge to the host computer. 3. Connect the USB-BlasterII to the host computer. 4. Install the USB to serial bridge driver on the host computer if that driver is not already present. Consult documentation for the DevKit for instructions on installing the USB to serial bridge driver. 5. Install the USB-BlasterII driver on the host computer if that driver is not already present. Consult documentation for QuartusII for instructions on installing the USB-BlasterII driver. 6. In DS-5, configure the launch configuration. 6a. Select the menu: Run >> Debug Configurations... 6b. In the options on the left, expand "DS-5 Debugger" and select "Altera-SoCFPGA-HardwareLib-GPIO-A10-GNU". 6c. In the "Connections" section near the bottom, click Browse. 6d. Select the appropriate USB-BlasterII to use. Multiple items will be presented if there is more than one USB-BlasterII connection attached to the host computer. 6e. Click "Apply" then "OK" to apply the USB-BlasterII selection. 6f. Click "Close" to close the Debug Configuration. Otherwise click "Debug" run the example in the debugger. Connecting to the target takes a moment to load the Bootloader, run the Bootloader, load the executable, and run executable. After the debug connection is established, the debugger will pause the execution at the main() function. Users can then set additional break points, step into, step out of, or step one line using the DS-5 debugger. Consult documentation for DS-5 for more information on debugging operations. This demo requires user to trigger the interrupts via HPS Push Buttons to drive the HPS LEDs. Press HPS Push Button 3: HPS LED 3 will blink at 500ms interval and then turn off ===== Sample output INFO: System Initialization. INFO: Init GPIO module. INFO: Setting up GPIO interrupt. INFO: Set up GPIO for LEDs. INFO: Set up GPIO for Push button. INFO: Register interrupt handler. INFO: Press HPS_PB_USER_3: HPS LEDs blink. INFO: HPS_PB_USER_3 was pushed. INFO: System uninit. INFO: Cleaning up GPIO interrupt. INFO: GPIO demo exits.