|
(灯)LED 与PA相连 按钮(SW,一共四个按钮)与PB 相连
#define LED_MASK (LED1|LED2|LED3|LED4)
#define SW_MASK (SW1_MASK|SW2_MASK|SW3_MASK|SW4_MASK|SW5_MASK)
高手帮我看看,为什么我按了SW4 ,没有反映呀(好像进不了中断呀)
#include "Board.h"
__ramfunc void aic_software_interrupt(void)
{
//* Read the output state
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED2 ) == LED2 )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED2 );
}
else
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED2 );
}
}
__ramfunc void pio_c_irq_handler ( void )
{
int dummy;
//* Read the output state
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED4 ) == LED4 )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED4);
}
else
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED4);
}
//* enable the next PIO IRQ
dummy =AT91C_BASE_PIOA->PIO_ISR;
//* suppress the compilation warning
dummy =dummy;
//* while SW3 is push wait
while ( (AT91F_PIO_GetInput(AT91C_BASE_PIOB) & SW3_MASK ) != SW3_MASK );
}
int main( void )
//* Begin
{
unsigned int loop_count ;
AT91PS_AIC pAic;
pAic = AT91C_BASE_AIC;
loop_count = 0 ;
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ;
AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LED_MASK ) ;
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_MASK ) ;
//* open external PIO interrupt
//* define switch SW3 at PIO input for interrupt IRQ loop
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOB ) ;
AT91F_PIO_CfgInput(AT91C_BASE_PIOB, SW3_MASK | SW4_MASK);
AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_PIOB,PIO_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_POSITIVE_EDGE , pio_c_irq_handler);
AT91F_PIO_InterruptEnable(AT91C_BASE_PIOB,SW4_MASK);
//* set the interrupt by software
AT91F_AIC_EnableIt (pAic, AT91C_ID_PIOB);
for (;;)
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED1 );
delay () ;
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );
delay () ;
loop_count ++ ;
//* Set LED by software interrupt
if (loop_count == 3)
{
loop_count=0;
//* Software interrupt
AT91F_AIC_Trig (pAic,AT91C_ID_SYS) ;
}
}
//* End
}
|
|