Hi Alex
It is a long time since I worked on the M5213 CAN driver but here are some ideas (based on quickly looking at out code)
>>It doesn't clear what should i do on frame receiving in RX interrupt service routine to safely grab a message. Should I only lock that buffer (read code, grab and read time stamp) or deactivate the buffer (write INACTIVE code, grab, write RX_EMPTY code )?
I'm afraid of frames lost.
On Rx interrupt we do
COLDFIRE_CAN_BUF *ptrMessageBuffer = MBUFF0_ADD;
ptrMessageBuffer += iIntBuf;
*(unsigned char *)ptrMessageBuffer = 0; // deactivate buffer so that it doesn't get overwritten
CAN_IFLAG = (0x0001 << iIntBuf); // clear interrupt flagThen the receiver can extract the message 'off-line' (outside of critical interrupt).
>>Is it possible to switch off self-received messages on hw level or I have to do this "manually" by caching sent messages?
I don't remember the details (or whether HW filtering is possible) but there is always an interrupt and it is possible to detect whether it is one of the following cases:
- buffer has just transmitted a remote frame request
- a remote response has been detected
- remote frame transmission message successfully acked
- tx message successfully acked
>>Is it possible to treat any incoming RTR frame as other incoming frames? This is important cause my driver have to deliver this RTR message to the upper level.
I have to receive RTR frames with any ID and pass them to software RX FIFO buffer.
RTR frames cause the used tx buffer to automatically revert to rx buffer after transmission. The reception process is then the same as for any buffer. I think that it is therefore a case of the driver remembering the mode of the buffer use and reacting accordingly.
Take a look at the following documenmt which describes our implementation on the Coldifre:
http://www.utasker.com/docs/uTasker/uTaskerCAN.PDFOn page 6/9 Remote frame operation is discussed (at the user level). Maybe it will give an idea of whether this is what you want to do (in which case it is possible) or not.
Sorry if the response it a little vague but it really is a long time since I worked on the CAN driver and so I am very rusty... Regards
Mark
www.uTasker.com