English
Language : 

AN2628 Datasheet, PDF (11/27 Pages) STMicroelectronics – Programming ST10F27x CAN interrupt drivers
AN2628
Programming through CAN hardware features
if (status & TxOK)
{......}
// transmit interrupt
if (status & RxOK)
{......}
// receive interrupt
if (status & 0x07)
{......}
// erroneous transfer interrupt
}
if (CANxCR & EIE) // if EIE is set (error interrupts)
{
if (status & EWRN)
{......}
// error counter warning
if (status & BOFF) // bus-off situation
CANxCR = (CANxCR & 0xfe);
// recover from BOff (clear INIT)
{......} // remaining part of the BOff procedure
}
break;
case 1: // Message 1 Interrupt
CANxIF1CM = 0x7F;
// Transfer entire message into inference
CANxIF1CR = intid;
// register and clear IntPnd and NewDat
CANx_WAIT_FOR_IF1;
if (CANxIF1A2 & IF_DIR)
// direction = transmit
{
if (CANxIF1MC & IF_NEWDAT)
// remote received provided that UMask = 1
// and RmtEn = 0
{.....} // procedure to handle answer to remote
else
{.....} // procedure to handle transmit interrupts
}
else
// direction = receive
{
if (CANxIF1MC & IF_NEWDAT) // NewDat is set
{.....}
// procedure to handle data receive interrupt
else
{.....} // a remote frame was successfully transmitted
}
break;
block to be repeated (from ‘case 1:’ to ‘case 32:’)
case n: // Message n Interrupt
CANxIF1CM = 0x7F;
// Transfer entire message into inference
CANxIF1CR = intid;
// register and clear IntPnd and NewDat
11/27