ARM 中断的写法

ARM 143浏览

//如一下代码所示,不能用2个if 代替这个两个else if,也不能用switch,因为最多四个参数寄存器,编译器会给switch类型的语法,每个情况分配一个寄存器,即使不带参数,也会出现中断不能响应的问题,所以用if..else if ...else if 代替switch 和 单个的if 语句. (连蒙带猜,不准,如有谁知道具体,请留言)

#include "s3c24xx.h"
void delay(unsigned int time)
{
        int i;
        for(i=time; i>0; i--);
}

void EINT_Handle()
{
        //PWM中断
        if(INTOFFSET == 10)
        {  
                SRCPND = 1<< INTOFFSET;
                INTPND = INTPND;
                GPFDAT ^= (1<<4);
//              GPFDAT = ~(GPFDAT & (0xf<<4));
        }  
        //外部中断0及外部中断2
        else if((INTOFFSET == 0) | (INTOFFSET == 2))

        {  
                SRCPND = 1<< INTOFFSET;
                INTPND = INTPND;
                GPFDAT |= (1<<4);
                delay(50000);
        }  
        //外部中断11和19
        else if(INTOFFSET == 5)
        {  
                if(EINTPEND == (1<<11))
                        EINTPEND = (1<<11);
                if(EINTPEND == (1<<19))
                        EINTPEND = (1<<19);
                SRCPND = 1<< INTOFFSET;
                INTPND = INTPND;
                GPFDAT |= (1<<4);
                delay(50000);
        }  

}