SIM_INTERFACE(can_device) {
void (*receive)(conf_object_t *obj, can_frame_t *frame);
};
#define CAN_DEVICE_INTERFACE "can_device"
The can_device interface is implemented by CAN controllers.
The receive function is called by can-endpoint to pass CAN frame
from other can-endpoint to the connected CAN controller.
The CAN frame is expressed by the frame parameter, which is a
pointer of can_frame_t. The following is the details of
can_frame_t:
Standard Format:Extended Format:can_frame_t only focus on the
logical meanings of such fields and tries to adapt different CAN controllers:
identifier: For Standard frame, 11bit_ID should be put in
identifier[10:0];for Extended frame, 11bit_sID should be put in
identifier[28:18] and 18bit_eID should be put in
identifier[17:0].extended: There isn't IDE in can_frame_t, instead,
extended is used to indicate if the frame is Extended frame or
Standard frame.rtr: There isn't SRR in can_frame_t for Extended frame,
instead, rtr is used to indicate if the frame is a remote frame or
not. Here we don't care whether the frame is Extended frame or Standard
frame.data_length: The data_length contains the arithmetic
value of the DLC.data[CAN_DATA_MAX_NUM]: This is the data field of Date frame.
crc: This is the crc field of a CAN frame.typedef struct {
/* arbitration field */
uint32 identifier;
bool extended;
bool rtr;
/* control field */
uint8 data_length;
/* data field */
uint8 data[CAN_DATA_MAX_NUM];
/* crc field */
uint16 crc;
} can_frame_t;