
We provide two functions for you to utilize these mask and filter registers. They are:
Mask:
init_Mask(
unsigned
char
num,
unsigned
char
ext,
unsigned
char
ulData);
Filter:
init_Filt(
unsigned
char
num,
unsigned
char
ext,
unsigned
char
ulData);
•
num
represents which register to use. You can fill 0 or 1 for mask and 0 to 5 for filter.
•
ext
represents the status of the frame. 0 means it’s a mask or filter for a standard frame.
1 means it’s for a extended frame.
•
ulData
represents the content of the mask of filter.
3. Check Receive
The MCP2515 can operate in either a polled mode, where the software checks for a
received frame, or using additional pins to signal that a frame has been received or
transmit completed.
Use the following function to poll for received frames.
INT8U MCP_CAN::checkReceive(void);
The function will return 1 if a frame arrives, and 0 if nothing arrives.
4. Get CAN ID
When some data arrive, you can use the following function to get the CAN ID of the
“send” node.
INT32U MCP_CAN::
getCanId
(void)
5. Send Data
CAN.sendMsgBuf(INT8U
id
, INT8U ext, INT8U len, data_buf);
It is a function to send data onto the bus. In which:
•
id
represents where the data come from.
•
ext
represents the status of the frame. ‘0’ means standard frame. ‘1’ means extended
frame.