I am a newer. I study the AT91SAM7S64 for a month. Now I encounter some problem. The code as below:
Code:
// Macros for Interrupt Nesting
#define IENABLE /* Nested Interrupts Entry */ \
__asm { MRS LR, SPSR } /* Copy SPSR_irq to LR */ \
__asm { STMFD SP!, {LR} } /* Save SPSR_irq */ \
__asm { MSR CPSR_c, #0x1F } /* Enable IRQ (Sys Mode) */ \
__asm { STMFD SP!, {LR} } /* Save LR */ \
#define IDISABLE /* Nested Interrupts Exit */ \
__asm { LDMFD SP!, {LR} } /* Restore LR */ \
__asm { MSR CPSR_c, #0x92 } /* Disable IRQ (IRQ Mode) */ \
__asm { LDMFD SP!, {LR} } /* Restore SPSR_irq to LR */ \
__asm { MSR SPSR_cxsf, LR } /* Copy LR to SPSR_irq */ \
extern AT91S_PIO * pPIO; /* Global Pointer to PIO */
void irq0_int (void) __irq __atr { /* IRQ0 (Push button SW2) */
IENABLE; /* Enable Interrupt nesting */
if ((pPIO->PIO_PDSR & SW2) == 0) { /* Check if SW2 is pressed */
pPIO->PIO_CODR = LED2; /* Turn On LED2 */
while ((pPIO->PIO_PDSR & SW2) == 0); /* Wait until SW2 is pressed */
pPIO->PIO_SODR = LED2; /* Turn Off LED2 */
}
IDISABLE; /* Disable Interrupt nesting */
*AT91C_AIC_EOICR = 0; /* End of Interrupt */
}
Can anybody explain the below code in detail:
Code:
__asm { MSR CPSR_c, #0x1F } /* Enable IRQ (Sys Mode) __asm { MSR CPSR_c, #0x92 } /* Disable IRQ (IRQ Mode) */
We can set the priority of interrupt by the below code:
Code:
pAIC->AIC_SMR[AT91C_ID_IRQ0] = AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED | 1;
Why we have to use the IENABLE, IDISABLE in the program?? Is it unnecessary or somrthing else???
cheng_bei