#include "xparameters.h"
#include "mb_interface.h"
#include "xintc.h"
#include "xgpio_l.h"
#include "xgpio.h"
#include "xio.h"
#include
XGpio GPIO_DPD_START ;
XGpio GPIO_DPD_BRAM_START ;
static XIntc InterruptController; /* Instance of the Interrupt Controller */
void GpioHandler1(void *CallbackRef )
{
XGpio *GpioPtr = (XGpio *)CallbackRef ;
xil_printf("GPIO LED Interrupt Occur\n\r");
XGpio_InterruptClear(GpioPtr, 1);
}
void GpioHandler0(void *CallbackRef )
{
XGpio *GpioPtr = (XGpio *)CallbackRef ;
xil_printf("GPIO ise Interrupt Occur\n\r");
XGpio_InterruptClear(GpioPtr, 1);
}
void init_sys( )
{
int Mystatus;
Mystatus = XIntc_Initialize(&InterruptController, XPAR_AXI_INTC_0_DEVICE_ID);
Mystatus=XGpio_Initialize(&GPIO_DPD_START,
XPAR_LED_DEVICE_ID);
Mystatus=XGpio_Initialize(&GPIO_DPD_BRAM_START,
XPAR_ISE_IN_DEVICE_ID);
XGpio_SetDataDirection( &GPIO_DPD_BRAM_START , 1, 0x1 );
XGpio_SetDataDirection( &GPIO_DPD_START , 1, 0x0 );
Mystatus = XIntc_Connect(&InterruptController, XPAR_INTC_0_GPIO_1_VEC_ID,
(XInterruptHandler)GpioHandler1, &GPIO_DPD_START);
Mystatus = XIntc_Connect(&InterruptController, XPAR_INTC_0_GPIO_0_VEC_ID,
(XInterruptHandler)GpioHandler0, &GPIO_DPD_BRAM_START);
XIntc_Enable(&InterruptController, XPAR_INTC_0_GPIO_1_VEC_ID);
XIntc_Enable(&InterruptController, XPAR_INTC_0_GPIO_0_VEC_ID);
XGpio_InterruptEnable ( &GPIO_DPD_START, 1);
XGpio_InterruptEnable ( &GPIO_DPD_BRAM_START, 1);
XGpio_InterruptGlobalEnable(&GPIO_DPD_BRAM_START);
XGpio_InterruptGlobalEnable(&GPIO_DPD_START);
}
int main()
{
int i;
microblaze_enable_interrupts();
init_sys( );
xil_printf("Test Oct.2012 1:55\n\r");
while(1)
return 0;
}
注http://ifpga.5d6d.net/thread-461-1-1.html也由我开办
文章评论(0条评论)
登录后参与讨论