void CAN_IRQHandler(void)
{
uint32_t canstat = canstat;
uint32_t can_int, msg_no;
while ( (can_int = LPC_CAN->INT) != 0 )
{
if ( can_int & CAN_STATUS_INTERRUPT )
{
canstat = LPC_CAN->STAT;
#if CAN_DEBUG
CANStatusLog[CANStatusLogCount++] = canstat;
#endif
if ( canstat & STAT_EWARN )
{
EWarnCnt++;
return;
}
if ( canstat & STAT_BOFF )
{
BOffCnt++;
return;
}
}
else
{
if ( (canstat & STAT_LEC) == 0 ) /* NO ERROR */
{
/* deal with RX only for now. */
msg_no = can_int & 0x7FFF;
if ( (msg_no >= 0x01) && (msg_no <= 0x20) )
{
LPC_CAN->STAT &= ~STAT_RXOK;
CAN_MessageProcess( msg_no-1 );
CANRxDone[msg_no-1] = TRUE;
}
}
}
}
return;
}
#endif问一下CAN收到数据进入这个中断时LPC_CAN->INT为状态中断,LPC_CAN->STAT为RXOK。那这个程序不是一接收到CAN数据就就马上产生状态中断么,怎么会进入ELSE里的报文中断里去呢?
此帖出自
小平头技术问答
一周热门 更多>