| intc Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xintc_example.c File Reference

## Overview

This file contains a design example using the Interrupt Controller driver (XIntc) and hardware device.

Please reference other device driver examples to see more examples of how the intc and interrupts can be used by a software application.

This example shows the use of the Interrupt Controller both with a PowerPC and MicroBlaze processor.

Note
  This example can also be used for Cascade mode interrupt controllers by using the interrupt IDs generated in xparameters.h. For Cascade mode, Interrupt IDs are generated in xparameters.h as shown below:

Master/Primary INTC

| |-0 Secondary INTC | |-. ______ | |-. | |-32 Last INTC | |-. | |-. ______ |______|<–31--—| |-. | |-64 | |-. | |-. |______|<–63---—| |-. | |-. |______|-95

All driver functions has to be called using DeviceId/InstancePtr of Primary/Master Controller only. Driver functions takes care of Slave Controllers based on Interrupt ID passed. User must not use Interrupt source/ID 31 of Primary and Secondary controllers to call driver functions.

    MODIFICATION HISTORY:
    Ver   Who  Date  Changes

    1.00b jhl  02/13/02 First release
    1.00c rpm  11/13/03 Updated to show microblaze and PPC interrupt use and
                  to use the common L0/L1 interrupt handler with device ID.
    1.00c sv   06/29/05 Minor changes to comply to Doxygen and coding guidelines
    2.00a ktn  10/20/09 Updated to use HAL Processor APIs amd minor modifications
                  as per coding guidelines.
    3.6   ms   01/23/17 Added xil_printf statement in main function to
                        ensure that "Successfully ran" and "Failed" strings
                        are available in all examples. This is a fix for
                        CR-965028.

## Functions
int | IntcExample (u16 DeviceId)
| This function is an example of how to use the interrupt controller driver component (XIntc) and the hardware device. More...
int | SetUpInterruptSystem (XIntc *XIntcInstancePtr)
| This function connects the interrupt handler of the interrupt controller to the processor. More...
void | DeviceDriverHandler (void *CallbackRef)
| This function is designed to look like an interrupt handler in a device driver. More...
int | main (void)
| This is the main function for the Interrupt Controller example. More...

## Function Documentation

void DeviceDriverHandler | ( | void * | CallbackRef | ) |

This function is designed to look like an interrupt handler in a device driver.

This is typically a 2nd level handler that is called from the interrupt controller interrupt handler. This handler would typically perform device specific processing such as reading and writing the registers of the device to clear the interrupt condition and pass any data to an application using the device driver. Many drivers already provide this handler and the user is not required to create it.

Parameters

  CallbackRef | is passed back to the device driver's interrupt handler by the XIntc driver. It was given to the XIntc driver in the XIntc_Connect() function call. It is typically a pointer to the device driver instance variable if using the Xilinx Level 1 device drivers. In this example, we do not care about the callback reference, so we passed it a 0 when connecting the handler to the XIntc driver and we make no use of it here.

Returns
  None.

Note
  None.

This is typically a 2nd level handler that is called from the interrupt controller interrupt handler. This handler would typically perform device specific processing such as reading and writing the registers of the device to clear the interrupt condition and pass any data to an application using the device driver.

Parameters

  CallbackRef | is passed back to the device driver's interrupt handler by the XIntc driver. It was given to the XIntc driver in the XIntc_Connect() function call. It is typically a pointer to the device driver instance variable if using the Xilinx Level 1 device drivers. In this example, we do not care about the callback reference, so we passed it a 0 when connecting the handler to the XIntc driver and we make no use of it here.

Returns
  None.

Note
  None.

Referenced by IntcLowLevelExample(), and SetUpInterruptSystem().

int IntcExample | ( | u16 | DeviceId | ) |

This function is an example of how to use the interrupt controller driver component (XIntc) and the hardware device.

This function is designed to work without any hardware devices to cause interrupts. It may not return if the interrupt controller is not properly connected to the processor in either software or hardware.

This function relies on the fact that the interrupt controller hardware has come out of the reset state such that it will allow interrupts to be simulated by the software.

Parameters

  DeviceId | is Device ID of the Interrupt Controller Device, typically XPAR_<INTC_instance>_DEVICE_ID value from xparameters.h.

Returns
  XST_SUCCESS to indicate success, otherwise XST_FAILURE.

Note
  None.

References SetUpInterruptSystem(), XIntc_Initialize(), XIntc_SelfTest(), and XIntc_SimulateIntr().

Referenced by main().

int main | ( | void |  | ) |

This is the main function for the Interrupt Controller example.

Parameters

  None. |

Returns
  XST_SUCCESS to indicate success, otherwise XST_FAILURE.

Note
  None.

References IntcExample().

int SetUpInterruptSystem | ( | XIntc * | XIntcInstancePtr | ) |

This function connects the interrupt handler of the interrupt controller to the processor.

This function is separate to allow it to be customized for each application. Each processor or RTOS may require unique processing to connect the interrupt handler.

Parameters

  None. |

Returns
  None.

Note
  None.

References DeviceDriverHandler(), XIN_SIMULATION_MODE, XIntc_Connect(), XIntc_Enable(), XIntc_InterruptHandler(), and XIntc_Start().

Referenced by IntcExample().