Data Link Layer

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.

CAN_EFF_FLAG

EFF/SFF is set in the MSB.

1
(0x80000000U)
CAN_RTR_FLAG

remote transmission request

1
(0x40000000U)
CAN_ERR_FLAG

error message frame

1
(0x20000000U)
CAN_SFF_MASK

standard frame format (SFF)

1
(0x000007FFU)
CAN_EFF_MASK

extended frame format (EFF)

1
(0x1FFFFFFFU)
CAN_ERR_MASK

omit EFF, RTR, ERR flags

1
(0x1FFFFFFFU)
enum can_state
CAN_STATE_ERROR_ACTIVE = 0
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.
CAN_STATE_MAX
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)

CAN_MAX_DLEN

Max data length for a CAN frame.

1
(8)
struct can_frame

Controller Area Network frame.

can.h::canid_t can_id

32 bit CAN_ID + EFF/RTR/ERR flags

uint8_t can_dlc

frame payload length in byte (0 .

. CAN_MAX_DLEN)

uint8_t __pad

padding

uint8_t __res0

reserved / padding

uint8_t __res1

reserved / padding

uint8_t data()

Frame data.

struct can_filter

Controller Area Network filter.

can.h::canid_t can_id

CAN ID.

can.h::canid_t can_mask

Mask.

struct can_bittiming

CAN bit-timing parameters.

For further information, please read chapter “8 BIT TIMING REQUIREMENTS” of the “Bosch CAN Specification version 2.0” at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.

uint32_t bitrate

Bit-rate in bits/second.

uint32_t sample_point

Sample point in one-tenth of a percent.

uint32_t tq

Time quanta (TQ) in nanoseconds.

uint32_t prop_seg

Propagation segment in TQs.

uint32_t phase_seg1

Phase buffer segment 1 in TQs.

uint32_t phase_seg2

Phase buffer segment 2 in TQs.

uint32_t sjw

Synchronisation jump width in TQs.

uint32_t brp

Bit-rate prescaler.

struct can_bittiming_const

CAN hardware-dependent bit-timing constant.

Used for calculating and checking bit-timing parameters

uint32_t tseg1_min

Time segment 1 = prop_seg + phase_seg1, min value.

uint32_t tseg1_max

Time segment 1, max value.

uint32_t tseg2_min

Time segment 2 = phase_seg2, min value.

uint32_t tseg2_max

Time segment 2, max value.

uint32_t sjw_max

Synchronisation jump width.

uint32_t brp_min

Bit-rate prescaler, min value.

uint32_t brp_max

Bit-rate prescaler, max value.

uint32_t brp_inc

Bit-rate prescaler, increment.