2.8 Controller Area Network (CAN)

This Plib implements software abstraction for CAN Peripheral.

Library Interface

Controller Area Network peripheral library provides the following interfaces:

Functions

NameDescription
CANx_InitializeInitializes given instance of the CAN peripheral
CANx_MessageTransmitTransmits a message into CAN bus
CANx_MessageReceiveReceives a message from CAN bus
CANx_MessageAbortAbort request for a FIFO
CANx_MessageIDSetSet Message ID in mailbox
CANx_MessageIDGetGet Message ID from mailbox
CANx_MessageAcceptanceFilterSetSet Message acceptance filter configuration
CANx_MessageAcceptanceFilterGetGet Message acceptance filter configuration
CANx_MessageAcceptanceFilterMaskSetSet Message acceptance filter mask configuration
CANx_MessageAcceptanceFilterMaskGetGet Message acceptance filter mask configuration
CANx_MessageAcceptanceMaskSetSet Message acceptance identifier mask in mailbox
CANx_MessageAcceptanceMaskGetGet Message acceptance identifier mask from mailbox
CANx_MessageTimestampGetGet the message timestamp from a mailbox
CANx_TransmitEventFIFOElementGetGet the Transmit Event FIFO Element for the transmitted message
CANx_ErrorGetReturns the error during transfer
CANx_ErrorCountGetReturns the transmit and receive error count during transfer
CANx_InterruptGetReturns the FIFO Interrupt status
CANx_InterruptEnableEnables CAN Interrupt
CANx_InterruptDisableDisables CAN Interrupt
CANx_MailboxIsReadyReturns true if Mailbox is ready otherwise false
CANx_TxFIFOQueueIsFullReturns true if Tx FIFO/Queue is full otherwise false
CANx_TxFIFOIsFullReturns true if Tx FIFO is full otherwise false
CANx_AutoRTRResponseSetSet the Auto RTR response for remote transmit request
CANx_BitTimingCalculationGetReturns the bit timing information
CANx_BitTimingSetSets the bit timing
CANx_CallbackRegisterSets the pointer to the function (and it is context) to be called when the given CAN's transfer events occur
CANx_TxCallbackRegisterSets the pointer to the function (and it's context) to be called when the given CAN's Tx transfer events occur
CANx_RxCallbackRegisterSets the pointer to the function (and it's context) to be called when the given CAN's Rx transfer events occur
CANx_ErrorCallbackRegisterSets the pointer to the function (and it is context) to be called when error occurs in CAN

Data types and constants

NameTypeDescription
CANFD_MODEEnumCANFD Mode for Classic CAN and CAN FD
CANFD_MSG_TX_ATTRIBUTEEnumCANFD Tx Message Attribute for Tx FIFO and Tx Queue
CANFD_MSG_RX_ATTRIBUTEEnumCANFD Message RX Attribute for Data Frame and Remote Frame
CANFD_FIFO_INTERRUPT_FLAG_MASKEnumCANFD FIFO Interrupt Status Flag Mask
CANFD_ERROREnumCANFD Transfer Error data type
CANFD_CALLBACKTypedefCANFD Callback Function Pointer
CANFD_RX_MSGStructCANFD RX Message Buffer structure
CANFD_RX_MSG_OBJECTStructCANFD Receive Message Object structure
CANFD_TX_MSG_OBJECTStructCANFD Transmit Message Object structure
CANFD_TX_EVENT_FIFO_ELEMENTStructCANFD Trasmit Event FIFO Element structure
CAN_MAILBOX_TX_ATTRIBUTEEnumCAN Mailbox TX Attribute for Transmit mailbox, Producer Tx Mailbox and Consumer Tx Mailbox
CAN_MAILBOX_RX_ATTRIBUTEEnumCAN Mailbox RX Attribute for Reception Mailbox, Reception Mailbox with overwrite, Consumer Rx Mailbox and Producer Rx Mailbox
CAN_MSG_TX_ATTRIBUTEEnumCAN Message TX Attribute for Data Frame and Remote Frame
CAN_MSG_RX_ATTRIBUTEEnumCAN Message RX Attribute for Data Frame and Remote Frame
CAN_MAILBOX_NUMEnumCAN Mailbox Number
CAN_MAILBOX_MASKEnumCAN Mailbox Mask
CAN_FIFO_INTERRUPT_FLAG_MASKEnumCAN FIFO Interrupt Status Flag Mask
CAN_ERROREnumCAN Transfer Error data type
CAN_INTERRUPT_MASKEnumCAN Interrupt Mask
CAN_MAILBOX_STATEEnumCAN Mailbox State
CAN_CALLBACKTypedefCAN Callback Function Pointer
CAN_RX_MSGStructCAN RX Message Buffer structure
CAN_MAILBOX_CALLBACKStructCAN transfer event callback structure
CAN_TX_RX_MSG_BUFFERStructCAN Message Buffer structure
CAN_NOMINAL_BIT_TIMINGStructNominal bit timing parameters
CAN_BIT_TIMINGStructBit timing parameters
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.