//-------------------------------------------------------------------------*
//文  件  名:  isr.c （中断处理函数文件）                                  *
//说      明:  中断处理函数                                                *
//本文件包含:                                                              *  
//           (1)isrDummy:  中断处理程序                                    *
//           (2)SCI1_Recv: SCI1中断处理程序                                *
//           (3)SCI2_Recv: SCI2中断处理程序                                *
//硬件连接: 无                                                             *
//-------------------------------------------------------------------------*
//头文件
#include "Includes.h"

//extern unsigned char SerialBuff1[];  //串行口初始化子程序
extern unsigned char savPTB;
interrupt void SCI1_Recv(void)
{    
    unsigned char i;
    unsigned char *p;
    i=0x00;
    *p=0x02;
	//i=SCIRe1(p);       	//等待接收1个数据,
	  i=SCIRe1(1,p);
  	
	if(*p==0x00)
	{
	  //	SerialBuff1[0]=i;
	  
	  //进行通信前连线测试
	 // if(SerialBuff1[0]=='A')
	  if(i=='A')
	  {
	  	PTBD=0x00;					//通信测试成功,小灯全亮
	  	savPTB=0x00;
	  	//SCISend1(i);				//回送'A',表示成功
	  	SCISend1(1,i);
	  	//SerialBuff1[0]=0;
	  } 
	  else 
	  {
	    PTBD=0xf0;
	    savPTB=0xf0;
	    SCISend1(1,'0');
	   // SerialBuff1[0]=0;
	  } 
	}
	 else 
	 {
	  PTBD=0xff;
	  savPTB=0xff;
	  Delay(1500);
	  SCISend1(1,'1');
	  //SerialBuff1[0]=0;
	 }
	
}
interrupt void SCI2_Recv(void)
{    
    unsigned char i;
    unsigned char *p;
    i=0x00;
    *p=0x02;
	//i=SCIRe1(p);       	//等待接收1个数据,
	  i=SCIRe1(1,p);
  	
	if(*p==0x00)
	{
	  //	SerialBuff1[0]=i;
	  
	  //进行通信前连线测试
	 // if(SerialBuff1[0]=='A')
	  if(i=='A')
	  {
	  	PTBD=0x00;					//通信测试成功,小灯全亮
	  	savPTB=0x00;
	  	//SCISend1(i);				//回送'A',表示成功
	  	SCISend1(1,i);
	  	//SerialBuff1[0]=0;
	  } 
	  else 
	  {
	    PTBD=0xf0;
	    savPTB=0xf0;
	    SCISend1(1,'0');
	   // SerialBuff1[0]=0;
	  } 
	}
	 else 
	 {
	  PTBD=0xff;
	  savPTB=0xff;
	  Delay(1500);
	  SCISend1(1,'1');
	  //SerialBuff1[0]=0;
	 }
}
   
//此处为用户新定义中断处理函数的存放处


//未定义的中断处理函数,本函数不能删除
interrupt void isrDummy(void)
{
    
}

//中断处理子程序类型定义
typedef void( *ISR_func_t)(void);

//中断矢量表，如果需要定义其它中断函数，请修改下表中的相应项目
const ISR_func_t ISR_vectors[] @0xFFCC = 
{
    isrDummy,     //   0xFFCC       //RTI (periodic interrupt) vector
    isrDummy,     //   0xFFCE       //IIC vector
    isrDummy,     //   0xFFD0       //analog to digital conversion vector
    isrDummy,     //   0xFFD2       //keyboard vector
    isrDummy,     //   0xFFD4       //SCI2 transmit vector
    SCI2_Recv,    //   0xFFD6       //SCI2 receive vector
    isrDummy,     //   0xFFD8       //SCI2 error vector
    isrDummy,     //   0xFFDA       //SCI1 transmit vector
    SCI1_Recv,    //   0xFFDC       //SCI1 receive vector
    isrDummy,     //   0xFFDE       //SCI1 error vector
    isrDummy,     //   0xFFE0       //SPI vector
    isrDummy,     //   0xFFE2       //TPM2 overflow vector
    isrDummy,     //   0xFFE4       //TPM2 channel 1 vector
    isrDummy,     //   0xFFE6       //TPM2 channel 0 vector
    isrDummy,     //   0xFFE8       //TPM1 overflow vector
    isrDummy,     //   0xFFEA       //TPM1 channel 5 vector
    isrDummy,     //   0xFFEC       //TPM1 channel 4 vector
    isrDummy,     //   0xFFEE       //TPM1 channel 3 vector
    isrDummy,     //   0xFFF0       //TPM1 channel 2 vector
    isrDummy,     //   0xFFF2       //TPM1 channel 1 vector
    isrDummy,     //   0xFFF4       //TPM1 channel 0 vector
    isrDummy,     //   0xFFF6       //ICG vector
    isrDummy,     //   0xFFF8       //low voltage detect vector
    isrDummy,     //   0xFFFA       //IRQ pin vector
    isrDummy      //   0xFFFC       //SWI vector
    //  RESET defined in Project.prm
};



