ZYNQ中断示例修改
生活随笔
收集整理的这篇文章主要介绍了
ZYNQ中断示例修改
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
说明:在一些Vitis生成的中断示例中,经常会有“xintc”作为中断中断控制器,导致无法直接编译。本文以xuartlite为示例介绍修改过程。
文章目录
- 头文件 Include File
- 常量定义 Constant Definitions
- 变量定义 Variable Definitions
- 中断配置函数
- 原中断配置函数
- 修改后的中断配置函数
- 总结
头文件 Include File
将
#include "xintc.h"修改为
#include "xscugic.h"常量定义 Constant Definitions
将
#define INTC_DEVICE_ID XPAR_INTC_0_DEVICE_ID #define UARTLITE_INT_IRQ_ID XPAR_INTC_0_UARTLITE_0_VEC_ID修改为
#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID #define UARTLITE_INT_IRQ_ID XPAR_FABRIC_AXI_UARTLITE_485_1_INTERRUPT_INTR //注意AXI_UARTLITE_485_1为我用的IP核的名称变量定义 Variable Definitions
将
XIntc InterruptController; /* The instance of the Interrupt Controller */修改为
XScuGic InterruptController; /* The instance of the Interrupt Controller */中断配置函数
原中断配置函数
代码如下:
int SetupInterruptSystem(XUartLite *UartLitePtr) {int Status;/** Initialize the interrupt controller driver so that it is ready to* use.*/Status = XIntc_Initialize(&InterruptController, INTC_DEVICE_ID);if (Status != XST_SUCCESS) {return XST_FAILURE;}/** Connect a device driver handler that will be called when an interrupt* for the device occurs, the device driver handler performs the* specific interrupt processing for the device.*/Status = XIntc_Connect(&InterruptController, UARTLITE_INT_IRQ_ID,(XInterruptHandler)XUartLite_InterruptHandler,(void *)UartLitePtr);if (Status != XST_SUCCESS) {return XST_FAILURE;}/** Start the interrupt controller such that interrupts are enabled for* all devices that cause interrupts, specific real mode so that* the UartLite can cause interrupts through the interrupt controller.*/Status = XIntc_Start(&InterruptController, XIN_REAL_MODE);if (Status != XST_SUCCESS) {return XST_FAILURE;}/** Enable the interrupt for the UartLite device.*/XIntc_Enable(&InterruptController, UARTLITE_INT_IRQ_ID);/** Initialize the exception table.*/Xil_ExceptionInit();/** Register the interrupt controller handler with the exception table.*/Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,(Xil_ExceptionHandler)XIntc_InterruptHandler,&InterruptController);/** Enable exceptions.*/Xil_ExceptionEnable();return XST_SUCCESS; }修改后的中断配置函数
代码如下:
int SetupInterruptSystem(XUartLite *UartLitePtr) {int Status;XScuGic_Config *IntcConfig;/** Initialize the interrupt controller driver so that it is ready to* use.*/IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);if (NULL == IntcConfig) {return XST_FAILURE;}Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,IntcConfig->CpuBaseAddress);if (Status != XST_SUCCESS) {return XST_FAILURE;}XScuGic_SetPriorityTriggerType(&InterruptController, UARTLITE_INT_IRQ_ID, 0xA0, 0x3);/** Connect a device driver handler that will be called when an interrupt* for the device occurs, the device driver handler performs the* specific interrupt processing for the device.*/Status = XScuGic_Connect(&InterruptController, UARTLITE_INT_IRQ_ID,(Xil_InterruptHandler)XUartLite_InterruptHandler,(void *)UartLitePtr);if (Status != XST_SUCCESS) {return XST_FAILURE;}/** Enable the interrupt for the UartLite device.*/XScuGic_Enable(&InterruptController, UARTLITE_INT_IRQ_ID);/** Initialize the exception table.*/Xil_ExceptionInit();/** Register the interrupt controller handler with the exception table.*/Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,(Xil_ExceptionHandler)XScuGic_InterruptHandler,&InterruptController);/** Enable exceptions.*/Xil_ExceptionEnable();return XST_SUCCESS; }经过以上修改,编译正常,测试完毕。
总结
xIntc其实就是代替了XScuGic,只要换成对应名称的常量、变量等一般就可以解决这个问题。
总结
以上是生活随笔为你收集整理的ZYNQ中断示例修改的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: AXI quad SPI没有输出
- 下一篇: MATLAB常用命令、函数与运算