程序如下:
static void SetInterrupt()
{
// CSL_GpioHandle hGpio;
Error_Block eb;
Hwi_Params hwiParams;
Hwi_Handle hwi0;
int sysInterrupt=0;
System_printf("enter main()\n");
System_flush();
// Open the CSL GPIO Module 0
hGpio = CSL_GPIO_open (0);
KICK0 = 0x83e70b13;
KICK1 = 0x95a4f1e0;
PIN_CONTROL_0 = 0xFFFF0000;
CSL_GPIO_setPinDirInput ( hGpio, 16) ; //set pin as input
CSL_GPIO_setRisingEdgeDetect (hGpio, 16); // Set interrupt detection on GPIO pin 1 to rising edge
CSL_GPIO_bankInterruptEnable (hGpio, 1);
// Enable GPIO per bank interrupt for bank zero
//chip-level INTC0 is for corepac0~1
hnd = CSL_CPINTC_open(0);
if (! hnd) {
return;
}
//disable all host interrupt
CSL_CPINTC_disableAllHostInterrupt(hnd);
//configure no nesting support in the cpintc module
CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);
CSL_CPINTC_clearSysInterrupt (hnd, 0);
//enable system interrupt 0
CSL_CPINTC_enableSysInterrupt (hnd, 0);
//map system interrupt 0(gpio16 gpint) to host interrupt 1
CSL_CPINTC_mapSystemIntrToChannel (hnd, 0, 1);
//enable host interrupt 1
CSL_CPINTC_enableHostInterrupt (hnd, 1);
//enable all host interrupts
CSL_CPINTC_enableAllHostInterrupt(hnd);
Error_init(&eb);
Hwi_Params_init(&hwiParams);
hwiParams.eventId = 23;
// params.eventId = 86;
// hwiParams.enableInt = 1;
// params.arg = sysInterrupt;
hwiParams.enableInt = 1;
hwiParams.arg = 1;
hwiParams.priority =1;
hwi0=Hwi_create(4, (ti_sysbios_hal_Hwi_FuncPtr) &hwiFunc, &hwiParams, &eb);
// hwiParams.enableInt = 1;
if(hwi0==NULL)
{
System_abort("Hwi create failed");
}
}
void hwiFunc(UArg sysInterrupt)
{
// CSL_CPINTC_disableHostInterrupt(hnd, 1);
// CSL_CPINTC_clearSysInterrupt(hnd, sysInterrupt);
flag = 1;
// CSL_CPINTC_enableHostInterrupt(hnd, 1);
}
如果不用CSL,该怎么写
Allen35065:
CSL和BIOS的中断控制器不能同时使用;BIOS的就直接在BIOS的配置界面进行配置即可。