日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ZYNQ中断示例修改

發(fā)布時間:2024/10/14 63 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ZYNQ中断示例修改 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

說明:在一些Vitis生成的中斷示例中,經(jīng)常會有“xintc”作為中斷中斷控制器,導致無法直接編譯。本文以xuartlite為示例介紹修改過程。

文章目錄

  • 頭文件 Include File
  • 常量定義 Constant Definitions
  • 變量定義 Variable Definitions
  • 中斷配置函數(shù)
    • 原中斷配置函數(shù)
    • 修改后的中斷配置函數(shù)
  • 總結(jié)


頭文件 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 */

中斷配置函數(shù)

原中斷配置函數(shù)

代碼如下:

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; }

修改后的中斷配置函數(shù)

代碼如下:

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; }

經(jīng)過以上修改,編譯正常,測試完畢。


總結(jié)

xIntc其實就是代替了XScuGic,只要換成對應(yīng)名稱的常量、變量等一般就可以解決這個問題。

總結(jié)

以上是生活随笔為你收集整理的ZYNQ中断示例修改的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。