CAN FD Driver using dsPIC MCUs. More...
Files | |
file | can1.h |
This is the generated driver header file for the CAN1 driver using CCL. | |
file | can_features.h |
This is the generated module feature header file for CAN driver using CCL. This file provides module feature list available on the selected device. The macros defined in this file provides the flexibility to easily migrate the user application to other device which might have varied feature list. | |
file | can_types.h |
This is the generated driver types header file for the CAN driver using CCL. | |
file | can1.c |
This is the generated driver source file for CAN1 driver using CCL. | |
Data Structures | |
struct | CAN_INTERFACE |
Structure containing the function pointers of CAN driver. More... | |
struct | CAN_MSG_FIELD |
This data structure used to configure the message fields. Some of the fields formatType and brs data should match with the CAN FD configuration in Melody MCC user interface. More... | |
struct | CAN_MSG_OBJ |
This data structure used to configure the CAN FD message object. More... | |
struct | CAN1 |
This defines the object required for the maintenance of the receive FIFO message object. More... | |
Enumerations | |
enum | CAN1_TX_FIFO_CHANNELS { CAN1_TXQ = 0 } |
This enumeration defines the can Transmit FIFO Configured in MCC Melody CAN user interface. More... | |
enum | CAN1_RX_FIFO_CHANNELS { CAN1_FIFO_1 = 1 } |
This enumeration defines the can receive FIFO. More... | |
enum | CAN_MSG_OBJ_BRS_MODE { CAN_NON_BRS_MODE = 0 , CAN_BRS_MODE = 1 } |
Defines the Bit rate with enabled or disabled the CAN message object. More... | |
enum | CAN_MSG_OBJ_ID_TYPE { CAN_FRAME_STD = 0 , CAN_FRAME_EXT = 1 } |
Defines the Standard ID or Extended ID in CAN message object. More... | |
enum | CAN_MSG_OBJ_FRAME_TYPE { CAN_FRAME_DATA = 0 , CAN_FRAME_RTR = 1 } |
Defines the Data frame or Remote transmit Request frame in CAN message object. More... | |
enum | CAN_MSG_OBJ_TYPE { CAN_2_0_FORMAT = 0 , CAN_FD_FORMAT = 1 } |
Defines the CAN FD format or CAN 2.0 format in CAN message object. More... | |
enum | CAN_TX_MSG_REQUEST_STATUS { CAN_TX_MSG_REQUEST_SUCCESS = 0 , CAN_TX_MSG_REQUEST_DLC_EXCEED_ERROR = 1 , CAN_TX_MSG_REQUEST_BRS_ERROR = 2 , CAN_TX_MSG_REQUEST_FIFO_FULL = 3 } |
Defines the CAN transmit Api return status. More... | |
enum | CAN_OP_MODES { CAN_NORMAL_FD_MODE = 0x0 , CAN_DISABLE_MODE = 0x1 , CAN_INTERNAL_LOOPBACK_MODE = 0x2 , CAN_LISTEN_ONLY_MODE = 0x3 , CAN_CONFIGURATION_MODE = 0x4 , CAN_EXTERNAL_LOOPBACK_MODE = 0x5 , CAN_NORMAL_2_0_MODE = 0x6 , CAN_RESTRICTED_OPERATION_MODE =0x7 } |
Defines the CAN operation modes are available for the module to use. More... | |
enum | CAN_OP_MODE_STATUS { CAN_OP_MODE_REQUEST_SUCCESS , CAN_OP_MODE_REQUEST_FAIL , CAN_OP_MODE_SYS_ERROR_OCCURED } |
Defines the CAN operation set Api return status. More... | |
enum | CAN_TX_FIFO_STATUS { CAN_TX_FIFO_FULL , CAN_TX_FIFO_AVAILABLE } |
Defines the CAN transmit status get Api return status. More... | |
enum | CAN_DLC { DLC_0 , DLC_1 , DLC_2 , DLC_3 , DLC_4 , DLC_5 , DLC_6 , DLC_7 , DLC_8 , DLC_12 , DLC_16 , DLC_20 , DLC_24 , DLC_32 , DLC_48 , DLC_64 } |
Defines the CAN message payload size that are available for the mode to use. More... | |
Functions | |
void | CAN1_Initialize (void) |
Initializes CAN1 module. | |
void | CAN1_Deinitialize (void) |
Deinitializes CAN1 to POR values. | |
enum CAN_OP_MODE_STATUS | CAN1_OperationModeSet (const enum CAN_OP_MODES requestMode) |
Sets the CAN1 operation mode. | |
enum CAN_OP_MODES | CAN1_OperationModeGet (void) |
Get the CAN1 operation mode. | |
bool | CAN1_Receive (struct CAN_MSG_OBJ *rxCanMsg) |
Reads the received single message object. | |
bool | CAN1_ReceiveMessageGet (const enum CAN1_RX_FIFO_CHANNELS fifoChannel, struct CAN_MSG_OBJ *rxCanMsg) |
Reads the received single message object from the CAN1 receive FIFO. | |
enum CAN_TX_MSG_REQUEST_STATUS | CAN1_Transmit (const enum CAN1_TX_FIFO_CHANNELS fifoChannel, struct CAN_MSG_OBJ *txCanMsg) |
Writes the CAN message object to specified transmit FIFO channel. | |
enum CAN_TX_FIFO_STATUS | CAN1_TransmitFIFOStatusGet (const enum CAN1_TX_FIFO_CHANNELS fifoChannel) |
Returns the CAN1 transmitter FIFO status. | |
bool | CAN1_IsBusOff (void) |
Returns the bus off status. | |
bool | CAN1_IsTxErrorPassive (void) |
Returns the transmit error passive state. | |
bool | CAN1_IsTxErrorWarning (void) |
Returns the transmit error warning state. If Transmitter error counter is above 95 to below 128, then transmitter error warning state is set. | |
bool | CAN1_IsTxErrorActive (void) |
Returns the transmit error active state. | |
bool | CAN1_IsRxErrorPassive (void) |
Returns the receive error passive state. | |
bool | CAN1_IsRxErrorWarning (void) |
Returns the receive error warning state. If Receiver error counter is above 95 to below 128, then receiver error warning state is set. | |
bool | CAN1_IsRxErrorActive (void) |
Returns the receive error active state. | |
void | CAN1_Sleep (void) |
Sets the CAN node in sleep mode. | |
uint8_t | CAN1_ReceivedMessageCountGet (void) |
Returns the number of CAN messages received in all the FIFO. | |
uint8_t | CAN1_RX_FIFO_StatusGet (const enum CAN1_RX_FIFO_CHANNELS fifoNum) |
This returns the CAN1 receive FIFO status. | |
void | CAN1_Tasks (void) |
This routine is used to implement the tasks for polled implementations. | |
void | CAN1_InvalidMessageCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_InvalidMessageCallback. | |
void | CAN1_InvalidMessageCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_InvalidMessageCallbackRegister. | |
void | CAN1_BusWakeUpActivityCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_BusWakeUpActivityCallback. | |
void | CAN1_BusWakeUpActivityCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_BusWakeUpActivityCallbackRegister. | |
void | CAN1_BusErrorCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_BusErrorCallback. | |
void | CAN1_BusErrorCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_BusErrorCallbackRegister. | |
void | CAN1_ModeChangeCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_ModeChangeCallback. | |
void | CAN1_ModeChangeCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_ModeChangeCallbackRegister. | |
void | CAN1_SystemErrorCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_SystemErrorCallback. | |
void | CAN1_SystemErrorCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_SystemErrorCallbackRegister. | |
void | CAN1_TxAttemptCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_TxAttemptCallback. | |
void | CAN1_TxAttemptCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_TxAttemptCallbackRegister. | |
void | CAN1_RxBufferOverFlowCallbackRegister (void(*handler)(void)) |
This function can be used to override default callback and to define custom callback for CAN1_RxBufferOverFlowCallback. | |
void | CAN1_RxBufferOverFlowCallback (void) |
This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using CAN1_RxBufferOverFlowCallbackRegister. | |
static uint8_t | CAN1_DlcToDataBytesGet (const enum CAN_DLC dlc) |
This function get the DLC enum based decimal value. | |
static void | CAN1_FIFO_InfoGet (const uint8_t fifoNum, volatile struct CAN1_FIFO_INFO *fifoInfo) |
This function get the FIFO user address, message depth and payload size information. | |
static void | CAN1_RX_FIFO_ResetInfo (void) |
This function reset the CAN1 receive message head count. | |
static uint8_t | CAN1_RxFifoSearch (uint8_t fifoNum) |
This function Search the CAN1 receive FIFO channel index. | |
static void | CAN1_RX_FIFO_OverflowStatusFlagClear (const enum CAN1_RX_FIFO_CHANNELS fifoNum) |
This function is used to clear the CAN1 receive FIFO overflow status bit. | |
static void | CAN1_RX_FIFO_IncrementMsgPtr (const uint8_t fifoNum) |
This function Update the receive FIFO message increment tail position. | |
static uint16_t | CAN1_RX_FIFO_MessageIndexGet (const enum CAN1_RX_FIFO_CHANNELS fifoNum) |
This function get the Receiver FIFO message index value. | |
static void | CAN1_TX_FIFO_MessageSendRequest (const enum CAN1_TX_FIFO_CHANNELS fifoChannel) |
This function enables The FIFO transmit message send request bit. | |
static void | CAN1_MessageReadFromFifo (uint16_t *rxFifoObj, struct CAN_MSG_OBJ *rxCanMsg) |
This function read the message object from receive FIFO and update to the user message object pointer. | |
static void | CAN1_MessageWriteToFifo (uint16_t *txFifoObj, struct CAN_MSG_OBJ *txCanMsg) |
This function Read the message object from user input and update to the CAN1 TX FIFO. | |
static void | CAN1_TX_FIFO_Configuration (void) |
This function configure the CAN1 transmit FIFO settings. | |
static void | CAN1_RX_FIFO_Configuration (void) |
This function configure the CAN1 receive FIFO settings. | |
static void | CAN1_RX_FIFO_FilterMaskConfiguration (void) |
This function configure the CAN1 filter and mask settings. | |
static void | CAN1_BitRateConfiguration (void) |
This function configure the CAN1 bit rate settings. | |
static void | CAN1_ErrorNotificationEnable (void) |
This function enables the CAN1 error notification interrupt. | |
Variables | |
const struct CAN_INTERFACE | CAN_FD1 |
Structure object of type CAN_INTERFACE with the custom name given by the user in the Melody Driver User interface. The default name e.g. CAN can be changed by the user in the CAN FD user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability. | |
#define CAN1_RX_FIFO1 CAN1_FIFO_1 |
Defines the custom name of CAN1_FIFO_1 used for Receive functionality
#define CAN1_TX_TXQ CAN1_TXQ |
#define CAN_DMA_INTERFACE_FEATURE_AVAILABLE 0 |
Macros defined for features not supported in the device
Definition at line 103 of file can_features.h.
#define CAN_FD1_BusErrorCallbackRegister CAN1_BusErrorCallbackRegister |
#define CAN_FD1_BusWakeUpActivityCallbackRegister CAN1_BusWakeUpActivityCallbackRegister |
#define CAN_FD1_Deinitialize CAN1_Deinitialize |
#define CAN_FD1_Initialize CAN1_Initialize |
#define CAN_FD1_InvalidMessageCallbackRegister CAN1_InvalidMessageCallbackRegister |
#define CAN_FD1_IsBusOff CAN1_IsBusOff |
#define CAN_FD1_IsRxErrorActive CAN1_IsRxErrorActive |
#define CAN_FD1_IsRxErrorPassive CAN1_IsRxErrorPassive |
#define CAN_FD1_IsRxErrorWarning CAN1_IsRxErrorWarning |
#define CAN_FD1_IsTxErrorActive CAN1_IsTxErrorActive |
#define CAN_FD1_IsTxErrorPassive CAN1_IsTxErrorPassive |
#define CAN_FD1_IsTxErrorWarning CAN1_IsTxErrorWarning |
#define CAN_FD1_ModeChangeCallbackRegister CAN1_ModeChangeCallbackRegister |
#define CAN_FD1_OperationModeGet CAN1_OperationModeGet |
#define CAN_FD1_OperationModeSet CAN1_OperationModeSet |
#define CAN_FD1_Receive CAN1_Receive |
#define CAN_FD1_ReceivedMessageCountGet CAN1_ReceivedMessageCountGet |
#define CAN_FD1_ReceiveMessageGet CAN1_ReceiveMessageGet |
#define CAN_FD1_RX_FIFO_StatusGet CAN1_RX_FIFO_StatusGet |
#define CAN_FD1_RxBufferOverFlowCallbackRegister CAN1_RxBufferOverFlowCallbackRegister |
#define CAN_FD1_Sleep CAN1_Sleep |
#define CAN_FD1_SystemErrorCallbackRegister CAN1_SystemErrorCallbackRegister |
#define CAN_FD1_Tasks CAN1_Tasks |
#define CAN_FD1_Transmit CAN1_Transmit |
#define CAN_FD1_TransmitFIFOStatusGet CAN1_TransmitFIFOStatusGet |
#define CAN_FD1_TxAttemptCallbackRegister CAN1_TxAttemptCallbackRegister |
#define CAN_FD_MESSAGE_FORMAT_FEATURE_AVAILABLE 1 |
IMPORTANT******** This file defines the CAN module feature C-macros available on the selected device. The macros defined in this file provides the flexibility to easily migrate the user application to other device which might have varied feature list.
The file has to be manually included in main.c, if the user intends to migrate the application to another device which might have varied feature list.
The content in this file is strictly "read only" and should
not be altered. Failing to do so, the migration is not guaranteed.************* Macros defined for features supported in the device
APIs Supported:
CAN_TX_MSG_REQUEST_STATUS CANx_Transmit(const CANx_TX_FIFO_CHANNELS fifoChannel, CAN_MSG_OBJ *txCanMsg); bool CANx_Receive(CAN_MSG_OBJ *rxCanMsg); x denotes instance of CAN in CANx. Refer to device specific datasheet to check number of CAN module instance. Refer driver header file for detailed description of the APIs.
Definition at line 80 of file can_features.h.
#define CAN_FIFO_BASED_TRANSMIT_PRIORITY_FEATURE_AVAILABLE 1 |
APIs Supported:
CAN_TX_MSG_REQUEST_STATUS CANx_Transmit(const CANx_TX_FIFO_CHANNELS fifoChannel, CAN_MSG_OBJ *txCanMsg); CAN_TX_FIFO_STATUS CANx_TransmitFIFOStatusGet(const CANx_TX_FIFO_CHANNELS fifoChannel);
x denotes instance of CAN in CANx. Refer to device specific datasheet to check number of CAN module instance. Refer driver header file for detailed description of the APIs.
Definition at line 94 of file can_features.h.
enum CAN_DLC |
Definition at line 176 of file can_types.h.
enum CAN_MSG_OBJ_BRS_MODE |
Enumerator | |
---|---|
CAN_NON_BRS_MODE | Disable BRS Mode (Supported only in CAN FD mode) |
CAN_BRS_MODE | Enable BRS Mode (Supported only in CAN FD mode) |
Definition at line 79 of file can_types.h.
Enumerator | |
---|---|
CAN_FRAME_DATA | Data Frame CAN message object |
CAN_FRAME_RTR | Remote Transmit Request Frame CAN message object |
Definition at line 101 of file can_types.h.
enum CAN_MSG_OBJ_ID_TYPE |
Enumerator | |
---|---|
CAN_FRAME_STD | Standard ID CAN message object |
CAN_FRAME_EXT | Extended ID CAN message object |
Definition at line 90 of file can_types.h.
enum CAN_MSG_OBJ_TYPE |
Enumerator | |
---|---|
CAN_2_0_FORMAT | CAN 2.0 Message format |
CAN_FD_FORMAT | CAN FD Message format (Supported only in CAN FD mode) |
Definition at line 112 of file can_types.h.
enum CAN_OP_MODE_STATUS |
Definition at line 153 of file can_types.h.
enum CAN_OP_MODES |
Definition at line 136 of file can_types.h.
enum CAN_TX_FIFO_STATUS |
Enumerator | |
---|---|
CAN_TX_FIFO_FULL | Defines the Transmit FIFO is full |
CAN_TX_FIFO_AVAILABLE | Defines the Transmit FIFO is available |
Definition at line 165 of file can_types.h.
Definition at line 123 of file can_types.h.
|
static |
void CAN1_BusErrorCallback | ( | void | ) |
void CAN1_BusErrorCallbackRegister | ( | void(*)(void) | handler | ) |
void CAN1_BusWakeUpActivityCallback | ( | void | ) |
void CAN1_BusWakeUpActivityCallbackRegister | ( | void(*)(void) | handler | ) |
void CAN1_Deinitialize | ( | void | ) |
|
static |
|
static |
|
static |
void CAN1_Initialize | ( | void | ) |
void CAN1_InvalidMessageCallback | ( | void | ) |
void CAN1_InvalidMessageCallbackRegister | ( | void(*)(void) | handler | ) |
bool CAN1_IsBusOff | ( | void | ) |
none |
bool CAN1_IsRxErrorActive | ( | void | ) |
none |
bool CAN1_IsRxErrorPassive | ( | void | ) |
none |
bool CAN1_IsRxErrorWarning | ( | void | ) |
none |
bool CAN1_IsTxErrorActive | ( | void | ) |
none |
bool CAN1_IsTxErrorPassive | ( | void | ) |
none |
bool CAN1_IsTxErrorWarning | ( | void | ) |
none |
|
static |
|
static |
void CAN1_ModeChangeCallback | ( | void | ) |
void CAN1_ModeChangeCallbackRegister | ( | void(*)(void) | handler | ) |
enum CAN_OP_MODES CAN1_OperationModeGet | ( | void | ) |
none |
Definition at line 656 of file can1.c.
enum CAN_OP_MODE_STATUS CAN1_OperationModeSet | ( | const enum CAN_OP_MODES | requestMode | ) |
[in] | requestMode | - CAN1 operation modes |
Definition at line 629 of file can1.c.
bool CAN1_Receive | ( | struct CAN_MSG_OBJ * | rxCanMsg | ) |
[out] | rxCanMsg | - pointer to the message object |
Definition at line 661 of file can1.c.
uint8_t CAN1_ReceivedMessageCountGet | ( | void | ) |
none |
Definition at line 812 of file can1.c.
bool CAN1_ReceiveMessageGet | ( | const enum CAN1_RX_FIFO_CHANNELS | fifoChannel, |
struct CAN_MSG_OBJ * | rxCanMsg ) |
[out] | rxCanMsg | - pointer to the message object |
Definition at line 707 of file can1.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
uint8_t CAN1_RX_FIFO_StatusGet | ( | const enum CAN1_RX_FIFO_CHANNELS | fifoNum | ) |
[in] | fifoNum | - FIFO channel of which status is required |
Definition at line 862 of file can1.c.
void CAN1_RxBufferOverFlowCallback | ( | void | ) |
void CAN1_RxBufferOverFlowCallbackRegister | ( | void(*)(void) | handler | ) |
|
static |
void CAN1_Sleep | ( | void | ) |
none |
Definition at line 927 of file can1.c.
void CAN1_SystemErrorCallback | ( | void | ) |
void CAN1_SystemErrorCallbackRegister | ( | void(*)(void) | handler | ) |
void CAN1_Tasks | ( | void | ) |
none |
enum CAN_TX_MSG_REQUEST_STATUS CAN1_Transmit | ( | const enum CAN1_TX_FIFO_CHANNELS | fifoChannel, |
struct CAN_MSG_OBJ * | txCanMsg ) |
[in] | fifoChannel | - FIFO channel where the message object to be written |
[in] | txCanMsg | - pointer to the message object |
Definition at line 746 of file can1.c.
enum CAN_TX_FIFO_STATUS CAN1_TransmitFIFOStatusGet | ( | const enum CAN1_TX_FIFO_CHANNELS | fifoChannel | ) |
[in] | fifoChannel | - CAN1 TX priority FIFO selection |
Definition at line 794 of file can1.c.
|
static |
|
static |
void CAN1_TxAttemptCallback | ( | void | ) |
void CAN1_TxAttemptCallbackRegister | ( | void(*)(void) | handler | ) |
|
extern |