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
| Name | Description |
|---|---|
| CANx_Initialize | Initializes given instance of the CAN peripheral |
| CANx_MessageTransmit | Transmits a message into CAN bus |
| CANx_MessageReceive | Receives a message from CAN bus |
| CANx_MessageAbort | Abort request for a FIFO |
| CANx_MessageIDSet | Set Message ID in mailbox |
| CANx_MessageIDGet | Get Message ID from mailbox |
| CANx_MessageAcceptanceFilterSet | Set Message acceptance filter configuration |
| CANx_MessageAcceptanceFilterGet | Get Message acceptance filter configuration |
| CANx_MessageAcceptanceFilterMaskSet | Set Message acceptance filter mask configuration |
| CANx_MessageAcceptanceFilterMaskGet | Get Message acceptance filter mask configuration |
| CANx_MessageAcceptanceMaskSet | Set Message acceptance identifier mask in mailbox |
| CANx_MessageAcceptanceMaskGet | Get Message acceptance identifier mask from mailbox |
| CANx_MessageTimestampGet | Get the message timestamp from a mailbox |
| CANx_TransmitEventFIFOElementGet | Get the Transmit Event FIFO Element for the transmitted message |
| CANx_ErrorGet | Returns the error during transfer |
| CANx_ErrorCountGet | Returns the transmit and receive error count during transfer |
| CANx_InterruptGet | Returns the FIFO Interrupt status |
| CANx_InterruptEnable | Enables CAN Interrupt |
| CANx_InterruptDisable | Disables CAN Interrupt |
| CANx_MailboxIsReady | Returns true if Mailbox is ready otherwise false |
| CANx_TxFIFOQueueIsFull | Returns true if Tx FIFO/Queue is full otherwise false |
| CANx_TxFIFOIsFull | Returns true if Tx FIFO is full otherwise false |
| CANx_AutoRTRResponseSet | Set the Auto RTR response for remote transmit request |
| CANx_BitTimingCalculationGet | Returns the bit timing information |
| CANx_BitTimingSet | Sets the bit timing |
| CANx_CallbackRegister | Sets the pointer to the function (and it is context) to be called when the given CAN's transfer events occur |
| CANx_TxCallbackRegister | Sets the pointer to the function (and it's context) to be called when the given CAN's Tx transfer events occur |
| CANx_RxCallbackRegister | Sets the pointer to the function (and it's context) to be called when the given CAN's Rx transfer events occur |
| CANx_ErrorCallbackRegister | Sets the pointer to the function (and it is context) to be called when error occurs in CAN |
Data types and constants
| Name | Type | Description |
|---|---|---|
| CANFD_MODE | Enum | CANFD Mode for Classic CAN and CAN FD |
| CANFD_MSG_TX_ATTRIBUTE | Enum | CANFD Tx Message Attribute for Tx FIFO and Tx Queue |
| CANFD_MSG_RX_ATTRIBUTE | Enum | CANFD Message RX Attribute for Data Frame and Remote Frame |
| CANFD_FIFO_INTERRUPT_FLAG_MASK | Enum | CANFD FIFO Interrupt Status Flag Mask |
| CANFD_ERROR | Enum | CANFD Transfer Error data type |
| CANFD_CALLBACK | Typedef | CANFD Callback Function Pointer |
| CANFD_RX_MSG | Struct | CANFD RX Message Buffer structure |
| CANFD_RX_MSG_OBJECT | Struct | CANFD Receive Message Object structure |
| CANFD_TX_MSG_OBJECT | Struct | CANFD Transmit Message Object structure |
| CANFD_TX_EVENT_FIFO_ELEMENT | Struct | CANFD Trasmit Event FIFO Element structure |
| CAN_MAILBOX_TX_ATTRIBUTE | Enum | CAN Mailbox TX Attribute for Transmit mailbox, Producer Tx Mailbox and Consumer Tx Mailbox |
| CAN_MAILBOX_RX_ATTRIBUTE | Enum | CAN Mailbox RX Attribute for Reception Mailbox, Reception Mailbox with overwrite, Consumer Rx Mailbox and Producer Rx Mailbox |
| CAN_MSG_TX_ATTRIBUTE | Enum | CAN Message TX Attribute for Data Frame and Remote Frame |
| CAN_MSG_RX_ATTRIBUTE | Enum | CAN Message RX Attribute for Data Frame and Remote Frame |
| CAN_MAILBOX_NUM | Enum | CAN Mailbox Number |
| CAN_MAILBOX_MASK | Enum | CAN Mailbox Mask |
| CAN_FIFO_INTERRUPT_FLAG_MASK | Enum | CAN FIFO Interrupt Status Flag Mask |
| CAN_ERROR | Enum | CAN Transfer Error data type |
| CAN_INTERRUPT_MASK | Enum | CAN Interrupt Mask |
| CAN_MAILBOX_STATE | Enum | CAN Mailbox State |
| CAN_CALLBACK | Typedef | CAN Callback Function Pointer |
| CAN_RX_MSG | Struct | CAN RX Message Buffer structure |
| CAN_MAILBOX_CALLBACK | Struct | CAN transfer event callback structure |
| CAN_TX_RX_MSG_BUFFER | Struct | CAN Message Buffer structure |
| CAN_NOMINAL_BIT_TIMING | Struct | Nominal bit timing parameters |
| CAN_BIT_TIMING | Struct | Bit timing parameters |
Note: Not all APIs maybe implemented. See the specific device family
section for available APIs.
