This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GPIO中断程序无法返回主程序



你好,请教一下GPIO中断程序一直循环等待中断产生,无法返回主程序,怎么解决?可以正常进入中断响应处理函数。代码如下:

void main()
{
gpioInternalLoopbackDemo();/*一直在这里循环等待中断产生,无法返回主程序 */
while(1)
{
//在此加入EDMA传输的数据处理算法,中断响应函数处理完毕无法返回这里
}
}

//中断响应处理函数,开启EDMA数据传输

void HandleGPIO_INT (void *arg)
{
edma_interrupt_example();
intrCnt++;
return;
}

/*一直在这里循环等待中断产生,无法返回主程序 */

void gpioInternalLoopbackDemo (
void
)
{
int i=0,j=0;
CSL_Status intStat;
CSL_GpioPinConfig config;
CSL_GpioPinNum pinNum;
CSL_Status status;
CSL_GpioContext pContext;
CSL_GpioObj gpioObj;
CSL_GpioHwSetup hwSetup;
CSL_IntcGlobalEnableState state;
CSL_IntcParam vectId;
Uint32 loopIndex,evtClr=0;

/* Initialize INTC */
context.numEvtEntries = 1;
context.eventhandlerRecord = record;

intStat = CSL_intcInit(&context);
if (intStat != CSL_SOK) {
printf("INTR: Initialization error.\n");
demoFail++;
return;
}
/* Enable NMIs */
intStat = CSL_intcGlobalNmiEnable();
if (intStat != CSL_SOK) {
printf("INTR: Error while enabling NMI.\n");
demoFail++;
return;
}

/* Enable all interrupts */
intStat = CSL_intcGlobalEnable(&state);
if (intStat != CSL_SOK) {
printf("INTR: Error while enabling interrupt.\n");
demoFail++;
return;
}
/* Open interrupt module */
vectId = CSL_INTC_VECTID_12;

gpioIntcHandle = CSL_intcOpen(&gpioIntcObj, CSL_INTC_EVENTID_GPINT5,
&vectId, &intStat);
if ((gpioIntcHandle == NULL) || (intStat != CSL_SOK)) {
printf("INTR: Error opening the instance.\n");
demoFail++;
return;
}

/* Bind ISR to Interrupt */
isr_gpio.handler = (CSL_IntcEventHandler)&HandleGPIO_INT;
isr_gpio.arg = gpioIntcHandle;
CSL_intcPlugEventHandler(gpioIntcHandle, &isr_gpio);

/* Event Enable */
CSL_intcHwControl(gpioIntcHandle, CSL_INTC_CMD_EVTENABLE, NULL);
if (intStat != CSL_SOK) {
printf("INTR: Error in enabling event.\n");
demoFail++;
return;
}
/* Initialize the GPIO CSL module */
status = CSL_gpioInit(&pContext);
if (status != CSL_SOK) {
printf("GPIO: Initialization error.\n");
demoFail++;
return;
}
/* Open the CSL module */
hGpio = CSL_gpioOpen(&gpioObj, CSL_GPIO, NULL, &status);
if ((hGpio == NULL) || (status != CSL_SOK)) {
printf("GPIO: Error opening the instance.\n");
demoFail++;
return;
}

intrCnt = 0;
/* Setup hardware parameters */
hwSetup.extendSetup = NULL;
/* Setup the General Purpose IO */
status = CSL_gpioHwSetup(hGpio, &hwSetup);
/* Configure pin 5 to generate an interrupt on Rising Edge, and
* configure it as an output, then set the data High (Low->High).
* Set Trigger:
*/
config.pinNum = CSL_GPIO_PIN5;
config.trigger = CSL_GPIO_TRIG_RISING_EDGE;
config.direction = CSL_GPIO_DIR_INPUT;
/* Enable the bank interrupt */
status = CSL_gpioHwControl(hGpio, CSL_GPIO_CMD_BANK_INT_ENABLE, NULL);
if (status != CSL_SOK) {
printf("GPIO: Command to enable bank interrupt... Failed.\n");
demoFail++;
}

/* configure the gpio pin 5 */
status = CSL_gpioHwControl(hGpio, CSL_GPIO_CMD_CONFIG_BIT, &config);
if (status != CSL_SOK) {
printf("GPIO: GPIO pin configuration error.\n");
demoFail++;
return;
}
/* Set Data High: */
/*
pinNum = CSL_GPIO_PIN5;

status = CSL_gpioHwControl (hGpio, CSL_GPIO_CMD_SET_BIT, &pinNum);
if (status != CSL_SOK) {
printf("GPIO: Command to set bit... Failed.\n");
demoFail++;
return;
}
*/
/*一直在这里循环等待中断产生,无法返回主程序 */
while (1) {
if (intrCnt == 1)
break;
}

status = CSL_gpioClose(hGpio);
if (status != CSL_SOK) {
printf("GPIO: Unable to Close the instance.[status = 0x%x].\n", status);
demoFail++;
return;
}
}