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常用命令、函数与运算