|  | Dual Active Bridge Development Board (Part-No. ) |
Content |  |  |  |  |  |

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
can1.c File Reference
MPLABX MCC Melody Code Generator » CAN FD Driver

This is the generated driver source file for CAN1 driver using CCL. More...

`#include <string.h>`
`#include "../can_types.h"`
`#include "../can1.h"`
Include dependency graph for can1.c:

Go to the source code of this file.

## Data Structures
struct | CAN1_FIFO_INFO

## Macros
#define | CAN1_FIFO_ALLOCATE_RAM_SIZE 360U
#define | CAN1_NUM_OF_RX_FIFO 2U
#define | CAN1_RX_FIFO_MSG_DATA 64U
#define | CAN_RX_FIFO_WORD_0 0
#define | CAN_RX_FIFO_WORD_1 1
#define | CAN_RX_FIFO_WORD_2 2
#define | CAN_RX_FIFO_WORD_4 4
#define | CAN1_TX_MSG_SEND_REQ_BIT_POS 0x200U
#define | CAN1_TX_INC_FIFO_PTR_BIT_POS 0x100U
#define | CAN_TX_FIFO_WORD_0 0
#define | CAN_TX_FIFO_WORD_1 1
#define | CAN_TX_FIFO_WORD_2 2
#define | CAN_TX_FIFO_WORD_4 4
#define | CAN_MSG_OBJ_DLC_FIELD_SIZE 0xFU
#define | CAN_MSG_OBJ_ID_TYPE_FIELD_POS 0x10U
#define | CAN_MSG_OBJ_ID_TYPE_SHIFT_POS 0x4U
#define | CAN_MSG_OBJ_RTR_SHIFT_POS 0x5U
#define | CAN_MSG_OBJ_RTR_FIELD_POS 0x20U
#define | CAN_MSG_OBJ_FRAME_TYPE_FIELD_POS 0x20U
#define | CAN_MSG_OBJ_FRAME_TYPE_SHIFT_POS 0x5U
#define | CAN_MSG_OBJ_BRS_FIELD_POS 0x40U
#define | CAN_MSG_OBJ_BRS_SHIFT_POS 0x6U
#define | CAN_MSG_OBJ_FORMAT_TYPE_FIELD_POS 0x80U
#define | CAN_MSG_OBJ_FORMAT_TYPE_SHIFT_POS 0x7U
#define | CAN_STD_MSG_ID_MAX_SIZE 0x7FFU
#define | CAN_MSG_OBJ_SID_SHIFT_POS 0x12U
#define | CAN_EXT_MSG_ID_HIGH_MAX_SIZE 0x1FFFU
#define | CAN_EXT_MSG_ID_LOW_MAX_SIZE 0x1FU
#define | CAN_MSG_OBJ_EID_LOW_SHIFT_POS 0xBU
#define | CAN_MSG_OBJ_EID_HIGH_SHIFT_POS 0x5U

## Functions
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.
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.
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.
bool | CAN1_IsBusOff (void)
| Returns the bus off status.
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.
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.
void | CAN1_Sleep (void)
| Sets the CAN node in sleep mode.
void | CAN1_InvalidMessageCallbackRegister (void(*handler)(void))
| This function can be used to override default callback and to define custom callback for CAN1_InvalidMessageCallback.
void | __attribute__ ((weak))
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_BusErrorCallbackRegister (void(*handler)(void))
| This function can be used to override default callback and to define custom callback for CAN1_BusErrorCallback.
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_SystemErrorCallbackRegister (void(*handler)(void))
| This function can be used to override default callback and to define custom callback for CAN1_SystemErrorCallback.
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_RxBufferOverFlowCallbackRegister (void(*handler)(void))
| This function can be used to override default callback and to define custom callback for CAN1_RxBufferOverFlowCallback.
void | __attribute__ ((__interrupt__, no_auto_psv))
void | CAN1_Tasks (void)
| This routine is used to implement the tasks for polled implementations.

## 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.
static volatile struct CAN1_RX_FIFO_MSG | rxFIFOMsg [CAN1_NUM_OF_RX_FIFO]

## Detailed Description

CAN1 Generated Driver Source File

Definition in file can1.c.

## Macro Definition Documentation

## ◆ CAN1_FIFO_ALLOCATE_RAM_SIZE

#define CAN1_FIFO_ALLOCATE_RAM_SIZE 360U

Definition at line 45 of file can1.c.

## ◆ CAN1_NUM_OF_RX_FIFO

#define CAN1_NUM_OF_RX_FIFO 2U

Definition at line 48 of file can1.c.

## ◆ CAN1_RX_FIFO_MSG_DATA

#define CAN1_RX_FIFO_MSG_DATA 64U

Definition at line 49 of file can1.c.

## ◆ CAN1_TX_INC_FIFO_PTR_BIT_POS

#define CAN1_TX_INC_FIFO_PTR_BIT_POS 0x100U

Definition at line 57 of file can1.c.

## ◆ CAN1_TX_MSG_SEND_REQ_BIT_POS

#define CAN1_TX_MSG_SEND_REQ_BIT_POS 0x200U

Definition at line 56 of file can1.c.

## ◆ CAN_EXT_MSG_ID_HIGH_MAX_SIZE

#define CAN_EXT_MSG_ID_HIGH_MAX_SIZE 0x1FFFU

Definition at line 77 of file can1.c.

## ◆ CAN_EXT_MSG_ID_LOW_MAX_SIZE

#define CAN_EXT_MSG_ID_LOW_MAX_SIZE 0x1FU

Definition at line 78 of file can1.c.

## ◆ CAN_MSG_OBJ_BRS_FIELD_POS

#define CAN_MSG_OBJ_BRS_FIELD_POS 0x40U

Definition at line 71 of file can1.c.

## ◆ CAN_MSG_OBJ_BRS_SHIFT_POS

#define CAN_MSG_OBJ_BRS_SHIFT_POS 0x6U

Definition at line 72 of file can1.c.

## ◆ CAN_MSG_OBJ_DLC_FIELD_SIZE

#define CAN_MSG_OBJ_DLC_FIELD_SIZE 0xFU

Definition at line 64 of file can1.c.

## ◆ CAN_MSG_OBJ_EID_HIGH_SHIFT_POS

#define CAN_MSG_OBJ_EID_HIGH_SHIFT_POS 0x5U

Definition at line 80 of file can1.c.

## ◆ CAN_MSG_OBJ_EID_LOW_SHIFT_POS

#define CAN_MSG_OBJ_EID_LOW_SHIFT_POS 0xBU

Definition at line 79 of file can1.c.

## ◆ CAN_MSG_OBJ_FORMAT_TYPE_FIELD_POS

#define CAN_MSG_OBJ_FORMAT_TYPE_FIELD_POS 0x80U

Definition at line 73 of file can1.c.

## ◆ CAN_MSG_OBJ_FORMAT_TYPE_SHIFT_POS

#define CAN_MSG_OBJ_FORMAT_TYPE_SHIFT_POS 0x7U

Definition at line 74 of file can1.c.

## ◆ CAN_MSG_OBJ_FRAME_TYPE_FIELD_POS

#define CAN_MSG_OBJ_FRAME_TYPE_FIELD_POS 0x20U

Definition at line 69 of file can1.c.

## ◆ CAN_MSG_OBJ_FRAME_TYPE_SHIFT_POS

#define CAN_MSG_OBJ_FRAME_TYPE_SHIFT_POS 0x5U

Definition at line 70 of file can1.c.

## ◆ CAN_MSG_OBJ_ID_TYPE_FIELD_POS

#define CAN_MSG_OBJ_ID_TYPE_FIELD_POS 0x10U

Definition at line 65 of file can1.c.

## ◆ CAN_MSG_OBJ_ID_TYPE_SHIFT_POS

#define CAN_MSG_OBJ_ID_TYPE_SHIFT_POS 0x4U

Definition at line 66 of file can1.c.

## ◆ CAN_MSG_OBJ_RTR_FIELD_POS

#define CAN_MSG_OBJ_RTR_FIELD_POS 0x20U

Definition at line 68 of file can1.c.

## ◆ CAN_MSG_OBJ_RTR_SHIFT_POS

#define CAN_MSG_OBJ_RTR_SHIFT_POS 0x5U

Definition at line 67 of file can1.c.

## ◆ CAN_MSG_OBJ_SID_SHIFT_POS

#define CAN_MSG_OBJ_SID_SHIFT_POS 0x12U

Definition at line 76 of file can1.c.

## ◆ CAN_RX_FIFO_WORD_0

#define CAN_RX_FIFO_WORD_0 0

Definition at line 50 of file can1.c.

## ◆ CAN_RX_FIFO_WORD_1

#define CAN_RX_FIFO_WORD_1 1

Definition at line 51 of file can1.c.

## ◆ CAN_RX_FIFO_WORD_2

#define CAN_RX_FIFO_WORD_2 2

Definition at line 52 of file can1.c.

## ◆ CAN_RX_FIFO_WORD_4

#define CAN_RX_FIFO_WORD_4 4

Definition at line 53 of file can1.c.

## ◆ CAN_STD_MSG_ID_MAX_SIZE

#define CAN_STD_MSG_ID_MAX_SIZE 0x7FFU

Definition at line 75 of file can1.c.

## ◆ CAN_TX_FIFO_WORD_0

#define CAN_TX_FIFO_WORD_0 0

Definition at line 58 of file can1.c.

## ◆ CAN_TX_FIFO_WORD_1

#define CAN_TX_FIFO_WORD_1 1

Definition at line 59 of file can1.c.

## ◆ CAN_TX_FIFO_WORD_2

#define CAN_TX_FIFO_WORD_2 2

Definition at line 60 of file can1.c.

## ◆ CAN_TX_FIFO_WORD_4

#define CAN_TX_FIFO_WORD_4 4

Definition at line 61 of file can1.c.

## Function Documentation

## ◆ __attribute__() [1/2]

void __attribute__ | ( | (__interrupt__, no_auto_psv) |  | ) |

Definition at line 1076 of file can1.c.

## ◆ __attribute__() [2/2]

void __attribute__ | ( | (weak) |  | ) |

Definition at line 993 of file can1.c.

## Variable Documentation

## ◆ rxFIFOMsg

volatile struct CAN1_RX_FIFO_MSG rxFIFOMsg[CAN1_NUM_OF_RX_FIFO]
| static

Initial value:
=
{
{CAN1_FIFO_1, 0U},
{CAN1_FIFO_2, 0U},
}
CAN1_FIFO_2
@ CAN1_FIFO_2
Definition can1.h:228
CAN1_FIFO_1
@ CAN1_FIFO_1
Definition can1.h:227

Definition at line 140 of file can1.c.