void can_signal(void)
{
unsigned char data can_irq;
unsigned char data temp;
x_wdgtime();
can_irq = InterruptReg;
if(can_irq&ALI_Bit)
{ // 裁定丢掉位
++al_counter;
temp=ArbLostCapReg; // 读裁定丢掉寄存器
alc_current=temp&0x1F; // 取得当时裁定丢掉的方位
}
if(can_irq & BEI_Bit)
{ // 总线过错中止
temp=ErrCodeCapReg;
buse_current=temp&0x3F;
temp=temp&0xD0; // 取得总线过错的类型
switch (temp)
{
case 0x00: ++bite_counter;
case 0x40: ++forme_counter;
case 0x80: ++stuffe_counter;
case 0xd0: ++othere_counter;
}
}
if(can_irq & EPI_Bit)
{ // 消沉过错中止,
// 接纳或发送过错计数超越127时,过错状况变为被迫过错
if((RxErrCountReg>127)||(TxErrCountReg>127)) errstatus_current=ERR_PASSIVE;
// 接纳或发送过错计数回到小于127时,过错状况变为自动过错
if((RxErrCountReg<127)&&(TxErrCountReg<127)) errstatus_current=ERR_ACTIVE;
}
if(can_irq & DOI_Bit)
{ // data overflow
CommandReg = (CDO_Bit|RRB_Bit);
return;
}
if(can_irq&EI_Bit)
{ // 过错报警中止, 这儿只对总线封闭过错做处理
if(StatusReg&BS_Bit)
{ // 检测状况寄存器的总线状况位
++busoff_counter;
ModeControlReg = 0x00;
return;
}
}
if(can_irq & RI_Bit)
{ // 接纳数据中止
if(StatusReg & DOS_Bit)
{
CommandReg = (CDO_Bit|RRB_Bit);
return;
}
can_readmsg();
return;
}
return;
}