//配置uPP的中断 void upp_intc_setup_my(int (*isr)(void *)) { //初始化开始 intcContext_uPP.eventhandlerRecord = EventHandler_uPP; //事件句柄记录指针 intcContext_uPP.numEvtEntries = 50; //事件入口数目 CSL_intcInit(&intcContext_uPP); //初始化中断上下文对象变量,返回状态CSL_SOK // Enable NMIs使能非可屏蔽中断 CSL_intcGlobalNmiEnable(); //Enable global interrupts使能全局中断 CSL_intcGlobalEnable(&intc_state_uPP); /***************** interrupt configration for UPP接口 **************************/ /* open CPINTC0 to map the UPP completetion ISR event to the host interrupt */ hnd_UPP = CSL_CPINTC_open(0); if (hnd_UPP == 0) { printf ("Error: Unable to open CPINTC-1\n"); return; } glbCpintcHnd[2] = (CSL_CPINTC_RegsOvly)hnd_UPP; //需要根据应用修改UPP产生的事件编号及CPINTC输出channel号 CSL_CPINTC_mapSystemIntrToChannel (hnd_UPP, CSL_INTC0_RPINT, 9); CSL_CPINTC_enableSysInterrupt (hnd_UPP, CSL_INTC0_RPINT); CSL_CPINTC_enableHostInterrupt (hnd_UPP, 9); CSL_CPINTC_enableAllHostInterrupt(hnd_UPP); vectId_uPP = CSL_INTC_VECTID_4; hIntcUpp= CSL_intcOpen (&intcObjUpp, CSL_GEM_INTC0_OUT_9_PLUS_20_MUL_N, &vectId_uPP , NULL); gpioHandler.handler = (CSL_IntcEventHandler)&upp_isr;//事件句柄指针 gpioHandler.arg = 0; //传递给参数的句柄指针 CSL_intcPlugEventHandler(hIntcUpp, &gpioHandler); //建立事件和句柄的映射关系 CSL_intcHwControl(hIntcUpp,CSL_INTC_CMD_EVTCLEAR,NULL); CSL_intcHwControl(hIntcUpp, CSL_INTC_CMD_EVTENABLE, NULL); /***************** interrupt configration for UPP接口 **************************/ }
/* * ============================================================================= * @func IntcInit * * @arg * NONE * * @desc * 初始化中断 * * @return * NONE * * ============================================================================= */ void IntcInit() { /*初始化开始*/ intcContext_uPP.eventhandlerRecord = EventHandler_uPP; //事件句柄记录指针 intcContext_uPP.numEvtEntries = 50; //事件入口数目 /* 初始化结束,前面的初始化过程只需要一次,如果需要增加中断处理,直接添加中断矢量 和事件号即可,无需再次初始化,否则会覆盖掉前面的配置(包括事件和其中断服务程序的映射表等)*/ /*初始化中断上下文对象变量,返回状态CSL_SOK*/ CSL_intcInit(&intcContext_uPP); /*使能非可屏蔽中断*/ CSL_intcGlobalNmiEnable(); /*使能全局中断*/ CSL_intcGlobalEnable(&intc_state_uPP); if(coreNum == 0) { /************************ 1.中断配置-----收图 **************************/ ///////////////////////////第一步:EDMACC_GINT事件作为system interrupt通过CPINTC映射到host interrupt//////////// /* open CPINTC0 to map the EDMA completetion ISR event to the host interrupt */ hnd_EDMA_uPP = CSL_CPINTC_open(0); if (hnd_EDMA_uPP == 0) { printf ("Error: Unable to open CPINTC-1\n"); return; } glbCpintcHnd[1] = (CSL_CPINTC_RegsOvly)hnd_EDMA_uPP; //需要根据应用修改EDMA产生的事件编号及CPINTC输出channel号 //tms320c6657.pdf中"EDMA产生的事件编号"对应"CIC0 Event Inputs的22号",System Event Mapping的CIC0_OUT(8+20*n)的"8"为host interrupt CSL_CPINTC_mapSystemIntrToChannel (hnd_EDMA_uPP, CSL_INTC0_CPU_3_2_EDMACC_GINT, 8);//system interrupt maping to host interrupt CSL_CPINTC_enableSysInterrupt (hnd_EDMA_uPP, CSL_INTC0_CPU_3_2_EDMACC_GINT); CSL_CPINTC_enableHostInterrupt (hnd_EDMA_uPP, 8); CSL_CPINTC_enableAllHostInterrupt(hnd_EDMA_uPP); /***************** interrupt configration for EDMA completed ***************/ //////////////////////////////////////第二步:host interrupt号转换为Event ID号,并绑定中断向量号///////////////////////// /* Opening a intc handle for edma event */ vectId_uPP = CSL_INTC_VECTID_7; //打开中断向量句柄,建立事件与中断之间的映射关系 //CSL_GEM_INTC0_OUT_8_PLUS_20_MUL_N 即CIC0_OUT(8+20*n)中8+20*n为Event ID hIntcEdma_uPP = CSL_intcOpen (&intcObjEdma_uPP, CSL_GEM_INTC0_OUT_8_PLUS_20_MUL_N, \ &vectId_uPP , NULL); /* Association of an EDMA event handler with the INTC routine 关联EDMA事件句柄到INTC程序*/ EventRecord_uPP.handler = &eventEdmaHandler;//EDMA事件句柄指针 EventRecord_uPP.arg = (void*)(hModule_uPP);//hModule_uPP是EMDA通道句柄 CSL_intcPlugEventHandler(hIntcEdma_uPP,&EventRecord_uPP); //建立事件和句柄的映射关系 CSL_intcHwControl(hIntcEdma_uPP,CSL_INTC_CMD_EVTCLEAR,NULL); /* Enabling event edma 使能EDMA收图完成中断 */ CSL_intcHwControl(hIntcEdma_uPP,CSL_INTC_CMD_EVTENABLE,NULL); /* Hook up the EDMA event with an completion code function handler */ EdmaEventHook(CSL_EDMA3_CHA_GPINT0, ImgEDMARecCompleted_INT);//收图完成中断 /***************** interrupt configration for EDMA completed ***************/ /*****************2.中断配置-----UPP接口 **************************/ ////////////////////////////////////////////////用来与FPGA通信,接收图像////////////////////////////////////////////////////////////////// /* open CPINTC0 to map the UPP completetion ISR event to the host interrupt */ hnd_UPP = CSL_CPINTC_open(0); if (hnd_UPP == 0) { printf ("Error: Unable to open CPINTC-1\n"); return; } glbCpintcHnd[2] = (CSL_CPINTC_RegsOvly)hnd_UPP; //需要根据应用修改UPP产生的事件编号及CPINTC输出channel号 //CSL_INTC0_RPINT为upp的system interrupt ,9为CIC0_OUT(9+20*n)中的host interrupt CSL_CPINTC_mapSystemIntrToChannel (hnd_UPP, CSL_INTC0_RPINT, 9); CSL_CPINTC_enableSysInterrupt (hnd_UPP, CSL_INTC0_RPINT); CSL_CPINTC_enableHostInterrupt (hnd_UPP, 9); CSL_CPINTC_enableAllHostInterrupt(hnd_UPP); vectId_uPP = CSL_INTC_VECTID_4; //绑定中断向量,即host interrupt转换为event id之后进入INTC绑定vectId_uPP hIntcUpp= CSL_intcOpen (&intcObjUpp, CSL_GEM_INTC0_OUT_9_PLUS_20_MUL_N, &vectId_uPP , NULL); gpioHandler.handler = (CSL_IntcEventHandler)&upp_isr;//事件句柄指针 gpioHandler.arg = 0; //传递给参数的句柄指针 CSL_intcPlugEventHandler(hIntcUpp, &gpioHandler); //建立事件和句柄的映射关系 CSL_intcHwControl(hIntcUpp,CSL_INTC_CMD_EVTCLEAR,NULL); CSL_intcHwControl(hIntcUpp, CSL_INTC_CMD_EVTENABLE, NULL); /***************** interrupt configration for UPP接口 **************************/ } }
BOOL Intr_Init(Intr *pThis, IntrItem eIntrItem, Intr_Handler pfnIntr_Handler, VOID *pIntrHandlerArg) //(*pIntr_Handler)(void *),\ { //CSL_Status intStat; //guru:may be not required for C6678 #if 1 //Initialize Global interrupts //Intr_EnableGlobalInterrupts(); Hwi_enable(); #endif //Initialize Global interrupts //CSL_intcGlobalEnable(NULL); //Get the values from Interrupt Table DataBase IntrDB_GetIntrTableParam(&pThis->oIntrTableParam, eIntrItem); Hwi_Params_init(&pThis->oHwi); Error_init(&pThis->eb); //Check whether the Interrupt source uses CIC Module if(pThis->oIntrTableParam.bCicRequired == TRUE) { /* Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */ CpIntc_dispatchPlug(pThis->oIntrTableParam.SysInt,(ti_sysbios_family_c66_tci66xx_CpIntc_FuncPtr) pfnIntr_Handler, (xdc_UArg)pIntrHandlerArg, FALSE); /* The configuration is for CPINTC0. We map system interrupt 112 to Host Interrupt 8. */ CpIntc_mapSysIntToHostInt(0,pThis->oIntrTableParam.SysInt,pThis->oIntrTableParam.HostInt ); /* Get the event id associated with the host interrupt. */ pThis->oHwi.eventId = CpIntc_getEventId(pThis->oIntrTableParam.HostInt); pThis->oHwi.arg = pThis->oIntrTableParam.HostInt; pThis->oHwi.maskSetting = Hwi_MaskingOption_NONE; //pThis->oHwi.priority = 3; pThis->oHwiHandle = Hwi_create((Int)pThis->oIntrTableParam.eIntcVectorId, (Hwi_FuncPtr)CpIntc_dispatch, &pThis->oHwi, &pThis->eb);// SYSBIOS API if(pThis->oHwiHandle==NULL) { #ifdef DEBUG LOG_TRACE0("INTR: Hwi not created ... Failed.\n"); #endif } } else { pThis->oHwi.eventId=pThis->oIntrTableParam.nIntcEventId; pThis->oHwi.maskSetting = Hwi_MaskingOption_NONE; //pThis->oHwi.priority = 3; //register the argument to be passed with the ISR pThis->oHwi.arg = (UArg)pIntrHandlerArg; pThis->oHwiHandle = Hwi_create((Int)pThis->oIntrTableParam.eIntcVectorId, (Hwi_FuncPtr)pfnIntr_Handler, &pThis->oHwi, &pThis->eb);// SYSBIOS API if(pThis->oHwiHandle==NULL) { #ifdef DEBUG LOG_TRACE0("INTR: Hwi not created ... Failed.\n"); #endif } } #ifdef _STE_APP //Initialize the oHwi object #endif #ifdef _STE_BOOT //Csl APIs or Hooking the Interrupt Event pThis->oIntcHandle = CSL_intcOpen (&pThis->oIntcObj, pThis->oIntrTableParam.nIntcEventId, &pThis->oIntrTableParam.eIntcVectorId, NULL); if ((pThis->oIntcHandle == NULL)) { #ifdef DEBUG printf ("INTR: Open... Failed.\n"); printf ("hIntc = 0x%x]\n", pThis->oIntcHandle); #endif } else { #ifdef DEBUG printf ("INTR: Open... Passed.\n"); #endif } pThis->oEventRecord.handler = (CSL_IntcEventHandler)pfnIntr_Handler; pThis->oEventRecord.arg = pIntrHandlerArg; CSL_intcPlugEventHandler(pThis->oIntcHandle, &pThis->oEventRecord); #endif return TRUE; }