关于#开发板#的问题,该代码能不能实现,有无正确代码

img


#include "ioCC2530.h"

#define LED1 P1_0

#define LED2 P1_1

#define LED3 P1_3

#define LED4 P1_4

#define SW1  P1_2

unsigned int counter=0;


void delay(unsigned int time)

{ 
  
  unsigned int i;
  
  unsigned char j;
  
  for(i = 0; i < time; i++)
  
  {  
    
    for(j = 0; j < 240; j++)
    
    {   
      asm("NOP");
        
      asm("NOP");
        
      asm("NOP");
    
    }
  
  }

}


#pragma vector=P1INT_VECTOR
__interrupt void P1_ISR()

{
  
  EA=0;
  
  if(P1IFG&0x04)//00000100
 
  {
    
    while(SW1==0)
      
      delay(100);//消抖
    
    while(!SW1)
    
    {
      
      counter++;
    
    }
    
    P1IFG&=0xFB;//11111011
    P1IF=0x00;
  }
  
  EA=1;

}



void init()
{
  P1SEL&=0xE0;//11100000
  P1DIR|=0x1B;//00011011
  P1DIR&=0xfb;
  P1INP&=0xFB;//11111011
  P2INP&=0xDF;//下拉
  IEN2|=0x10;//00010000 
  P1IEN|=0x04;//00000100 
  PICTL|=0x02;//11111101
  LED1=LED2=LED3=LED4=0;
  EA=1;
}

void PRESSBUTTON1()
{
  LED1=LED3=LED4=1;
  LED2=0;
  delay(1000);
  LED1=LED3=LED4=0;
  LED2=0;
  delay(1000);
}
void PRESSBUTTON2()
{
  LED4=LED2=1;
  LED1=LED3=0;
  delay(1000);
  LED4=LED2=0;
  LED1=LED3=0;
  delay(1000);
}

void PRESSBUTTON3()
{
  LED1=LED2=LED3=LED4=0;
  delay(1000);
}

void main()
{
  init();
  while(1)
    {
      switch(counter){
      case 1:
        PRESSBUTTON1(); 
        break;
      case 2:
        PRESSBUTTON2();
        break;
      case 3:
        PRESSBUTTON3();
        break;  
      case 4:
        PRESSBUTTON1();
        break;   
      default:
        counter=0;
        break;
    }
    delay(1000); 
  }
}

实际运行一下就知道能不能用了啊