Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:hardware:avr-can:can-functions [2010/04/05 12:57] – created mikk.leinien:hardware:avr-can:can-functions [2020/07/20 12:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== CAN-Functions ======
  
 +====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:
 +
 +<code c>
 +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
 +</code>
 +
 +====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:**
 +<code c>
 +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);
 +</code>
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0