at91rm9200的io口電平中斷簡單理解
以PIOB的PB0為例:
#defineLEVEL_IRQ_PIN(0x01<<0)
AT91F_PMC_EnablePeriphClock(AT91C_BASE_PMC,((unsignedint)1
AT91C_ID_PIOB,
1,
AT91C_AIC_SRCTYPE_EXT_POSITIVE_EDGE,
//AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED,//雙邊沿
//AT91C_AIC_SRCTYPE_EXT_HIGH_LEVEL,
//AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE,//
(void(*)(void))piob_interrupt_proc);
{volatiledummy;dummy=AT91C_BASE_PIOB->PIO_ISR;}
AT91F_PIO_InterruptEnable(AT91C_BASE_PIOB,LEVEL_IRQ_PIN);//使能PB0變化中斷
{volatiledummy;dummy=AT91C_BASE_PIOB->PIO_ISR;}
AT91F_AIC_EnableIt(AT91C_BASE_AIC,AT91C_ID_PIOB);//使能PIOB控制器中斷
以上就完成了PB0的上升沿中斷啟動,來看看中斷處理函數(shù)[ads1.2]
void__irq piob_interrupt_proc(void)
{
{volatiledummy;dummy=AT91C_BASE_PIOB->PIO_ISR;}
AT91C_BASE_AIC->AIC_EOICR=0;
if(AT91F_PIO_GetInput(AT91C_BASE_PIOB)&LEVEL_IRQ_PIN)
{
//...1電平
}else
{
//...0電平
}
}
評論