日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ZYNQ中断示例修改

發布時間:2024/10/14 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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中断示例修改的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。