Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

9.2.1.5. Supporting Multiple Interrupt APIs

When you write or update a custom device driver, Intel FPGA recommends that you write it in one of two ways:
  • Write it to support the enhanced HAL interrupt API—Write the driver this way if you intend to use it only in combination with other drivers supporting the enhanced API.
  • Write it to support both the enhanced and the legacy API—Write the driver this way if you need to use it in combination with legacy drivers supporting only the legacy API.
Note: Intel FPGA recommends using the enhanced API even if your Nios® II processor implements the IIC. The enhanced API supports both types of interrupt controller, and the legacy API is deprecated.

When the SBT selects the interrupt API, it defines one of the following symbols in system.h, to identify which interrupt API is available:

  • ALT_ENHANCED_INTERRUPT_API_PRESENT—Defined if the enhanced API is implemented
  • ALT_LEGACY_INTERRUPT_API_PRESENT—Defined if the legacy API is implemented

In your driver code, use these symbols to determine which API calls to make.

To support both APIs, your driver must publish its interrupt API support by way of a software property. In your driver’s <driver name>_sw.tcl file, use the set_sw_property command to set supported_interrupt_apis to both legacy_interrupt_api and enhanced_interrupt_api.

For more information about the set_sw_property command, refer to the “Software Build Tools Tcl Commands” section of the " Nios® II Software Build Tools Reference" section.