CSL_Status intStat;
CSL_IntcContext gpiocontext;
CSL_IntcEventHandlerRecord isr_gpio;
CSL_IntcEventHandlerRecord record[1];
CSL_IntcGlobalEnableState state;
CSL_IntcParam vectId;
CSL_IntcHandle gpioIntcHandle;
CSL_IntcObj gpioIntcObj;
static void HANDLE_INTR4(void *arg)
{
//中断服务程序
}
//
//=============初始化外部中断4============
//
void InitAndEnableIntc4(void)
{
//初始化
gpiocontext.numEvtEntries = 1;
gpiocontext.eventhandlerRecord = record;
intStat = CSL_intcInit(&gpiocontext);
//使能NMI(不可屏蔽中断)
intStat = CSL_intcGlobalNmiEnable();
//全局中断使能
intStat = CSL_intcGlobalEnable(&state);
//打开中断模块(把GPIO4中断事件映射到系统中断INT4)
vectId = CSL_INTC_VECTID_4;
gpioIntcHandle = CSL_intcOpen(&gpioIntcObj, CSL_INTC_EVENTID_GPINT4, &vectId, &intStat);
//绑定中断服务程序
isr_gpio.handler = (CSL_IntcEventHandler)&HANDLE_INTR4;
CSL_intcPlugEventHandler(gpioIntcHandle, &isr_gpio); //绑定
//使能该事件(开始监听)
CSL_intcHwControl(gpioIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);
}