The can_t Structure

CAN communication between the used CAN boards is (on the programming level) accessed through the use of a structure named can_t which is defined in “can.h”. The structure can_t consists of variables that can be written to prepare a message for sending or read to process a received message. Here is an overview of the variables of this structure:

Structure  can_t:
	uint32_t        id: //  message  ID
	struct flags
	int rtr: //  remote-transmit-request-frame
	int extended: //  extended  ID  ?
	uint8_t length: //  number  of  data  bytes
	uint8_t data[8]: //  message  data

Functions for CAN Communication

The header file “can.h” declares various functions necessary for CAN communi- cation. The CAN library is open source. The following functions are sufficient for basic communication:

Initialization of the CAN interface, setting of the baud rate:

extern    bool can_init(can_bitrate_t  bitrate);
//  Check  if  a  CAN  message  has  been  received  (function  returns  TRUE  or  FALSE):
extern    bool can_check_message(void);
//  Retrieving  a  message  out  of  the  receive  buffers  of  the  CAN  controller:
extern    uint8_t      can_get_message(can_t  *msg);
//  Sending  a  message  over  the  CAN  Bus:
extern    uint8_t      can_send_message(const  can_t  *msg);
en/hardware/avr-can/can-functions.txt · Last modified: 2018/12/27 12:53 (external edit) Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0