以下是 BSP 示例,看看你的代码少了什么?
void GPIOInterruptTest(void)
{
int i;
sysprintf("Connect GPB2 and GPB0 to test interrupt ......\n");
gpio_setportval(GPIO_PORTB, BIT0, BIT0); /* Set GPB0 output high */
gpio_setportdir(GPIO_PORTB, BIT0, BIT0); /* Set GPB0 output mode */
sysInstallISR(IRQ_LEVEL_7, (INT_SOURCE_E)IRQ_EXTINT0, (PVOID)EXTINT0_IRQHandler);
sysSetInterruptType((INT_SOURCE_E)IRQ_EXTINT0, HIGH_LEVEL_SENSITIVE);
sysEnableInterrupt((INT_SOURCE_E)IRQ_EXTINT0);
gpio_setportdir(GPIO_PORTB, BIT2, 0x0); /* Set GPB2 input mode */
gpio_setportpull(GPIO_PORTB, BIT2, BIT2); /* Set GPB2 pull-high */
gpio_setsrcgrp(GPIO_PORTB, BIT2, 0x0); /* set to IRQ_EXTINT0 */
gpio_setintmode(GPIO_PORTB, BIT2, BIT2, 0); /* Set GPB2 falling edge trigger */
sysSetLocalInterrupt(ENABLE_IRQ);
for(i = 0; i < 2; i++) {
gpio_setportval(GPIO_PORTB, BIT0, BIT0); /* Set GPB0 output high */
sysDelay(50);
gpio_setportval(GPIO_PORTB, BIT0, 0); /* Set GPB0 output low */
sysDelay(50);
}
}
|