canfd
Vitis Drivers API Documentation
xcanfd.h File Reference

Data Structures

struct  XCanFd_Config
 This typedef contains configuration information for a device. More...
 
struct  XCanFd
 The XCanFd driver instance data. More...
 

Macros

#define XCANFD_H
 by using protection macros More...
 
#define XCanFd_IsTxDone(InstancePtr)
 This macro checks if the transmission is complete. More...
 
#define XCanFd_CreateIdValue(StandardId, SubRemoteTransReq, IdExtension, ExtendedId, RemoteTransReq)
 This macro calculates CAN message identifier value given identifier field values. More...
 
#define XCanFd_Create_CanFD_DlcValue(DataLengCode)
 This macro calculates value for Data Length Code register given Data Length Code value with EDL set to 1(Only Can FD frames). More...
 
#define XCanFd_Create_CanFD_Dlc_BrsValue(DataLengCode)
 This macro calculates value for Data Length Code register given Data Length Code value with EDL set to 1(Only Can FD frames) and Setting the BRS. More...
 
#define XCanFd_CreateDlcValue(DataLengCode)   ((((DataLengCode) << XCANFD_DLCR_DLC_SHIFT) & XCANFD_DLCR_DLC_MASK))
 This macro calculates value for Data Length Code register given Data Length Code value i.e Only Stand. More...
 
#define XCanFd_IsBufferTransmitted(InstancePtr, TxBuffer)
 This macro checks whether Particular Buffer is Transmitted or not. More...
 
#define MAKE_CURRENTBUFFER_ZERO(InstancePtr)
 This macro initializes CurrentBuffer[32] to zeros. More...
 
#define XCANFD_TXID_OFFSET(FreeBuffer)   (XCANFD_TXFIFO_0_BASE_ID_OFFSET+((UINTPTR)FreeTxBuffer*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the TXBUFFER ID Offset. More...
 
#define XCANFD_TXDLC_OFFSET(FreeBuffer)   (XCANFD_TXFIFO_0_BASE_DLC_OFFSET+((UINTPTR)FreeTxBuffer*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the TXBUFFER DLC Offset. More...
 
#define XCANFD_TXDW_OFFSET(FreeBuffer)   (XCANFD_TXFIFO_0_BASE_DW0_OFFSET+((UINTPTR)FreeTxBuffer*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the TXBUFFER DW Offset. More...
 
#define XCANFD_TXEID_OFFSET(TXEVENTIndex)   (XCANFD_TXEFIFO_0_BASE_ID_OFFSET+((UINTPTR)TXEVENTIndex*XCANFD_TXE_MESSAGE_SIZE))
 This macro Returns the TX Event Buffer ID Offset. More...
 
#define XCANFD_TXEDLC_OFFSET(TXEVENTIndex)   (XCANFD_TXEFIFO_0_BASE_DLC_OFFSET+((UINTPTR)TXEVENTIndex*XCANFD_TXE_MESSAGE_SIZE))
 This macro Returns the TX Event Buffer DLC Offset. More...
 
#define XCANFD_RXID_OFFSET(ReadIndex)   (XCANFD_RXFIFO_0_BASE_ID_OFFSET+((UINTPTR)ReadIndex*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the RXBUFFER ID Offset. More...
 
#define XCANFD_RXDLC_OFFSET(ReadIndex)   (XCANFD_RXFIFO_0_BASE_DLC_OFFSET+((UINTPTR)ReadIndex*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the RXBUFFER DLC Offset. More...
 
#define XCANFD_RXDW_OFFSET(ReadIndex)   (XCANFD_RXFIFO_0_BASE_DW0_OFFSET+((UINTPTR)ReadIndex*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the RXBUFFER DW Offset. More...
 
#define XCANFD_FIFO_1_RXID_OFFSET(ReadIndex)   (XCANFD_RXFIFO_1_BUFFER_0_BASE_ID_OFFSET+((UINTPTR)ReadIndex*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the RXBUFFER ID Offset for FIFO 1. More...
 
#define XCANFD_FIFO_1_RXDLC_OFFSET(ReadIndex)   (XCANFD_RXFIFO_1_BUFFER_0_BASE_DLC_OFFSET+((UINTPTR)ReadIndex*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the RXBUFFER DLC Offset for FIFO 1. More...
 
#define XCANFD_FIFO_1_RXDW_OFFSET(ReadIndex)   (XCANFD_RXFIFO_1_BUFFER_0_BASE_DW0_OFFSET+((UINTPTR)ReadIndex*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the RXBUFFER DW Offset for FIFO 1. More...
 
#define XCANFD_RCS_OFFSET(NoCtrlStatus)   (XCANFD_RCS0_OFFSET+((UINTPTR)NoCtrlStatus*4U))
 This macro Returns the RCS Register Offset. More...
 
#define XCANFD_AFMR_OFFSET(FilterIndex)
 This macro Returns the AFMR Register Offset. More...
 
#define XCANFD_AFIDR_OFFSET(FilterIndex)
 This macro Returns the AFIDR Registger Offset. More...
 
#define XCANFD_MAILBOX_MASK_OFFSET(BufferNr)   (XCANFD_MAILBOX_RB_MASK_BASE_OFFSET+((UINTPTR)BufferNr*4U))
 This macro Returns the MAILBOX MODE RXMASK Offset. More...
 
#define XCANFD_MAILBOX_ID_OFFSET(BufferNr)   (XCANFD_RXFIFO_0_BASE_ID_OFFSET+((UINTPTR)BufferNr*XCANFD_MAX_FRAME_SIZE))
 This macro Returns the MAILBOX MODE ID Offset. More...
 
#define XCANFD_GET_RX_MODE(InstancePtr)   ((InstancePtr)->CanFdConfig.Rx_Mode)
 This macro Returns Design mode 1- Mailbox 0- Sequential. More...
 
#define XCanFd_Reset(InstancePtr)
 This function resets the CAN device. More...
 
#define XCanFd_GetBusErrorStatus(InstancePtr)   XCanFd_ReadReg(InstancePtr->CanFdConfig.BaseAddress, XCANFD_ESR_OFFSET)
 This function reads Error Status value from Error Status Register (ESR). More...
 
#define XCanFd_GetStatus(InstancePtr)   XCanFd_ReadReg(InstancePtr->CanFdConfig.BaseAddress, XCANFD_SR_OFFSET)
 This function returns Status value from Status Register (SR). More...
 
#define XCanFd_ClearBusErrorStatus(InstancePtr, Mask)
 This function clears Error Status bit(s) previously set in Error Status Register (ESR). More...
 
#define XCanFd_Get_Tranceiver_Delay_CompensationOffset(InstancePtr)
 This function returns the Tranceive delay comensation Offset. More...
 
#define XCanFd_ClearTImeStamp_Count(InstancePtr)
 This function Clears Time Stamp Counter Value. More...
 
#define XCanFd_GetTImeStamp_Count(InstancePtr)
 This function returns Time Stamp Counter Value. More...
 
#define XCanFd_GetRxIntrWatermark(InstancePtr)
 This routine returns the Rx water Mark threshold Value. More...
 
#define XCanFd_InterruptGetEnabled(InstancePtr)   XCanFd_ReadReg(InstancePtr->CanFdConfig.BaseAddress, XCANFD_IER_OFFSET)
 This routine returns enabled interrupt(s). More...
 
#define XCanFd_InterruptGetStatus(InstancePtr)   XCanFd_ReadReg(InstancePtr->CanFdConfig.BaseAddress, XCANFD_ISR_OFFSET)
 This routine returns interrupt status read from Interrupt Status Register. More...
 
#define XCanFd_Get_NofRxBuffers(InstancePtr)
 This routine returns Number of RCS registers to access because in Mail box mode user can configure 48,32,16 Rx Buffers. More...
 
#define XCanFd_Get_RxBuffers(InstancePtr)   InstancePtr->CanFdConfig.NumofRxMbBuf;
 This routine returns Number of RxBuffers user can Desing RxBuffers as 48,32,16. More...
 
#define XCanFD_Check_TrrVal_Set_Bit(Var)   ((Var)&(~(Var) + (u32)1))
 This routine returns Number with right most bit set from the target input value. More...
 
CAN normal Bit rate fields
#define XCANFD_MAX_SJW_VALUE   0x80
 Synchronization Jump Width. More...
 
#define XCANFD_MAX_TS1_VALUE   0x100
 Time Segment 1. More...
 
#define XCANFD_MAX_TS2_VALUE   0x80
 Time Segment 2. More...
 
CAN Fast Bit rate fields
#define XCANFD_MAX_F_SJW_VALUE   0x10
 Synchronization Jump Width for Data Phase. More...
 
#define XCANFD_MAX_F_TS1_VALUE   0x20
 Time Segment 1 for Data Phase. More...
 
#define XCANFD_MAX_F_TS2_VALUE   0x10
 Time Segment 2 for Data Phase. More...
 
CAN operation modes
#define XCANFD_MODE_CONFIG   0x00000001
 Configuration mode. More...
 
#define XCANFD_MODE_NORMAL   0x00000002
 Normal mode. More...
 
#define XCANFD_MODE_LOOPBACK   0x00000004
 Loop Back mode. More...
 
#define XCANFD_MODE_SLEEP   0x00000008
 Sleep mode. More...
 
#define XCANFD_MODE_SNOOP   0x00000010
 Snoop mode. More...
 
#define XCANFD_MODE_ABR   0x00000020
 Auto Bus-Off Recovery. More...
 
#define XCANFD_MODE_SBR   0x00000040
 Starut Bus-Off Recovery. More...
 
#define XCANFD_MODE_PEE   0x00000080
 Protocol Exception mode. More...
 
#define XCANFD_MODE_DAR   0x0000000A
 Disable Auto Retransmission mode. More...
 
#define XCANFD_MODE_BR   0x0000000B
 Bus-Off Recovery Mode. More...
 
#define XCANFD_RX_FIFO_0   0
 Selection for RX Fifo 0. More...
 
#define XCANFD_RX_FIFO_1   1
 Selection for RX Fifo 1. More...
 
Callback identifiers used as parameters to XCanFd_SetHandler()
#define XCANFD_HANDLER_SEND   1
 Handler type for frame sending interrupt. More...
 
#define XCANFD_HANDLER_RECV   2
 Handler type for frame reception interrupt. More...
 
#define XCANFD_HANDLER_ERROR   3
 Handler type for error interrupt. More...
 
#define XCANFD_HANDLER_EVENT   4
 Handler type for all other interrupts. More...
 

Typedefs

typedef void(* XCanFd_SendRecvHandler )(void *CallBackRef)
 Callback type for frame sending and reception interrupts. More...
 
typedef void(* XCanFd_ErrorHandler )(void *CallBackRef, u32 ErrorMask)
 Callback type for error interrupt. More...
 
typedef void(* XCanFd_EventHandler )(void *CallBackRef, u32 Mask)
 Callback type for all kinds of interrupts except sending frame interrupt, receiving frame interrupt, and error interrupt. More...
 

Functions

int XCanFd_CfgInitialize (XCanFd *InstancePtr, XCanFd_Config *ConfigPtr, UINTPTR EffectiveAddr)
 This routine initializes a specific XCanFd instance/driver. More...
 
int XCanFd_stop (XCanFd *InstancePtr)
 This routine releases resources of XCanFd instance/driver. More...
 
u8 XCanFd_GetMode (XCanFd *InstancePtr)
 This routine returns current operation mode the CAN device is in. More...
 
void XCanFd_EnterMode (XCanFd *InstancePtr, u8 OperationMode)
 This function allows the CAN device to enter one of the following operation modes: More...
 
void XCanFd_GetBusErrorCounter (XCanFd *InstancePtr, u8 *RxErrorCount, u8 *TxErrorCount)
 This function reads Receive and Transmit error counters. More...
 
int XCanFd_Send (XCanFd *InstancePtr, u32 *FramePtr, u32 *TxBufferNumber)
 This function sends a CAN/CANFD Frame. More...
 
void XCanFd_AcceptFilterEnable (XCanFd *InstancePtr, u32 FilterIndexMask)
 This routine enables the acceptance filters. More...
 
void XCanFd_AcceptFilterDisable (XCanFd *InstancePtr, u32 FilterIndexMask)
 This routine disables the acceptance filters. More...
 
u32 XCanFd_AcceptFilterGetEnabled (XCanFd *InstancePtr)
 This function returns enabled acceptance filters. More...
 
int XCanFd_AcceptFilterSet (XCanFd *InstancePtr, u32 FilterIndex, u32 MaskValue, u32 IdValue)
 This function sets values to the Acceptance Filter Mask Register (AFMR) and Acceptance Filter ID Register (AFIR) for the specified Acceptance Filter. More...
 
void XCanFd_AcceptFilterGet (XCanFd *InstancePtr, u32 FilterIndex, u32 *MaskValue, u32 *IdValue)
 This function reads the values of the Acceptance Filter Mask and ID Register for the specified Acceptance Filter. More...
 
XCanFd_ConfigXCanFd_LookupConfig (u16 DeviceId)
 This function looks for the device configuration based on the unique device ID. More...
 
XCanFd_ConfigXCanFd_GetConfig (unsigned int InstanceIndex)
 This function looks for the device configuration based on the device index. More...
 
int XCanFd_GetDlc2len (u32 Dlc, u32 Edl)
 This function returns Data Length Code(in Bytes),we need to pass DLC Field value in DLC Register. More...
 
u8 XCanFd_GetLen2Dlc (int len)
 This function returns Data Length Code of 4bits,we need to pass length in bytes. More...
 
u32 XCanFd_GetFreeBuffer (XCanFd *InstancePtr)
 This Routine returns the Free Buffers count out of 32 Transmit Buffers. More...
 
int XCanFd_Send_Queue (XCanFd *InstancePtr)
 This routine sends queue of buffers,when added to queue using Addto_Queue() Basically this will trigger the TRR Bit(s).This routine can be used when user want to send multiple packets at a time. More...
 
int XCanFd_Addto_Queue (XCanFd *InstancePtr, u32 *FramePtr, u32 *TxBufferNumber)
 This function writes the Data into specific Buffer.we have 32 TxBuffers we can Add data to each Buffer using this routine.This routine won't transmit the data. More...
 
u32 XCanFd_RxBuff_MailBox_Active (XCanFd *InstancePtr, u32 RxBuffer)
 This function sets an RxBuffer to Active State.In Mailbox Mode configuration we can set each buffer to receive with specific Id and Mask.inorder compare we need to first Activate the Buffer.Maximum number of RxBuffers depends on Design.Range 48,32,16. More...
 
u32 XCanFd_RxBuff_MailBox_DeActive (XCanFd *InstancePtr, u32 RxBuffer)
 This function sets an RxBuffer to InActive State.if we change a buffer to InActive state, then Rx Packet won't store into that buffer, even the Id is matched. More...
 
u32 XCanFd_Set_MailBox_IdMask (XCanFd *InstancePtr, u32 RxBuffer, u32 MaskValue, u32 IdValue)
 This function sets the Id and Mask for an RxBuffer to participate in Id match.if a packet is received with an id which is equal to id we configured, then it is stored in RxBuffer. More...
 
u32 XCanFd_Recv_Sequential (XCanFd *InstancePtr, u32 *FramePtr)
 This function receives a CAN/CAN FD Frame. More...
 
u32 XCanFd_Recv_Mailbox (XCanFd *InstancePtr, u32 *FramePtr)
 This function receives a CAN Frame in MAIL BOX Mode. More...
 
u32 XCanFd_Recv_TXEvents_Sequential (XCanFd *InstancePtr, u32 *FramePtr)
 This function receives a CAN/CAN FD TX Events. More...
 
void XCanFd_PollQueue_Buffer (XCanFd *InstancePtr)
 This function Polls the TxBuffer(s) whether it is transmitted or not. More...
 
int XCanFd_GetNofMessages_Stored_Rx_Fifo (XCanFd *InstancePtr, u8 fifo_no)
 This function returns Number of messages Stored. More...
 
int XCanFd_GetNofMessages_Stored_TXE_FIFO (XCanFd *InstancePtr)
 This function returns Number of messages Stored in TX Event FIFO The FSR Register has Field called FL. More...
 
int XCanFd_TxBuffer_Cancel_Request (XCanFd *InstancePtr, u32 BufferNumber)
 This function Cancels a CAN/CAN FD Frame which was already initiated for transmission.This function first checks TRR Bit based on BufferNumber. More...
 
void XCanFd_Enable_Tranceiver_Delay_Compensation (XCanFd *InstancePtr)
 This function Enables the Transceiver delay compensation. More...
 
void XCanFd_Set_Tranceiver_Delay_Compensation (XCanFd *InstancePtr, u32 TdcOffset)
 This function Sets the Transceiver delay compensation offset. More...
 
void XCanFd_Disable_Tranceiver_Delay_Compensation (XCanFd *InstancePtr)
 This function Disables the Transceiver delay compensation. More...
 
void XCanFd_Pee_BusOff_Handler (XCanFd *InstancePtr)
 This function recovers the CAN device from Protocol Exception Event & Busoff Event States. More...
 
int XCanFd_SetBaudRatePrescaler (XCanFd *InstancePtr, u8 Prescaler)
 This routine sets Baud Rate Prescaler value in Arbitration Phse. More...
 
u8 XCanFd_GetBaudRatePrescaler (XCanFd *InstancePtr)
 This routine gets Baud Rate Prescaler value. More...
 
u8 XCanFd_GetFBaudRatePrescaler (XCanFd *InstancePtr)
 This routine gets Baud Rate Prescaler value in Data Phase. More...
 
int XCanFd_SetBitTiming (XCanFd *InstancePtr, u8 SyncJumpWidth, u8 TimeSegment2, u16 TimeSegment1)
 This routine sets Bit time. More...
 
void XCanFd_GetBitTiming (XCanFd *InstancePtr, u8 *SyncJumpWidth, u8 *TimeSegment2, u8 *TimeSegment1)
 This routine gets Bit time. More...
 
void XCanFd_GetFBitTiming (XCanFd *InstancePtr, u8 *SyncJumpWidth, u8 *TimeSegment2, u8 *TimeSegment1)
 This routine gets Bit time in Data Phase. More...
 
int XCanFd_SetFBaudRatePrescaler (XCanFd *InstancePtr, u8 Prescaler)
 This routine sets Baud Rate Prescaler value in Data Phase. More...
 
int XCanFd_SetFBitTiming (XCanFd *InstancePtr, u8 SyncJumpWidth, u8 TimeSegment2, u8 TimeSegment1)
 This routine sets Bit time in Data Phase. More...
 
void XCanFd_SetBitRateSwitch_DisableNominal (XCanFd *InstancePtr)
 This routine Disables the BRSD bit, so that Bit Rate Switch can be happen with Nominal or configured rate. More...
 
void XCanFd_SetBitRateSwitch_EnableNominal (XCanFd *InstancePtr)
 This routine sets the Bit Rate Switch with nominal bit rate. More...
 
u32 XCanFd_SetRxIntrWatermark (XCanFd *InstancePtr, s8 Threshold)
 This routine sets the Rx Full threshold in the Watermark Interrupt Register. More...
 
u32 XCanFd_SetRxIntrWatermarkFifo1 (XCanFd *InstancePtr, s8 Threshold)
 This routine sets the Rx Full threshold in the Watermark Interrupt Register. More...
 
u32 XCanFd_SetTxEventIntrWatermark (XCanFd *InstancePtr, u8 Threshold)
 This routine sets the TX Events Full threshold in the Watermark Interrupt Register. More...
 
u32 XCanFd_SetRxFilterPartition (XCanFd *InstancePtr, u8 FilterPartition)
 This routine sets the Receive filter partition in the Watermark Interrupt Register. More...
 
int XCanFd_SelfTest (XCanFd *InstancePtr)
 This function runs a self-test on the CAN driver/device. More...
 
void XCanFd_InterruptEnable (XCanFd *InstancePtr, u32 Mask)
 This routine enables interrupt(s). More...
 
void XCanFd_InterruptDisable (XCanFd *InstancePtr, u32 Mask)
 This routine disables interrupt(s). More...
 
void XCanFd_InterruptClear (XCanFd *InstancePtr, u32 Mask)
 This function clears interrupt(s). More...
 
void XCanFd_IntrHandler (void *InstancePtr)
 This routine is the interrupt handler for the CAN driver. More...
 
int XCanFd_SetHandler (XCanFd *InstancePtr, u32 HandlerType, void *CallBackFunc, void *CallBackRef)
 This routine installs an asynchronous callback function for the given HandlerType: More...
 
void XCanFd_InterruptEnable_ReadyRqt (XCanFd *InstancePtr, u32 Mask)
 This routine enables TxBuffer Ready Request interrupt(s). More...
 
void XCanFd_InterruptEnable_CancelRqt (XCanFd *InstancePtr, u32 Mask)
 This routine enables TxBuffer Cancellation interrupt(s). More...
 
void XCanFd_InterruptDisable_ReadyRqt (XCanFd *InstancePtr, u32 Mask)
 This routine disables TxBuffer Ready Request interrupt(s). More...
 
void XCanFd_InterruptDisable_CancelRqt (XCanFd *InstancePtr, u32 Mask)
 This routine disables the TxBuffer Cancel Request interrupt(s). More...
 
void XCanFd_InterruptEnable_RxBuffFull (XCanFd *InstancePtr, u32 Mask, u32 RxBuffNumber)
 This routine Enables the RxBuffer Full interrupt(s) in MailBox Mode. More...
 
void XCanFd_InterruptDisable_RxBuffFull (XCanFd *InstancePtr, u32 Mask, u32 RxBuffNumber)
 This routine disables the RxBuffer Full interrupt(s) in MailBox Mode. More...
 

Variables

XCanFd_Config XCanFd_ConfigTable []
 Config table. More...