//-------------------------------------------------------------------------*
//文  件  名:  isr.c (中断处理函数文件)                                    *
//说      明:  中断处理函数                                                *
//本文件包含:                                                              *  
//           (1)isrDummy:中断处理函数                                      *
//           (2)isrT1Ch0In:定时器1通道0输入捕捉中断处理函数                *
//硬件连接: 无                                                             *
//-------------------------------------------------------------------------*

//头文件
#include "Includes.h"


//此处为用户新定义中断处理函数的存放处
 
 
//-------------------------------------------------------------------------*
//函数名: isrT1Ch0In(定时器1通道0输入捕捉中断处理函数)                     *
//功  能: 取反当前灯的状态并清通道标志位                                   *
//参  数: 无                                                               *
//返  回: 无                                                               *
//-------------------------------------------------------------------------*

interrupt void isrT1Ch0In(void)
{

	uint8 temp, flag;
	DisableInterrupts();          //禁止总中断
	flag = LStaTst(Light_Pin0);   //获取小灯当前状态("亮"/"暗")
	if (flag == 'L')              //取反当前小灯状态
	    LightDrv(Light_Pin0,'A');
	else 
	    LightDrv(Light_Pin0,'L');
	Delay(1);                     //延时,防止波动开关时产生抖动
	//清除输入捕捉标志位
	temp   = AW60_TPM1_CHSCSTR(0);                  //(1)读该寄存器
	AW60_TPM1_CHSCSTR(0) &= ~AW60_TPM_CHSCSTR_CHF;  //(2)向输入捕捉标志位写0
	EnableInterrupts();           //开放总中断
}

//-------------------------------------------------------------------------*
//函数名: isrT1Ch1In(定时器1通道0输入捕捉中断处理函数)                     *
//功  能: 取反当前灯的状态并清通道标志位                                   *
//参  数: 无                                                               *
//返  回: 无                                                               *
//-------------------------------------------------------------------------*

interrupt void isrT1Ch1In(void)
{

	uint8 temp, flag;
	DisableInterrupts();          //禁止总中断
	flag = LStaTst(Light_Pin1);   //获取小灯当前状态("亮"/"暗")
	if (flag == 'L')              //取反当前小灯状态
	    LightDrv(Light_Pin1,'A');
	else 
	    LightDrv(Light_Pin1,'L');
	Delay(1);                     //延时,防止波动开关时产生抖动
	//清除输入捕捉标志位
	temp   = AW60_TPM1_CHSCSTR(1);                  //(1)读该寄存器
	AW60_TPM1_CHSCSTR(1) &= ~AW60_TPM_CHSCSTR_CHF;  //(2)向输入捕捉标志位写0
	EnableInterrupts();           //开放总中断
}

//未定义的中断处理函数,本函数不能删除
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
    isrDummy,     //   0xFFD6       //SCI2 receive vector
    isrDummy,     //   0xFFD8       //SCI2 error vector
    isrDummy,     //   0xFFDA       //SCI1 transmit vector
    isrDummy,     //   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
    isrT1Ch1In,     //   0xFFF2       //TPM1 channel 1 vector
    isrT1Ch0In,   //   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
};



