我只设置GPIO6[1]为上升沿中断,但在下降沿时也会产生中断,而且一次中断会进入两次中断服务函数,求解答? 谢谢!
// The gpioPin number starts from 1; // bankNum = 0~8; pinNum = 0~15;
#define GPIO_PIN(bankNum, pinNum) (bankNum * 16 + pinNum + 1)
中断服务函数:
void gpioInputIsr(Ptr ignore)
{
Gpio_PinCmdArg pinCmdArg;
UInt32 tempVal = 0x00;
Gpio_IntrStatus intrStatus;
/* To avoid compiler warnings */
ignore = ignore;
intrStatus.bank = BANK6;
tempVal = Gpio_readBankInterruptStatus(gpio0, &intrStatus);
//printf ("\nBefore Clearing, IntrStatus – %d", intrStatus.value);
/* Clear the interrupt status */
pinCmdArg.pin = GPIO_PIN(BANK6, PIN1);
Gpio_clearInterruptStatus(gpio0, &pinCmdArg);
//tempVal = Gpio_readBankInterruptStatus(gpio0, &intrStatus);
//printf ("\nAfter Clearing, IntrStatus – %d", intrStatus.value);
}
中断初始化:
void gpioInterruptInit(void)
{
Gpio_IntrCmdArg intrCmdArg;
/* Enable GPIO Bank interrupt for bank GPIO_BANK_6 */
Gpio_bankInterruptEnable(gpio0, BANK6);
/* Configure GPIO(GPIO6_1_PIN) to generate interrupt on rising edge */
Gpio_setRisingEdgeTrigger(gpio0, GPIO_PIN(BANK6, PIN1));
/* Set the interrupt handler for GPIO6_1_PIN. However we cannot register *
* interrupts for individual pins in C6748, therefore register interrupt *
* for the associated bank(BANK6) as a whole */
intrCmdArg.value = BANK6;
intrCmdArg.bankOrPin = Gpio_BankOrPin_isBank;
intrCmdArg.isrHandler = (Gpio_Isr)gpioInputIsr;
Gpio_regIntHandler(gpio0, &intrCmdArg);
}
Tony Tang:
请问你是如何触发的?GPIO上是否有抖动,这是我常见的这类情况。