/* * gpio_intr_initial.c * * Created on: 2016-1-13 * Author: Administrator */ /* * gpio_intr_initial.c * * Created on: 2016-1-13 * Author: Milinker Xu */ #include "gpio_intr.h" void intr_Init(XIntc *IntcInstancePtr, u16 DeviceId) { XIntc_Initialize(IntcInstancePtr, DeviceId);//初始化中断 XIntc_Enable(&Intc,XPAR_INTC_0_GPIO_0_VEC_ID);;//使能中断 Xil_ExceptionInit(); //外设初始化 Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_InterruptHandler,IntcInstancePtr); Xil_ExceptionEnable(); XIntc_Start(IntcInstancePtr, XIN_REAL_MODE);//启动中断 } void GPIO_Init(XIntc* IntcInstancePtr,XGpio* GpioInstancePtr,u16 DeviceId,u16 IntrId) { /* 初始化GIPO*/ XGpio_Initialize(GpioInstancePtr, DeviceId); XIntc_Connect(IntcInstancePtr, IntrId,(XInterruptHandler)gpio_intr_handler, GpioInstancePtr); XGpio_InterruptEnable(GpioInstancePtr, 1); XGpio_InterruptGlobalEnable(GpioInstancePtr); } void gpio_intr_initial(void) { intr_Init(&Intc,XPAR_INTC_0_DEVICE_ID); GPIO_Init(&Intc,&Gpio,XPAR_BUTTOM_DEVICE_ID,XPAR_INTC_0_GPIO_0_VEC_ID); } |