Loading...
Searching...
No Matches

CAN Data Link Layer More...

Detailed Description

CAN Data Link Layer

The Data Link Layer is composed of the device, router, pkt and dll files. It can be used to send and receive raw CAN frames through multiple CAN controllers.

Files

file  can.h
 Definitions high-level CAN interface.
 
file  device.h
 Definitions of CAN device interface.
 
file  dll.h
 Definitions of low-level CAN DLL interface.
 
file  pkt.h
 CAN memory allocation module.
 
file  raw.h
 Definitions high-level RAW CAN interface.
 
file  router.h
 Functions for routing RX can frames.
 

Data Structures

struct  can_frame
 Controller Area Network frame. More...
 
struct  can_filter
 Controller Area Network filter. More...
 
struct  can_bittiming
 CAN bit-timing parameters. More...
 
struct  can_bittiming_const
 CAN hardware-dependent bit-timing constant. More...
 

Typedefs

typedef uint32_t canid_t
 Controller Area Network Identifier structure.
 
typedef struct can_frame can_frame_t
 CAN frame.
 

Enumerations

enum  can_state {
  CAN_STATE_ERROR_ACTIVE = 0 , CAN_STATE_ERROR_WARNING , CAN_STATE_ERROR_PASSIVE , CAN_STATE_BUS_OFF ,
  CAN_STATE_STOPPED , CAN_STATE_SLEEPING , CAN_STATE_MAX
}
 CAN operational and error states. More...
 
#define CAN_MAX_DLEN   (8)
 Max data length for classic and FD CAN frames (compliant with libsocketcan macros)
 
#define CANFD_MAX_DLEN   (64)
 CAN FD maximum data length.
 

CAN_ID flags and masks

#define CAN_EFF_FLAG   (0x80000000U)
 EFF/SFF is set in the MSB.
 
#define CAN_RTR_FLAG   (0x40000000U)
 remote transmission request
 
#define CAN_ERR_FLAG   (0x20000000U)
 error message frame
 
#define CAN_SFF_MASK   (0x000007FFU)
 standard frame format (SFF)
 
#define CAN_EFF_MASK   (0x1FFFFFFFU)
 extended frame format (EFF)
 
#define CAN_ERR_MASK   (0x1FFFFFFFU)
 omit EFF, RTR, ERR flags
 

CAN FD flags extracted from libsocketcan

#define CANFD_BRS   0x01
 bit rate switch (second bitrate for payload data)
 
#define CANFD_ESI   0x02
 error state indicator of the transmitting node
 
#define CANFD_FDF   0x04
 mark CAN FD for dual use of struct canfd_frame
 

Macro Definition Documentation

◆ CAN_EFF_FLAG

#define CAN_EFF_FLAG   (0x80000000U)

EFF/SFF is set in the MSB.

Definition at line 56 of file can.h.

◆ CAN_EFF_MASK

#define CAN_EFF_MASK   (0x1FFFFFFFU)

extended frame format (EFF)

Definition at line 62 of file can.h.

◆ CAN_ERR_FLAG

#define CAN_ERR_FLAG   (0x20000000U)

error message frame

Definition at line 58 of file can.h.

◆ CAN_ERR_MASK

#define CAN_ERR_MASK   (0x1FFFFFFFU)

omit EFF, RTR, ERR flags

Definition at line 63 of file can.h.

◆ CAN_MAX_DLEN

#define CAN_MAX_DLEN   (8)

Max data length for classic and FD CAN frames (compliant with libsocketcan macros)

Classic CAN maximum data length

Definition at line 47 of file can.h.

◆ CAN_RTR_FLAG

#define CAN_RTR_FLAG   (0x40000000U)

remote transmission request

Definition at line 57 of file can.h.

◆ CAN_SFF_MASK

#define CAN_SFF_MASK   (0x000007FFU)

standard frame format (SFF)

Definition at line 61 of file can.h.

◆ CANFD_BRS

#define CANFD_BRS   0x01

bit rate switch (second bitrate for payload data)

Definition at line 70 of file can.h.

◆ CANFD_ESI

#define CANFD_ESI   0x02

error state indicator of the transmitting node

Definition at line 71 of file can.h.

◆ CANFD_FDF

#define CANFD_FDF   0x04

mark CAN FD for dual use of struct canfd_frame

Definition at line 72 of file can.h.

◆ CANFD_MAX_DLEN

#define CANFD_MAX_DLEN   (64)

CAN FD maximum data length.

Definition at line 48 of file can.h.

Typedef Documentation

◆ can_frame_t

typedef struct can_frame can_frame_t

CAN frame.

Definition at line 179 of file can.h.

◆ canid_t

typedef uint32_t canid_t

Controller Area Network Identifier structure.

bit 0-28 : CAN identifier (11/29 bit) right aligned for 11 bit bit 29 : error message frame flag (0 = data frame, 1 = error message) bit 30 : remote transmission request flag (1 = rtr frame) bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)

Definition at line 96 of file can.h.

Enumeration Type Documentation

◆ can_state

enum can_state

CAN operational and error states.

Enumerator
CAN_STATE_ERROR_ACTIVE 

RX/TX error count < 96.

CAN_STATE_ERROR_WARNING 

RX/TX error count < 128.

CAN_STATE_ERROR_PASSIVE 

RX/TX error count < 256.

CAN_STATE_BUS_OFF 

RX/TX error count >= 256.

CAN_STATE_STOPPED 

Device is stopped.

CAN_STATE_SLEEPING 

Device is sleeping.

Definition at line 78 of file can.h.