RTEMS CAN/CAN FD Stack
Loading...
Searching...
No Matches
Classes | Macros
can-frame.h File Reference

This header file is part of CAN/CAN FD bus common support. It implements CAN frame structure and related defines. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  can_frame_header
 This structure represents the CAN message header. More...
 
struct  can_frame
 This structure represents one CAN frame. It consists of CAN header and data. More...
 

Macros

#define CAN_FRAME_BFF_ID_MASK   ( 0x000007ff )
 This define provides mask for base frame format identifier.
 
#define CAN_FRAME_EFF_ID_MASK   ( 0x1fffffff )
 This define provides mask for extended frame format identifier.
 
#define CAN_FRAME_STANDARD_DLEN   ( 8u )
 Represents standard (not FD) CAN frame data length.
 
#define CAN_FRAME_FD_DLEN   ( 64u )
 Represents CAN FD frame data length.
 
#define CAN_FRAME_MAX_DLEN   ( CAN_FRAME_FD_DLEN )
 Represents maximum allowed CAN frame data length.
 
CAN Frame Flags

See structure can_frame for reference.

#define CAN_FRAME_IDE   ( 1 << 0 )
 Represents extended frame format.
 
#define CAN_FRAME_RTR   ( 1 << 1 )
 Represents remote transfer request.
 
#define CAN_FRAME_ECHO   ( 1 << 2 )
 Represents echo flag.
 
#define CAN_FRAME_LOCAL   ( 1 << 3 )
 Represents local flag.
 
#define CAN_FRAME_TXERR   ( 1 << 4 )
 Represents frame transmission error.
 
#define CAN_FRAME_ERR   ( 1 << 5 )
 Represents generic error flag.
 
#define CAN_FRAME_FIFO_OVERFLOW   ( 1 << 6 )
 Represents local FIFO overflow.
 
#define CAN_FRAME_FDF   ( 1 << 7 )
 Represents CAN FD frame format.
 
#define CAN_FRAME_BRS   ( 1 << 8 )
 Represents bit rate shift for CAN FD frames.
 
#define CAN_FRAME_ESI   ( 1 << 9 )
 Represents error state inicator of transmitting node.
 
CAN Error Types

These types are defined in identifier field of can_frame structure.

#define CAN_ERR_ID_TXTIMEOUT   ( 1 << 0 )
 Represents CAN frame TX timeout error.
 
#define CAN_ERR_ID_LOSTARB   ( 1 << 1 )
 Represents lost arbitration error. Additional information are stored in CAN_ERR_DATA_BYTE_TRX_CTRL of data.
 
#define CAN_ERR_ID_CRTL   ( 1 << 2 )
 Represents CAN controller error. Additional information are stored in CAN_ERR_DATA_BYTE_TRX_PROT of data.
 
#define CAN_ERR_ID_PROT   ( 1 << 3 )
 Represents CAN frame protocol violations. Additional information are stored in CAN_ERR_DATA_BYTE_TRX_PROT and CAN_ERR_DATA_BYTE_TRX_PROT_LOC of data.
 
#define CAN_ERR_ID_TRX   ( 1 << 4 )
 Represents transceiver status error. Additional information are stored in CAN_ERR_TRX_DATA_BYTE of data.
 
#define CAN_ERR_ID_ACK   ( 1 << 5 )
 Represents no acknowledgment on transmission error.
 
#define CAN_ERR_ID_BUSOFF   ( 1 << 6 )
 Represents bus off state.
 
#define CAN_ERR_ID_BUSERROR   ( 1 << 7 )
 Represents bus error.
 
#define CAN_ERR_ID_RESTARTED   ( 1 << 8 )
 Represents controller restarted information.
 
#define CAN_ERR_ID_CNT   ( 1 << 9 )
 Represents TX/RX error counter. Values are stored in CAN_ERR_DATA_BYTE_CNT_TX and CAN_ERR_DATA_BYTE_CNT_RX of data.
 
#define CAN_ERR_ID_INTERNAL   ( 1 << 10 )
 Represents stack internal error.
 
#define CAN_ERR_ID_TAG   ( 1 << 31 )
 Represents CAN error tag. This sets 31st bit of identifier to logical one to make the frame invalid. It should be used to further distinquish error frames from standard ones.
 
CAN Error Types Offsets to Data

These defines offsets to data field of can_frame structure, where additional information for given error type are stored.

#define CAN_ERR_DATA_BYTE_TRX_LOSTARB   ( 0 )
 Represents data offset in bytes to lost arbitration information.
 
#define CAN_ERR_DATA_BYTE_TRX_CTRL   ( 1 )
 Represents data offset in bytes to controller error information.
 
#define CAN_ERR_DATA_BYTE_TRX_PROT   ( 2 )
 Represents data offset in bytes to information about protocol violation.
 
#define CAN_ERR_DATA_BYTE_TRX_PROT_LOC   ( 3 )
 Represents data offset in bytes to information about protocol violation location.
 
#define CAN_ERR_TRX_DATA_BYTE   ( 4 )
 Represents data offset in bytes to additional transceiver status error information.
 
#define CAN_ERR_DATA_BYTE_CNT_TX   ( 6 )
 Represents data offset in bytes to TX counter.
 
#define CAN_ERR_DATA_BYTE_CNT_RX   ( 7 )
 Represents data offset in bytes to RX counter.
 
CAN Lost Arbitration Errors
#define CAN_ERR_LOSTARB_UNSPEC   ( 0 )
 Represents unspecified lost arbitration error.
 
#define CAN_ERR_LOSTARB_BIT(n)   ( n )
 Represents bit in which arbitration was lost.
 
CAN Controller Errors
#define CAN_ERR_CRTL_UNSPEC   ( 0 )
 Represents unspecified controller error.
 
#define CAN_ERR_CRTL_RX_OVERFLOW   ( 1 << 0 )
 Represents RX buffer overflow controller error.
 
#define CAN_ERR_CRTL_TX_OVERFLOW   ( 1 << 1 )
 Represents TX buffer overflow controller error.
 
#define CAN_ERR_CRTL_RX_WARNING   ( 1 << 2 )
 Identifies controller reached warning level for RX errors.
 
#define CAN_ERR_CRTL_TX_WARNING   ( 1 << 3 )
 Identifies controller reached warning level for TX errors.
 
#define CAN_ERR_CRTL_RX_PASSIVE   ( 1 << 4 )
 Identifies controller reached error passive status for RX.
 
#define CAN_ERR_CRTL_TX_PASSIVE   ( 1 << 5 )
 Identifies controller reached error passive status for TX.
 
#define CAN_ERR_CRTL_ACTIVE   ( 1 << 6 )
 Identifies controller recovered to error active state.
 
CAN Protocol Violation Errors
#define CAN_ERR_PROT_UNSPEC   ( 0 )
 Represents unspecified protocol violation.
 
#define CAN_ERR_PROT_BIT   (1 << 0)
 Represents single bit error.
 
#define CAN_ERR_PROT_FOR   (1 << 1)
 Represents frame format error.
 
#define CAN_ERR_PROT_STUFF   (1 << 2)
 Represents bit stuffing error.
 
#define CAN_ERR_PROT_BIT0   (1 << 3)
 Identifies the controller is unable to send dominant bit.
 
#define CAN_ERR_PROT_BIT1   (1 << 4)
 Identifies the controller is unable to send recessive bit.
 
#define CAN_ERR_PROT_OVERLOAD   (1 << 5)
 Represents bus overload.
 
#define CAN_ERR_PROT_ACTIVE   (1 << 6)
 Represents active error announcement.
 
#define CAN_ERR_PROT_TX   (1 << 7)
 Identifies that rrror occurred on transmission.
 
CAN Protocol Violation Errors Location
#define CAN_ERR_PROT_LOC_UNSPEC   ( 0x00 )
 Represents unspecified protocol violation location.
 
#define CAN_ERR_PROT_LOC_SOF   ( 0x01 )
 Represents protocol violation location at start of frame.
 
#define CAN_ERR_PROT_LOC_ID0   ( 0x02 )
 Represents protocol violation location at ID bits 0-4.
 
#define CAN_ERR_PROT_LOC_ID1   ( 0x03 )
 Represents protocol violation location at ID bits 5-12.
 
#define CAN_ERR_PROT_LOC_ID2   ( 0x04 )
 Represents protocol violation location at ID bits 13-17.
 
#define CAN_ERR_PROT_LOC_ID3   ( 0x05 )
 Represents protocol violation location at ID bits 21-28.
 
#define CAN_ERR_PROT_LOC_ID4   ( 0x06 )
 Represents protocol violation location at ID bits 18-20.
 
#define CAN_ERR_PROT_LOC_IDE   ( 0x07 )
 Represents protocol violation location at IDE bit.
 
#define CAN_ERR_PROT_LOC_RTR   ( 0x08 )
 Represents protocol violation location at RTR bit.
 
#define CAN_ERR_PROT_LOC_SRTR   ( 0x09 )
 Represents protocol violation location at SRTR bit.
 
#define CAN_ERR_PROT_LOC_RES0   ( 0x0a )
 Represents protocol violation location at reserved bit 0.
 
#define CAN_ERR_PROT_LOC_RES1   ( 0x0b )
 Represents protocol violation location at reserved bit 1.
 
#define CAN_ERR_PROT_LOC_DLC   ( 0x0c )
 Represents protocol violation location at DLC.
 
#define CAN_ERR_PROT_LOC_DATA   ( 0x0d )
 Represents protocol violation location at data section.
 
#define CAN_ERR_PROT_LOC_CRCSEQ   ( 0x0e )
 Represents protocol violation location at CRC sequence.
 
#define CAN_ERR_PROT_LOC_CRCDEL   ( 0x0f )
 Represents protocol violation location at CRC delimiter.
 
#define CAN_ERR_PROT_LOC_ACK   ( 0x10 )
 Represents protocol violation location at ACK slot.
 
#define CAN_ERR_PROT_LOC_ACKDEL   ( 0x11 )
 Represents protocol violation location at ACK delimiter.
 
#define CAN_ERR_PROT_LOC_EOF   ( 0x12 )
 Represents protocol violation location at end of frame.
 
#define CAN_ERR_PROT_LOC_INTERM   ( 0x13 )
 Represents protocol violation location at intermission.
 
CAN Transmission Errors
#define CAN_ERR_TRX_UNSPEC   ( 0x00 )
 Represents unspecified transmission error.
 
#define CAN_ERR_TRX_H_MASK   ( 0x0f )
 Represents mask for CANH transmission error.
 
#define CAN_ERR_TRX_H_NOWIRE   ( 0x01 )
 Represents no CAN high wire detected.
 
#define CAN_ERR_TRX_H_SHORT2BAT   ( 0x02 )
 Identifies CAN H shortage to bat.
 
#define CAN_ERR_TRX_H_SHORT2VCC   ( 0x03 )
 Identifies CAN H shortage to VCC.
 
#define CAN_ERR_TRX_H_SHORT2GND   ( 0x04 )
 Identifies CAN H shortage to ground.
 
#define CAN_ERR_TRX_L_MASK   ( 0xf0 )
 Represents mask for CANL transmission error.
 
#define CAN_ERR_TRX_L_NOWIRE   ( 0x10 )
 Represents no CAN low wire detected.
 
#define CAN_ERR_TRX_L_SHORT2BAT   ( 0x20 )
 Identifies CAN L shortage to bat.
 
#define CAN_ERR_TRX_L_SHORT2VCC   ( 0x30 )
 Identifies CAN L shortage to VCC.
 
#define CAN_ERR_TRX_L_SHORT2GND   ( 0x40 )
 Identifies CAN L shortage to ground.
 
#define CAN_ERR_TRX_L_SHORT2CANH   ( 0x50 )
 Identifies CAN L shortage to CAN H.
 

Detailed Description

This header file is part of CAN/CAN FD bus common support. It implements CAN frame structure and related defines.