对于AXI Interconnect的输出引脚,双击进行配置
SDK中的配置,关闭CPU 和 DDR中间的缓存
Xil_DCacheFlushRange(0x01000000 & 0xffffffc0,640*480);
gic中断设置 gic_intr.c
1 #include "gic_intr.h" 2 3 int Gic_init(XScuGic *GicPtr,XScuGic_Config *GicCfgPtr,u16 DeviceId) 4 { 5 int status; 6 Xil_ExceptionInit(); 7 GicCfgPtr = XScuGic_LookupConfig(DeviceId); 8 status = XScuGic_CfgInitialize(GicPtr,GicCfgPtr,GicCfgPtr->CpuBaseAddress); 9 if(status != XST_SUCCESS) 10 { 11 return status; 12 } 13 Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,(Xil_ExceptionHandler)XScuGic_InterruptHandler,GicPtr); 14 15 Xil_ExceptionEnable(); 16 return XST_SUCCESS; 17 } 18 19 void IntcTypeSetup(XScuGic *InstancePtr, int intId, int intType) 20 { 21 int mask; 22 23 intType &= INT_TYPE_MASK; 24 mask = XScuGic_DistReadReg(InstancePtr, INT_CFG0_OFFSET + (intId/16)*4); 25 mask &= ~(INT_TYPE_MASK << (intId%16)*2); 26 mask |= intType << ((intId%16)*2); 27 XScuGic_DistWriteReg(InstancePtr, INT_CFG0_OFFSET + (intId/16)*4, mask); 28 }
gic_intr.h
1 #ifndef _GIC_INTR_H_ 2 #define _GIC_INTR_H_ 3 4 #include <stdio.h> 5 #include "xil_printf.h" 6 #include "xscugic.h" 7 #include "xparameters.h" 8 9 #define GIC_DEVICE_ID XPAR_PS7_SCUGIC_0_DEVICE_ID 10 11 XScuGic GicPtr; 12 XScuGic_Config *GicCfgPtr; 13 14 #define INT_TYPE_RISING_EDGE 0x03 15 #define INT_TYPE_HIGHLEVEL 0x01 16 #define INT_TYPE_MASK 0x03 17 18 #define INT_CFG0_OFFSET 0x00000C00 19 20 int Gic_init(XScuGic *GicPtr,XScuGic_Config *GicCfgPtr,u16 DeviceId); 21 void IntcTypeSetup(XScuGic *InstancePtr, int intId, int intType); 22 23 #endif /* _GIC_INTR_H_ */
interrupt.c
1 #include "interrupt.h" 2 3 4 int initIntr() 5 { 6 int status; 7 //全局中断初始化 8 status = Gic_init(&GicPtr,GicCfgPtr,GIC_DEVICE_ID); 9 //pl中断 10 status = XScuGic_Connect(&GicPtr,F2P_INTR0_ID,(Xil_ExceptionHandler)f2pIntr0Handler,&GicPtr); 11 IntcTypeSetup(&GicPtr, F2P_INTR0_ID, INT_TYPE_RISING_EDGE); 12 XScuGic_Enable(&GicPtr, F2P_INTR0_ID); 13 14 return status; 15 }
interrupt.h
1 #ifndef _INTERRUPT_H_ 2 #define _INTERRUPT_H_ 3 4 5 #include <stdio.h> 6 #include "xscugic.h" 7 #include "xparameters.h" 8 #include "xil_mmu.h" 9 #include "xil_types.h" 10 11 #include "gic_intr.h" 12 #include "pl_intr.h" 13 14 int initIntr();
pl_intr.c
1 #include "pl_intr.h" 2 #include "xil_printf.h" 3 4 void f2pIntr0Handler(void * callbackref) 5 { 6 static i = 0 ; 7 printf("i = %d \n\r",i++); 8 }
pl_intr.h
1 #ifndef _PL_INTR_H_ 2 #define _PL_INTR_H_ 3 4 #include "xil_printf.h" 5 #include <stdio.h> 6 7 #define F2P_INTR0_ID 61 8 9 #define CPU_AXI_LITE_W(BaseAddress, RegOffset, Data) Xil_Out32((BaseAddress) + (RegOffset), (u32)(Data)) 10 #define CPU_AXI_LITE_R(BaseAddress, RegOffset) Xil_In32((BaseAddress) + (RegOffset)) 11 12 void f2pIntr0Handler(void * callbackref);//行中断 13 14 15 #endif /* _PL_INTR_H_ */
注意这里使用自定义的axi_dma.v导入的数据顺序和使用VDMA导入的数据存在区别