| can Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Data Structures | Macros | Typedefs | Functions | Variables
Overview

## Data Structures
struct | XCan_Config
| This typedef contains configuration information for a device. More...
struct | XCan
| The XCan driver instance data. More...

## Macros
#define | XCAN_H
| by using protection macros More...
#define | XCan_IsTxDone(InstancePtr)
| This macro checks if the transmission is complete. More...
#define | XCan_IsTxFifoFull(InstancePtr)
| This macro checks if the transmission FIFO is full. More...
#define | XCan_IsHighPriorityBufFull(InstancePtr)
| This macro checks if the Transmission High Priority Buffer is full. More...
#define | XCan_IsRxEmpty(InstancePtr)
| This macro checks if the receive FIFO is empty. More...
#define | XCan_IsAcceptFilterBusy(InstancePtr)
| This macro checks if the CAN device is ready for the driver to change Acceptance Filter Identifier Registers (AFIR) and Acceptance Filter Mask Registers (AFMR). More...
#define | XCan_CreateIdValue(StandardId, SubRemoteTransReq, IdExtension, ExtendedId, RemoteTransReq)
| This macro calculates CAN message identifier value given identifier field values. More...
#define | XCan_CreateDlcValue(DataLengCode) (((DataLengCode) << XCAN_DLCR_DLC_SHIFT) & XCAN_DLCR_DLC_MASK)
| This macro calculates value for Data Length Code register given Data Length Code value. More...
#define | XCAN_L_H
| by using protection macros More...
#define | XCan_ReadReg(BaseAddress, RegOffset) Xil_In32((BaseAddress) + (RegOffset))
| This macro reads the given register. More...
#define | XCan_WriteReg(BaseAddress, RegOffset, Data) Xil_Out32((BaseAddress) + (RegOffset), (Data))
| This macro writes the given register. More...
#define | XCAN_MAX_FRAME_SIZE_IN_WORDS (XCAN_MAX_FRAME_SIZE / sizeof(u32))
| Max Frame Size. More...
#define | TEST_MESSAGE_ID 1024
| Mesage ID. More...
#define | TEST_CAN_DLC 8
| DLC length. More...

## Typedefs
typedef void(* | XCan_SendRecvHandler )(void *CallBackRef)
| Callback type for frame sending and reception interrupts. More...
typedef void(* | XCan_ErrorHandler )(void *CallBackRef, u32 ErrorMask)
| Callback type for error interrupt. More...
typedef void(* | XCan_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 | XCan_Initialize (XCan *InstancePtr, u16 DeviceId)
| This routine initializes a specific XCan instance/driver. More...
int | XCan_VmInitialize (XCan *InstancePtr, u16 DeviceId, UINTPTR VirtAddr)
| This routine initializes of a specific XCan instance/driver. More...
void | XCan_Reset (XCan *InstancePtr)
| This function resets the CAN device. More...
u8 | XCan_GetMode (XCan *InstancePtr)
| This routine returns current operation mode the CAN device is in. More...
void | XCan_EnterMode (XCan *InstancePtr, u8 OperationMode)
| This function allows the CAN device to enter one of the following operation modes: More...
u32 | XCan_GetStatus (XCan *InstancePtr)
| This function returns Status value from Status Register (SR). More...
void | XCan_GetBusErrorCounter (XCan *InstancePtr, u8 *RxErrorCount, u8 *TxErrorCount)
| This function reads Receive and Transmit error counters. More...
u32 | XCan_GetBusErrorStatus (XCan *InstancePtr)
| This function reads Error Status value from Error Status Register (ESR). More...
void | XCan_ClearBusErrorStatus (XCan *InstancePtr, u32 Mask)
| This function clears Error Status bit(s) previously set in Error Status Register (ESR). More...
int | XCan_Send (XCan *InstancePtr, u32 *FramePtr)
| This function sends a CAN Frame. More...
int | XCan_Recv (XCan *InstancePtr, u32 *FramePtr)
| This function receives a CAN Frame. More...
int | XCan_SendHighPriority (XCan *InstancePtr, u32 *FramePtr)
| This routine sends a CAN High Priority frame. More...
void | XCan_AcceptFilterEnable (XCan *InstancePtr, u32 FilterIndexes)
| This routine enables individual acceptance filters. More...
void | XCan_AcceptFilterDisable (XCan *InstancePtr, u32 FilterIndexes)
| This routine disables individual acceptance filters. More...
u32 | XCan_AcceptFilterGetEnabled (XCan *InstancePtr)
| This function returns enabled acceptance filters. More...
int | XCan_AcceptFilterSet (XCan *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 | XCan_AcceptFilterGet (XCan *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...
XCan_Config * | XCan_LookupConfig (u16 DeviceId)
| This function looks for the device configuration based on the unique device ID. More...
XCan_Config * | XCan_GetConfig (unsigned int InstanceIndex)
| This function looks for the device configuration based on the device index. More...
void | XCan_ResetECC (XCan *InstancePtr)
| This function resets the ECC counters. More...
void | XCan_GetECCCount (XCan *InstancePtr)
| This function gets the count of ECC error count for one and two bit error in TX_TL FIFO, TX_OL FIFO, RX FIFO. More...
int | XCan_SetBaudRatePrescaler (XCan *InstancePtr, u8 Prescaler)
| This routine sets Baud Rate Prescaler value. More...
u8 | XCan_GetBaudRatePrescaler (XCan *InstancePtr)
| This routine gets Baud Rate Prescaler value. More...
int | XCan_SetBitTiming (XCan *InstancePtr, u8 SyncJumpWidth, u8 TimeSegment2, u8 TimeSegment1)
| This routine sets Bit time. More...
void | XCan_GetBitTiming (XCan *InstancePtr, u8 *SyncJumpWidth, u8 *TimeSegment2, u8 *TimeSegment1)
| This routine gets Bit time. More...
int | XCan_SelfTest (XCan *InstancePtr)
| This function runs a self-test on the CAN driver/device. More...
void | XCan_InterruptEnable (XCan *InstancePtr, u32 Mask)
| This routine enables interrupt(s). More...
void | XCan_InterruptDisable (XCan *InstancePtr, u32 Mask)
| This routine disables interrupt(s). More...
u32 | XCan_InterruptGetEnabled (XCan *InstancePtr)
| This routine returns enabled interrupt(s). More...
u32 | XCan_InterruptGetStatus (XCan *InstancePtr)
| This routine returns interrupt status read from Interrupt Status Register. More...
void | XCan_InterruptClear (XCan *InstancePtr, u32 Mask)
| This function clears interrupt(s). More...
void | XCan_IntrHandler (void *InstancePtr)
| This routine is the interrupt handler for the CAN driver. More...
int | XCan_SetHandler (XCan *InstancePtr, u32 HandlerType, void *CallBackFunc, void *CallBackRef)
| This routine installs an asynchronous callback function for the given HandlerType: More...

## Variables
XCan_Config | XCan_ConfigTable []
| This table contains configuration information for each CAN device in the system. More...
XCan_Config | XCan_ConfigTable [XPAR_XCAN_NUM_INSTANCES]
| This table contains configuration information for each CAN device in the system. More...

## CAN operation modes
#define | XCAN_MODE_CONFIG 0x00000001
| Configuration mode. More...
#define | XCAN_MODE_NORMAL 0x00000002
| Normal mode. More...
#define | XCAN_MODE_LOOPBACK 0x00000004
| Loop Back mode. More...
#define | XCAN_MODE_SLEEP 0x00000008
| Sleep mode. More...

## Callback identifiers used as parameters to XCan_SetHandler()
#define | XCAN_HANDLER_SEND 1
| Handler type for frame sending interrupt. More...
#define | XCAN_HANDLER_RECV 2
| Handler type for frame reception interrupt. More...
#define | XCAN_HANDLER_ERROR 3
| Handler type for error interrupt. More...
#define | XCAN_HANDLER_EVENT 4
| Handler type for all other interrupts. More...

## Register offsets for the CAN. Each register is 32 bits.
#define | XCAN_SRR_OFFSET 0x000
| Software Reset Register. More...
#define | XCAN_MSR_OFFSET 0x004
| Mode Select Register. More...
#define | XCAN_BRPR_OFFSET 0x008
| Baud Rate Prescaler Register. More...
#define | XCAN_BTR_OFFSET 0x00C
| Bit Timing Register. More...
#define | XCAN_ECR_OFFSET 0x010
| Error Counter Register. More...
#define | XCAN_ESR_OFFSET 0x014
| Error Status Register. More...
#define | XCAN_SR_OFFSET 0x018
| Status Register. More...
#define | XCAN_ISR_OFFSET 0x01C
| Interrupt Status Register. More...
#define | XCAN_IER_OFFSET 0x020
| Interrupt Enable Register. More...
#define | XCAN_ICR_OFFSET 0x024
| Interrupt Clear Register. More...
#define | XCAN_TXFIFO_ID_OFFSET 0x030
| TX FIFO ID. More...
#define | XCAN_TXFIFO_DLC_OFFSET 0x034
| TX FIFO DLC. More...
#define | XCAN_TXFIFO_DW1_OFFSET 0x038
| TX FIFO Data Word 1. More...
#define | XCAN_TXFIFO_DW2_OFFSET 0x03C
| TX FIFO Data Word 2. More...
#define | XCAN_TXBUF_ID_OFFSET 0x040
| TX High Priority Buffer ID. More...
#define | XCAN_TXBUF_DLC_OFFSET 0x044
| TX High Priority Buffer DLC. More...
#define | XCAN_TXBUF_DW1_OFFSET 0x048
| TX High Priority Buf Data Word 1. More...
#define | XCAN_TXBUF_DW2_OFFSET 0x04C
| TX High Priority Buf Data Word 2. More...
#define | XCAN_RXFIFO_ID_OFFSET 0x050
| RX FIFO ID. More...
#define | XCAN_RXFIFO_DLC_OFFSET 0x054
| RX FIFO DLC. More...
#define | XCAN_RXFIFO_DW1_OFFSET 0x058
| RX FIFO Data Word 1. More...
#define | XCAN_RXFIFO_DW2_OFFSET 0x05C
| RX FIFO Data Word 2. More...
#define | XCAN_AFR_OFFSET 0x060
| Acceptance Filter Register. More...
#define | XCAN_AFMR1_OFFSET 0x064
| Acceptance Filter Mask Register 1. More...
#define | XCAN_AFIR1_OFFSET 0x068
| Acceptance Filter ID Register 1. More...
#define | XCAN_AFMR2_OFFSET 0x06C
| Acceptance Filter Mask Register 2. More...
#define | XCAN_AFIR2_OFFSET 0x070
| Acceptance Filter ID Register 2. More...
#define | XCAN_AFMR3_OFFSET 0x074
| Acceptance Filter Mask Register 3. More...
#define | XCAN_AFIR3_OFFSET 0x078
| Acceptance Filter ID Register 3. More...
#define | XCAN_AFMR4_OFFSET 0x07C
| Acceptance Filter Mask Register 4. More...
#define | XCAN_AFIR4_OFFSET 0x080
| Acceptance Filter ID Register 4. More...
#define | XCAN_ECC_CFG_OFFSET 0x0C8
| ECC Configuration register. More...
#define | XCAN_TXTLFIFO_ECC_OFFSET 0x0CC
| TXTL FIFO ECC error counter. More...
#define | XCAN_TXOLFIFO_ECC_OFFSET 0x0D0
| TXOL FIFO ECC error counter. More...
#define | XCAN_RXFIFO_ECC_OFFSET 0X0D4
| RX FIFO ECC error counter. More...

## Software Reset Register
#define | XCAN_SRR_CEN_MASK 0x00000002
| Can Enable Mask. More...
#define | XCAN_SRR_SRST_MASK 0x00000001
| Reset Mask. More...

## Mode Select Register
#define | XCAN_MSR_LBACK_MASK 0x00000002
| Loop Back Mode Select Mask. More...
#define | XCAN_MSR_SLEEP_MASK 0x00000001
| Sleep Mode Select Mask. More...

## Baud Rate Prescaler register
#define | XCAN_BRPR_BRP_MASK 0x000000FF
| Baud Rate Prescaler Mask. More...

## Bit Timing Register
#define | XCAN_BTR_SJW_MASK 0x00000180
| Sync Jump Width Mask. More...
#define | XCAN_BTR_SJW_SHIFT 7
| Sync Jump Width Shift. More...
#define | XCAN_BTR_TS2_MASK 0x00000070
| Time Segment 2 Mask. More...
#define | XCAN_BTR_TS2_SHIFT 4
| Time Segment 2 Shift. More...
#define | XCAN_BTR_TS1_MASK 0x0000000F
| Time Segment 1 Mask. More...

## Error Counter Register
#define | XCAN_ECR_REC_MASK 0x0000FF00
| Receive Error Counter Mask. More...
#define | XCAN_ECR_REC_SHIFT 8
| Receive Error Counter Shift. More...
#define | XCAN_ECR_TEC_MASK 0x000000FF
| Transmit Error Counter Mask. More...

## Error Status Register
#define | XCAN_ESR_ACKER_MASK 0x00000010
| ACK Error Mask. More...
#define | XCAN_ESR_BERR_MASK 0x00000008
| Bit Error Mask. More...
#define | XCAN_ESR_STER_MASK 0x00000004
| Stuff Error Mask. More...
#define | XCAN_ESR_FMER_MASK 0x00000002
| Form Error Mask. More...
#define | XCAN_ESR_CRCER_MASK 0x00000001
| CRC Error Mask. More...

## Status Register
#define | XCAN_SR_ACFBSY_MASK 0x00000800
| Acceptance Filter busy Mask. More...
#define | XCAN_SR_TXFLL_MASK 0x00000400
| TX FIFO is full Mask. More...
#define | XCAN_SR_TXBFLL_MASK 0x00000200
| TX High Priority Buffer full. More...
#define | XCAN_SR_ESTAT_MASK 0x00000180
| Error Status Mask. More...
#define | XCAN_SR_ESTAT_SHIFT 7
| Error Status Shift. More...
#define | XCAN_SR_ERRWRN_MASK 0x00000040
| Error Warning Mask. More...
#define | XCAN_SR_BBSY_MASK 0x00000020
| Bus Busy Mask. More...
#define | XCAN_SR_BIDLE_MASK 0x00000010
| Bus Idle Mask. More...
#define | XCAN_SR_NORMAL_MASK 0x00000008
| Normal Mode Mask. More...
#define | XCAN_SR_SLEEP_MASK 0x00000004
| Sleep Mode Mask. More...
#define | XCAN_SR_LBACK_MASK 0x00000002
| Loop Back Mode Mask. More...
#define | XCAN_SR_CONFIG_MASK 0x00000001
| Configuration Mode Mask. More...

## Interrupt Status/Enable/Clear Register
#define | XCAN_IXR_E2BERX_MASK 0x00800000
| RX FIFO two bit ECC error. More...
#define | XCAN_IXR_E1BERX_MASK 0x00400000
| RX FIFO one bit ECC error. More...
#define | XCAN_IXR_E2BETXOL_MASK 0x00200000
| TXOL FIFO two bit ECC error. More...
#define | XCAN_IXR_E1BETXOL_MASK 0x00100000
| TXOL FIFO one bit ECC error. More...
#define | XCAN_IXR_E2BETXTL_MASK 0x00080000
| TXTL FIFO two bit ECC error. More...
#define | XCAN_IXR_E1BETXTL_MASK 0x00040000
| TXTL FIFO one bit ECC error. More...
#define | XCAN_IXR_WKUP_MASK 0x00000800
| Wake up Interrupt Mask. More...
#define | XCAN_IXR_SLP_MASK 0x00000400
| Sleep Interrupt Mask. More...
#define | XCAN_IXR_BSOFF_MASK 0x00000200
| Bus Off Interrupt Mask. More...
#define | XCAN_IXR_ERROR_MASK 0x00000100
| Error Interrupt Mask. More...
#define | XCAN_IXR_RXNEMP_MASK 0x00000080
| RX FIFO Not Empty Intr Mask. More...
#define | XCAN_IXR_RXOFLW_MASK 0x00000040
| RX FIFO Overflow Intr Mask. More...
#define | XCAN_IXR_RXUFLW_MASK 0x00000020
| RX FIFO Underflow Intr Mask. More...
#define | XCAN_IXR_RXOK_MASK 0x00000010
| New Message Received Intr. More...
#define | XCAN_IXR_TXBFLL_MASK 0x00000008
| TX High Priority Buf Full. More...
#define | XCAN_IXR_TXFLL_MASK 0x00000004
| TX FIFO Full Interrupt Mask. More...
#define | XCAN_IXR_TXOK_MASK 0x00000002
| TX Successful Interrupt Mask. More...
#define | XCAN_IXR_ARBLST_MASK 0x00000001
| Arbitration Lost Intr Mask. More...
#define | XCAN_IXR_ECC_MASK
| Mask for ECC interrupts. More...
#define | XCAN_IXR_ALL
| Mask for basic interrupts. More...

## CAN Frame Identifier (TX High Priority Buffer/TX/RX/Acceptance Filter
Mask/Acceptance Filter ID)
#define | XCAN_IDR_ID1_MASK 0xFFE00000
| Standard Messg Ident Mask. More...
#define | XCAN_IDR_ID1_SHIFT 21
| Standard Messg Ident Shift. More...
#define | XCAN_IDR_SRR_MASK 0x00100000
| Substitute Remote TX Req. More...
#define | XCAN_IDR_SRR_SHIFT 20
| Shift Value for SRR. More...
#define | XCAN_IDR_IDE_MASK 0x00080000
| Identifier Extension Mask. More...
#define | XCAN_IDR_IDE_SHIFT 19
| Identifier Extension Shift. More...
#define | XCAN_IDR_ID2_MASK 0x0007FFFE
| Extended Message Ident Mask. More...
#define | XCAN_IDR_ID2_SHIFT 1
| Extended Message Ident Shift. More...
#define | XCAN_IDR_RTR_MASK 0x00000001
| Remote TX Request Mask. More...

## CAN Frame Data Length Code (TX High Priority Buffer/TX/RX)
#define | XCAN_DLCR_DLC_MASK 0xF0000000
| Data Length Code Mask. More...
#define | XCAN_DLCR_DLC_SHIFT 28
| Data Length Code Shift. More...

## CAN Frame Data Word 1 (TX High Priority Buffer/TX/RX)
#define | XCAN_DW1R_DB0_MASK 0xFF000000
| Data Byte 0 Mask. More...
#define | XCAN_DW1R_DB0_SHIFT 24
| Data Byte 0 Shift. More...
#define | XCAN_DW1R_DB1_MASK 0x00FF0000
| Data Byte 1 Mask. More...
#define | XCAN_DW1R_DB1_SHIFT 16
| Data Byte 1 Shift. More...
#define | XCAN_DW1R_DB2_MASK 0x0000FF00
| Data Byte 2 Mask. More...
#define | XCAN_DW1R_DB2_SHIFT 8
| Data Byte 2 Shift. More...
#define | XCAN_DW1R_DB3_MASK 0x000000FF
| Data Byte 3 Mask. More...

## CAN Frame Data Word 2 (TX High Priority Buffer/TX/RX)
#define | XCAN_DW2R_DB4_MASK 0xFF000000
| Data Byte 4 Mask. More...
#define | XCAN_DW2R_DB4_SHIFT 24
| Data Byte 4 Shift. More...
#define | XCAN_DW2R_DB5_MASK 0x00FF0000
| Data Byte 5 Mask. More...
#define | XCAN_DW2R_DB5_SHIFT 16
| Data Byte 5 Shift. More...
#define | XCAN_DW2R_DB6_MASK 0x0000FF00
| Data Byte 6 Mask. More...
#define | XCAN_DW2R_DB6_SHIFT 8
| Data Byte 6 Shift. More...
#define | XCAN_DW2R_DB7_MASK 0x000000FF
| Data Byte 7. More...

## Acceptance Filter Register
#define | XCAN_AFR_UAF4_MASK 0x00000008
| Use Acceptance Filter No.4. More...
#define | XCAN_AFR_UAF3_MASK 0x00000004
| Use Acceptance Filter No.3. More...
#define | XCAN_AFR_UAF2_MASK 0x00000002
| Use Acceptance Filter No.2. More...
#define | XCAN_AFR_UAF1_MASK 0x00000001
| Use Acceptance Filter No.1. More...
#define | XCAN_AFR_UAF_ALL_MASK
| Mask for Acceptance Filters. More...

## ECC Configuration register
#define | XCAN_ECC_CFG_RST_MASK 0x00000007
| Reset Mask for ECC configuration register. More...
#define | XCAN_ECC_CFG_REECRX_MASK 0x00000004
| Reset RX FIFO ECC error counters. More...
#define | XCAN_ECC_CFG_REECTXOL_MASK 0x00000002
| Reset TXOL FIFO ECC error counters. More...
#define | XCAN_ECC_CFG_REECTXTL_MASK 0x00000001
| Reset TXTL FIFO ECC error counters. More...
#define | XCAN_ECC_2BIT_SHIFT 16
| ECC 2bit error counter shift. More...

## CAN frame length constants
#define | XCAN_MAX_FRAME_SIZE 16
| Maximum CAN frame length in bytes. More...

## Mask for Low 16bits and High 16 bits
#define | XCAN_MASK_LOW_16BITS 0x0000FFFF
| Mask to obtain lower 16bits. More...
#define | XCAN_MASK_HIGH_16BITS 0XFFFF0000
| Mask to obtain higher 16bits. More...

## Macro Definition Documentation

#define TEST_CAN_DLC 8

DLC length.

Referenced by XCan_SelfTest().

#define TEST_MESSAGE_ID 1024

Mesage ID.

Referenced by main(), and XCan_SelfTest().

#define XCAN_AFIR1_OFFSET 0x068

Acceptance Filter ID Register 1.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFIR2_OFFSET 0x070

Acceptance Filter ID Register 2.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFIR3_OFFSET 0x078

Acceptance Filter ID Register 3.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFIR4_OFFSET 0x080

Acceptance Filter ID Register 4.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFMR1_OFFSET 0x064

Acceptance Filter Mask Register 1.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFMR2_OFFSET 0x06C

Acceptance Filter Mask Register 2.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFMR3_OFFSET 0x074

Acceptance Filter Mask Register 3.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFMR4_OFFSET 0x07C

Acceptance Filter Mask Register 4.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFR_OFFSET 0x060

Acceptance Filter Register.

Referenced by XCan_AcceptFilterDisable(), XCan_AcceptFilterEnable(), and XCan_AcceptFilterGetEnabled().

#define XCAN_AFR_UAF1_MASK 0x00000001

Use Acceptance Filter No.1.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFR_UAF2_MASK 0x00000002

Use Acceptance Filter No.2.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFR_UAF3_MASK 0x00000004

Use Acceptance Filter No.3.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFR_UAF4_MASK 0x00000008

Use Acceptance Filter No.4.

Referenced by XCan_AcceptFilterGet(), and XCan_AcceptFilterSet().

#define XCAN_AFR_UAF_ALL_MASK

Value:
(XCAN_AFR_UAF4_MASK | XCAN_AFR_UAF3_MASK | \
XCAN_AFR_UAF2_MASK | XCAN_AFR_UAF1_MASK)
XCAN_AFR_UAF2_MASK
#define XCAN_AFR_UAF2_MASK
Use Acceptance Filter No.2.
Definition: xcan_l.h:260
XCAN_AFR_UAF3_MASK
#define XCAN_AFR_UAF3_MASK
Use Acceptance Filter No.3.
Definition: xcan_l.h:259
XCAN_AFR_UAF4_MASK
#define XCAN_AFR_UAF4_MASK
Use Acceptance Filter No.4.
Definition: xcan_l.h:258
XCAN_AFR_UAF1_MASK
#define XCAN_AFR_UAF1_MASK
Use Acceptance Filter No.1.
Definition: xcan_l.h:261

Mask for Acceptance Filters.

Referenced by XCan_AcceptFilterDisable(), and XCan_AcceptFilterEnable().

#define XCAN_BRPR_BRP_MASK 0x000000FF

Baud Rate Prescaler Mask.

#define XCAN_BRPR_OFFSET 0x008

Baud Rate Prescaler Register.

Referenced by XCan_GetBaudRatePrescaler(), and XCan_SetBaudRatePrescaler().

#define XCAN_BTR_OFFSET 0x00C

Bit Timing Register.

Referenced by XCan_GetBitTiming(), and XCan_SetBitTiming().

#define XCAN_BTR_SJW_MASK 0x00000180

Sync Jump Width Mask.

Referenced by XCan_GetBitTiming(), and XCan_SetBitTiming().

#define XCAN_BTR_SJW_SHIFT 7

Sync Jump Width Shift.

Referenced by XCan_GetBitTiming(), and XCan_SetBitTiming().

#define XCAN_BTR_TS1_MASK 0x0000000F

Time Segment 1 Mask.

Referenced by XCan_GetBitTiming(), and XCan_SetBitTiming().

#define XCAN_BTR_TS2_MASK 0x00000070

Time Segment 2 Mask.

Referenced by XCan_GetBitTiming(), and XCan_SetBitTiming().

#define XCAN_BTR_TS2_SHIFT 4

Time Segment 2 Shift.

Referenced by XCan_GetBitTiming(), and XCan_SetBitTiming().

#define XCan_CreateDlcValue | ( |  | DataLengCode | ) | (((DataLengCode) << XCAN_DLCR_DLC_SHIFT) & XCAN_DLCR_DLC_MASK)

This macro calculates value for Data Length Code register given Data Length Code value.

Parameters

  DataLengCode | indicates Data Length Code value.

Returns
  Value that can be assigned to Data Length Code register.

Note
  C-Style signature: u32 XCan_CreateDlcValue(u32 DataLengCode);

          Read the CAN specification for meaning of Data Length Code.

Referenced by main(), and XCan_SelfTest().

#define XCan_CreateIdValue | ( |  | StandardId,
|  |  | SubRemoteTransReq,
|  |  | IdExtension,
|  |  | ExtendedId,
|  |  | RemoteTransReq
| ) |  |

Value:
((((StandardId) << XCAN_IDR_ID1_SHIFT) & XCAN_IDR_ID1_MASK) | \
(((SubRemoteTransReq) << XCAN_IDR_SRR_SHIFT) & XCAN_IDR_SRR_MASK) | \
(((IdExtension) << XCAN_IDR_IDE_SHIFT) & XCAN_IDR_IDE_MASK) | \
(((ExtendedId) << XCAN_IDR_ID2_SHIFT) & XCAN_IDR_ID2_MASK) | \
((RemoteTransReq) & XCAN_IDR_RTR_MASK))
XCAN_IDR_IDE_MASK
#define XCAN_IDR_IDE_MASK
Identifier Extension Mask.
Definition: xcan_l.h:217
XCAN_IDR_ID2_SHIFT
#define XCAN_IDR_ID2_SHIFT
Extended Message Ident Shift.
Definition: xcan_l.h:220
XCAN_IDR_ID1_SHIFT
#define XCAN_IDR_ID1_SHIFT
Standard Messg Ident Shift.
Definition: xcan_l.h:214
XCAN_IDR_SRR_MASK
#define XCAN_IDR_SRR_MASK
Substitute Remote TX Req.
Definition: xcan_l.h:215
XCAN_IDR_SRR_SHIFT
#define XCAN_IDR_SRR_SHIFT
Shift Value for SRR.
Definition: xcan_l.h:216
XCAN_IDR_IDE_SHIFT
#define XCAN_IDR_IDE_SHIFT
Identifier Extension Shift.
Definition: xcan_l.h:218
XCAN_IDR_ID1_MASK
#define XCAN_IDR_ID1_MASK
Standard Messg Ident Mask.
Definition: xcan_l.h:213
XCAN_IDR_RTR_MASK
#define XCAN_IDR_RTR_MASK
Remote TX Request Mask.
Definition: xcan_l.h:221
XCAN_IDR_ID2_MASK
#define XCAN_IDR_ID2_MASK
Extended Message Ident Mask.
Definition: xcan_l.h:219

This macro calculates CAN message identifier value given identifier field values.

Parameters

  StandardId | contains Standard Message ID value.
  SubRemoteTransReq | contains Substitute Remote Transmission Request value.
  IdExtension | contains Identifier Extension value.
  ExtendedId | contains Extended Message ID value.
  RemoteTransReq | contains Remote Transmission Request value.

Returns
  Message Identifier value.

Note
  C-Style signature: u32 XCan_CreateIdValue(u32 StandardId, u32 SubRemoteTransReq, u32 IdExtension, u32 ExtendedId, u32 RemoteTransReq);

Read the CAN specification for meaning of each parameter.

Referenced by main(), and XCan_SelfTest().

#define XCAN_DLCR_DLC_MASK 0xF0000000

Data Length Code Mask.

#define XCAN_DLCR_DLC_SHIFT 28

Data Length Code Shift.

#define XCAN_DW1R_DB0_MASK 0xFF000000

Data Byte 0 Mask.

#define XCAN_DW1R_DB0_SHIFT 24

Data Byte 0 Shift.

#define XCAN_DW1R_DB1_MASK 0x00FF0000

Data Byte 1 Mask.

#define XCAN_DW1R_DB1_SHIFT 16

Data Byte 1 Shift.

#define XCAN_DW1R_DB2_MASK 0x0000FF00

Data Byte 2 Mask.

#define XCAN_DW1R_DB2_SHIFT 8

Data Byte 2 Shift.

#define XCAN_DW1R_DB3_MASK 0x000000FF

Data Byte 3 Mask.

#define XCAN_DW2R_DB4_MASK 0xFF000000

Data Byte 4 Mask.

#define XCAN_DW2R_DB4_SHIFT 24

Data Byte 4 Shift.

#define XCAN_DW2R_DB5_MASK 0x00FF0000

Data Byte 5 Mask.

#define XCAN_DW2R_DB5_SHIFT 16

Data Byte 5 Shift.

#define XCAN_DW2R_DB6_MASK 0x0000FF00

Data Byte 6 Mask.

#define XCAN_DW2R_DB6_SHIFT 8

Data Byte 6 Shift.

#define XCAN_DW2R_DB7_MASK 0x000000FF

Data Byte 7.

#define XCAN_ECC_2BIT_SHIFT 16

ECC 2bit error counter shift.

Referenced by XCan_GetECCCount().

#define XCAN_ECC_CFG_OFFSET 0x0C8

ECC Configuration register.

Referenced by XCan_ResetECC().

#define XCAN_ECC_CFG_REECRX_MASK 0x00000004

Reset RX FIFO ECC error counters.

#define XCAN_ECC_CFG_REECTXOL_MASK 0x00000002

Reset TXOL FIFO ECC error counters.

#define XCAN_ECC_CFG_REECTXTL_MASK 0x00000001

Reset TXTL FIFO ECC error counters.

#define XCAN_ECC_CFG_RST_MASK 0x00000007

Reset Mask for ECC configuration register.

Referenced by XCan_ResetECC().

#define XCAN_ECR_OFFSET 0x010

Error Counter Register.

Referenced by XCan_GetBusErrorCounter().

#define XCAN_ECR_REC_MASK 0x0000FF00

Receive Error Counter Mask.

Referenced by XCan_GetBusErrorCounter().

#define XCAN_ECR_REC_SHIFT 8

Receive Error Counter Shift.

Referenced by XCan_GetBusErrorCounter().

#define XCAN_ECR_TEC_MASK 0x000000FF

Transmit Error Counter Mask.

Referenced by XCan_GetBusErrorCounter().

#define XCAN_ESR_ACKER_MASK 0x00000010

ACK Error Mask.

Referenced by main().

#define XCAN_ESR_BERR_MASK 0x00000008

Bit Error Mask.

Referenced by main().

#define XCAN_ESR_CRCER_MASK 0x00000001

CRC Error Mask.

Referenced by main().

#define XCAN_ESR_FMER_MASK 0x00000002

Form Error Mask.

Referenced by main().

#define XCAN_ESR_OFFSET 0x014

Error Status Register.

Referenced by XCan_ClearBusErrorStatus(), and XCan_GetBusErrorStatus().

#define XCAN_ESR_STER_MASK 0x00000004

Stuff Error Mask.

Referenced by main().

#define XCAN_H

by using protection macros

#define XCAN_HANDLER_ERROR 3

Handler type for error interrupt.

Referenced by main(), and XCan_SetHandler().

#define XCAN_HANDLER_EVENT 4

Handler type for all other interrupts.

Referenced by main(), and XCan_SetHandler().

#define XCAN_HANDLER_RECV 2

Handler type for frame reception interrupt.

Referenced by main(), and XCan_SetHandler().

#define XCAN_HANDLER_SEND 1

Handler type for frame sending interrupt.

Referenced by main(), and XCan_SetHandler().

#define XCAN_ICR_OFFSET 0x024

Interrupt Clear Register.

Referenced by XCan_InterruptClear().

#define XCAN_IDR_ID1_MASK 0xFFE00000

Standard Messg Ident Mask.

#define XCAN_IDR_ID1_SHIFT 21

Standard Messg Ident Shift.

#define XCAN_IDR_ID2_MASK 0x0007FFFE

Extended Message Ident Mask.

#define XCAN_IDR_ID2_SHIFT 1

Extended Message Ident Shift.

#define XCAN_IDR_IDE_MASK 0x00080000

Identifier Extension Mask.

#define XCAN_IDR_IDE_SHIFT 19

Identifier Extension Shift.

#define XCAN_IDR_RTR_MASK 0x00000001

Remote TX Request Mask.

#define XCAN_IDR_SRR_MASK 0x00100000

Substitute Remote TX Req.

#define XCAN_IDR_SRR_SHIFT 20

Shift Value for SRR.

#define XCAN_IER_OFFSET 0x020

Interrupt Enable Register.

Referenced by XCan_InterruptDisable(), XCan_InterruptEnable(), and XCan_InterruptGetEnabled().

#define XCan_IsAcceptFilterBusy | ( |  | InstancePtr | ) |

Value:
((XCan_ReadReg(((InstancePtr)->BaseAddress), XCAN_SR_OFFSET) & \
XCAN_SR_ACFBSY_MASK) ? TRUE : FALSE)
XCAN_SR_ACFBSY_MASK
#define XCAN_SR_ACFBSY_MASK
Acceptance Filter busy Mask.
Definition: xcan_l.h:147
XCAN_SR_OFFSET
#define XCAN_SR_OFFSET
Status Register.
Definition: xcan_l.h:58
XCan_ReadReg
#define XCan_ReadReg(BaseAddress, RegOffset)
This macro reads the given register.
Definition: xcan_l.h:308

This macro checks if the CAN device is ready for the driver to change Acceptance Filter Identifier Registers (AFIR) and Acceptance Filter Mask Registers (AFMR).

AFIR and AFMR for a filter are changeable only after the filter is disabled and this routine returns FALSE.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - TRUE if the device is busy and NOT ready to accept writes to AFIR and AFMR.
  - FALSE if the device is ready to accept writes to AFIR and AFMR.

Note
  C-Style signature: int XCan_IsAcceptFilterBusy(XCan *InstancePtr);

Referenced by XCan_AcceptFilterSet().

#define XCan_IsHighPriorityBufFull | ( |  | InstancePtr | ) |

Value:
((XCan_ReadReg(((InstancePtr)->BaseAddress), XCAN_SR_OFFSET) & \
XCAN_SR_TXBFLL_MASK) ? TRUE : FALSE)
XCAN_SR_OFFSET
#define XCAN_SR_OFFSET
Status Register.
Definition: xcan_l.h:58
XCan_ReadReg
#define XCan_ReadReg(BaseAddress, RegOffset)
This macro reads the given register.
Definition: xcan_l.h:308
XCAN_SR_TXBFLL_MASK
#define XCAN_SR_TXBFLL_MASK
TX High Priority Buffer full.
Definition: xcan_l.h:149

This macro checks if the Transmission High Priority Buffer is full.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - TRUE if TX High Priority Buffer is full.
  - FALSE if TX High Priority Buffer is not full.

Note
  C-Style signature: int XCan_IsHighPriorityBufFull(XCan *InstancePtr);

Referenced by XCan_SendHighPriority().

#define XCAN_ISR_OFFSET 0x01C

Interrupt Status Register.

Referenced by XCan_InterruptGetStatus().

#define XCan_IsRxEmpty | ( |  | InstancePtr | ) |

Value:
((XCan_ReadReg(((InstancePtr)->BaseAddress), XCAN_ISR_OFFSET) & \
XCAN_IXR_RXNEMP_MASK) ? FALSE : TRUE)
XCAN_IXR_RXNEMP_MASK
#define XCAN_IXR_RXNEMP_MASK
RX FIFO Not Empty Intr Mask.
Definition: xcan_l.h:175
XCan_ReadReg
#define XCan_ReadReg(BaseAddress, RegOffset)
This macro reads the given register.
Definition: xcan_l.h:308
XCAN_ISR_OFFSET
#define XCAN_ISR_OFFSET
Interrupt Status Register.
Definition: xcan_l.h:60

This macro checks if the receive FIFO is empty.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - TRUE if RX FIFO is empty.
  - FALSE if RX FIFO is not empty.

Note
  C-Style signature: int XCan_IsRxEmpty(XCan *InstancePtr);

Referenced by XCan_Recv(), and XCan_SelfTest().

#define XCan_IsTxDone | ( |  | InstancePtr | ) |

Value:
((XCan_ReadReg(((InstancePtr)->BaseAddress), XCAN_ISR_OFFSET) & \
XCAN_IXR_TXOK_MASK) ? TRUE : FALSE)
XCAN_IXR_TXOK_MASK
#define XCAN_IXR_TXOK_MASK
TX Successful Interrupt Mask.
Definition: xcan_l.h:181
XCan_ReadReg
#define XCan_ReadReg(BaseAddress, RegOffset)
This macro reads the given register.
Definition: xcan_l.h:308
XCAN_ISR_OFFSET
#define XCAN_ISR_OFFSET
Interrupt Status Register.
Definition: xcan_l.h:60

This macro checks if the transmission is complete.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - TRUE if the transmission is done (completed).
  - FALSE if the transmission is not completed.

Note
  C-Style signature: int XCan_IsTxDone(XCan *InstancePtr);

#define XCan_IsTxFifoFull | ( |  | InstancePtr | ) |

Value:
((XCan_ReadReg(((InstancePtr)->BaseAddress), XCAN_SR_OFFSET) & \
XCAN_SR_TXFLL_MASK) ? TRUE : FALSE)
XCAN_SR_OFFSET
#define XCAN_SR_OFFSET
Status Register.
Definition: xcan_l.h:58
XCan_ReadReg
#define XCan_ReadReg(BaseAddress, RegOffset)
This macro reads the given register.
Definition: xcan_l.h:308
XCAN_SR_TXFLL_MASK
#define XCAN_SR_TXFLL_MASK
TX FIFO is full Mask.
Definition: xcan_l.h:148

This macro checks if the transmission FIFO is full.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - TRUE if TX FIFO is full.
  - FALSE if TX FIFO is not full.

Note
  C-Style signature: int XCan_IsTxFifoFull(XCan *InstancePtr);

Referenced by main(), and XCan_Send().

#define XCAN_IXR_ALL

Value:
(XCAN_IXR_WKUP_MASK | \
XCAN_IXR_SLP_MASK | \
XCAN_IXR_BSOFF_MASK | \
XCAN_IXR_ERROR_MASK | \
XCAN_IXR_RXNEMP_MASK | \
XCAN_IXR_RXOFLW_MASK | \
XCAN_IXR_RXUFLW_MASK | \
XCAN_IXR_RXOK_MASK | \
XCAN_IXR_TXBFLL_MASK | \
XCAN_IXR_TXFLL_MASK | \
XCAN_IXR_TXOK_MASK | \
XCAN_IXR_ARBLST_MASK)
XCAN_IXR_ERROR_MASK
#define XCAN_IXR_ERROR_MASK
Error Interrupt Mask.
Definition: xcan_l.h:174
XCAN_IXR_RXUFLW_MASK
#define XCAN_IXR_RXUFLW_MASK
RX FIFO Underflow Intr Mask.
Definition: xcan_l.h:177
XCAN_IXR_SLP_MASK
#define XCAN_IXR_SLP_MASK
Sleep Interrupt Mask.
Definition: xcan_l.h:172
XCAN_IXR_RXNEMP_MASK
#define XCAN_IXR_RXNEMP_MASK
RX FIFO Not Empty Intr Mask.
Definition: xcan_l.h:175
XCAN_IXR_WKUP_MASK
#define XCAN_IXR_WKUP_MASK
Wake up Interrupt Mask.
Definition: xcan_l.h:171
XCAN_IXR_RXOFLW_MASK
#define XCAN_IXR_RXOFLW_MASK
RX FIFO Overflow Intr Mask.
Definition: xcan_l.h:176
XCAN_IXR_TXOK_MASK
#define XCAN_IXR_TXOK_MASK
TX Successful Interrupt Mask.
Definition: xcan_l.h:181
XCAN_IXR_TXBFLL_MASK
#define XCAN_IXR_TXBFLL_MASK
TX High Priority Buf Full.
Definition: xcan_l.h:179
XCAN_IXR_ARBLST_MASK
#define XCAN_IXR_ARBLST_MASK
Arbitration Lost Intr Mask.
Definition: xcan_l.h:182
XCAN_IXR_BSOFF_MASK
#define XCAN_IXR_BSOFF_MASK
Bus Off Interrupt Mask.
Definition: xcan_l.h:173
XCAN_IXR_TXFLL_MASK
#define XCAN_IXR_TXFLL_MASK
TX FIFO Full Interrupt Mask.
Definition: xcan_l.h:180
XCAN_IXR_RXOK_MASK
#define XCAN_IXR_RXOK_MASK
New Message Received Intr.
Definition: xcan_l.h:178

Mask for basic interrupts.

Referenced by main().

#define XCAN_IXR_ARBLST_MASK 0x00000001

Arbitration Lost Intr Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_BSOFF_MASK 0x00000200

Bus Off Interrupt Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_E1BERX_MASK 0x00400000

RX FIFO one bit ECC error.

Referenced by XCan_GetECCCount().

#define XCAN_IXR_E1BETXOL_MASK 0x00100000

TXOL FIFO one bit ECC error.

Referenced by XCan_GetECCCount().

#define XCAN_IXR_E1BETXTL_MASK 0x00040000

TXTL FIFO one bit ECC error.

Referenced by XCan_GetECCCount().

#define XCAN_IXR_E2BERX_MASK 0x00800000

RX FIFO two bit ECC error.

Referenced by XCan_GetECCCount().

#define XCAN_IXR_E2BETXOL_MASK 0x00200000

TXOL FIFO two bit ECC error.

Referenced by XCan_GetECCCount().

#define XCAN_IXR_E2BETXTL_MASK 0x00080000

TXTL FIFO two bit ECC error.

Referenced by XCan_GetECCCount().

#define XCAN_IXR_ECC_MASK

Value:
(XCAN_IXR_E2BERX_MASK | \
XCAN_IXR_E1BERX_MASK | \
XCAN_IXR_E2BETXOL_MASK | \
XCAN_IXR_E1BETXOL_MASK | \
XCAN_IXR_E2BETXTL_MASK | \
XCAN_IXR_E1BETXTL_MASK)
XCAN_IXR_E1BETXOL_MASK
#define XCAN_IXR_E1BETXOL_MASK
TXOL FIFO one bit ECC error.
Definition: xcan_l.h:167
XCAN_IXR_E2BERX_MASK
#define XCAN_IXR_E2BERX_MASK
RX FIFO two bit ECC error.
Definition: xcan_l.h:164
XCAN_IXR_E1BETXTL_MASK
#define XCAN_IXR_E1BETXTL_MASK
TXTL FIFO one bit ECC error.
Definition: xcan_l.h:169
XCAN_IXR_E2BETXOL_MASK
#define XCAN_IXR_E2BETXOL_MASK
TXOL FIFO two bit ECC error.
Definition: xcan_l.h:166
XCAN_IXR_E2BETXTL_MASK
#define XCAN_IXR_E2BETXTL_MASK
TXTL FIFO two bit ECC error.
Definition: xcan_l.h:168
XCAN_IXR_E1BERX_MASK
#define XCAN_IXR_E1BERX_MASK
RX FIFO one bit ECC error.
Definition: xcan_l.h:165

Mask for ECC interrupts.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_ERROR_MASK 0x00000100

Error Interrupt Mask.

Referenced by XCan_IntrHandler().

#define XCAN_IXR_RXNEMP_MASK 0x00000080

RX FIFO Not Empty Intr Mask.

Referenced by XCan_IntrHandler(), and XCan_Recv().

#define XCAN_IXR_RXOFLW_MASK 0x00000040

RX FIFO Overflow Intr Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_RXOK_MASK 0x00000010

New Message Received Intr.

#define XCAN_IXR_RXUFLW_MASK 0x00000020

RX FIFO Underflow Intr Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_SLP_MASK 0x00000400

Sleep Interrupt Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_TXBFLL_MASK 0x00000008

TX High Priority Buf Full.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_TXFLL_MASK 0x00000004

TX FIFO Full Interrupt Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_IXR_TXOK_MASK 0x00000002

TX Successful Interrupt Mask.

Referenced by XCan_IntrHandler().

#define XCAN_IXR_WKUP_MASK 0x00000800

Wake up Interrupt Mask.

Referenced by main(), and XCan_IntrHandler().

#define XCAN_L_H

by using protection macros

#define XCAN_MASK_HIGH_16BITS 0XFFFF0000

Mask to obtain higher 16bits.

Referenced by XCan_GetECCCount().

#define XCAN_MASK_LOW_16BITS 0x0000FFFF

Mask to obtain lower 16bits.

Referenced by XCan_GetECCCount().

#define XCAN_MAX_FRAME_SIZE 16

Maximum CAN frame length in bytes.

#define XCAN_MAX_FRAME_SIZE_IN_WORDS (XCAN_MAX_FRAME_SIZE / sizeof(u32))

Max Frame Size.

Referenced by XCan_SelfTest().

#define XCAN_MODE_CONFIG 0x00000001

Configuration mode.

Referenced by main(), XCan_EnterMode(), XCan_GetMode(), XCan_SelfTest(), XCan_SetBaudRatePrescaler(), XCan_SetBitTiming(), and XCanPolledExample().

#define XCAN_MODE_LOOPBACK 0x00000004

Loop Back mode.

Referenced by main(), XCan_EnterMode(), XCan_GetMode(), XCan_SelfTest(), and XCanPolledExample().

#define XCAN_MODE_NORMAL 0x00000002

Normal mode.

Referenced by XCan_EnterMode(), and XCan_GetMode().

#define XCAN_MODE_SLEEP 0x00000008

Sleep mode.

Referenced by XCan_EnterMode(), and XCan_GetMode().

#define XCAN_MSR_LBACK_MASK 0x00000002

Loop Back Mode Select Mask.

Referenced by XCan_EnterMode().

#define XCAN_MSR_OFFSET 0x004

Mode Select Register.

Referenced by XCan_EnterMode().

#define XCAN_MSR_SLEEP_MASK 0x00000001

Sleep Mode Select Mask.

Referenced by XCan_EnterMode().

#define XCan_ReadReg | ( |  | BaseAddress,
|  |  | RegOffset
| ) |  | Xil_In32((BaseAddress) + (RegOffset))

This macro reads the given register.

Parameters

  BaseAddress | is the base address of the device
  RegOffset | is the register offset to be read

Returns
  The 32-bit value of the register

Note
  C-Style signature: u32 XCan_ReadReg(u32 BaseAddress, u32 RegOffset);

Referenced by XCan_AcceptFilterDisable(), XCan_AcceptFilterEnable(), XCan_AcceptFilterGet(), XCan_AcceptFilterGetEnabled(), XCan_GetBaudRatePrescaler(), XCan_GetBitTiming(), XCan_GetBusErrorCounter(), XCan_GetBusErrorStatus(), XCan_GetECCCount(), XCan_GetStatus(), XCan_InterruptGetEnabled(), XCan_InterruptGetStatus(), and XCan_Recv().

#define XCAN_RXFIFO_DLC_OFFSET 0x054

RX FIFO DLC.

Referenced by XCan_Recv().

#define XCAN_RXFIFO_DW1_OFFSET 0x058

RX FIFO Data Word 1.

Referenced by XCan_Recv().

#define XCAN_RXFIFO_DW2_OFFSET 0x05C

RX FIFO Data Word 2.

Referenced by XCan_Recv().

#define XCAN_RXFIFO_ECC_OFFSET 0X0D4

RX FIFO ECC error counter.

Referenced by XCan_GetECCCount().

#define XCAN_RXFIFO_ID_OFFSET 0x050

RX FIFO ID.

Referenced by XCan_Recv().

#define XCAN_SR_ACFBSY_MASK 0x00000800

Acceptance Filter busy Mask.

#define XCAN_SR_BBSY_MASK 0x00000020

Bus Busy Mask.

#define XCAN_SR_BIDLE_MASK 0x00000010

Bus Idle Mask.

#define XCAN_SR_CONFIG_MASK 0x00000001

Configuration Mode Mask.

Referenced by XCan_GetMode().

#define XCAN_SR_ERRWRN_MASK 0x00000040

Error Warning Mask.

#define XCAN_SR_ESTAT_MASK 0x00000180

Error Status Mask.

#define XCAN_SR_ESTAT_SHIFT 7

Error Status Shift.

#define XCAN_SR_LBACK_MASK 0x00000002

Loop Back Mode Mask.

#define XCAN_SR_NORMAL_MASK 0x00000008

Normal Mode Mask.

Referenced by XCan_GetMode().

#define XCAN_SR_OFFSET 0x018

Status Register.

Referenced by XCan_GetStatus().

#define XCAN_SR_SLEEP_MASK 0x00000004

Sleep Mode Mask.

Referenced by XCan_GetMode().

#define XCAN_SR_TXBFLL_MASK 0x00000200

TX High Priority Buffer full.

#define XCAN_SR_TXFLL_MASK 0x00000400

TX FIFO is full Mask.

#define XCAN_SRR_CEN_MASK 0x00000002

Can Enable Mask.

Referenced by XCan_EnterMode().

#define XCAN_SRR_OFFSET 0x000

Software Reset Register.

Referenced by XCan_EnterMode(), and XCan_Reset().

#define XCAN_SRR_SRST_MASK 0x00000001

Reset Mask.

Referenced by XCan_Reset().

#define XCAN_TXBUF_DLC_OFFSET 0x044

TX High Priority Buffer DLC.

Referenced by XCan_SendHighPriority().

#define XCAN_TXBUF_DW1_OFFSET 0x048

TX High Priority Buf Data Word 1.

Referenced by XCan_SendHighPriority().

#define XCAN_TXBUF_DW2_OFFSET 0x04C

TX High Priority Buf Data Word 2.

Referenced by XCan_SendHighPriority().

#define XCAN_TXBUF_ID_OFFSET 0x040

TX High Priority Buffer ID.

Referenced by XCan_SendHighPriority().

#define XCAN_TXFIFO_DLC_OFFSET 0x034

TX FIFO DLC.

Referenced by XCan_Send().

#define XCAN_TXFIFO_DW1_OFFSET 0x038

TX FIFO Data Word 1.

Referenced by XCan_Send().

#define XCAN_TXFIFO_DW2_OFFSET 0x03C

TX FIFO Data Word 2.

Referenced by XCan_Send().

#define XCAN_TXFIFO_ID_OFFSET 0x030

TX FIFO ID.

Referenced by XCan_Send().

#define XCAN_TXOLFIFO_ECC_OFFSET 0x0D0

TXOL FIFO ECC error counter.

Referenced by XCan_GetECCCount().

#define XCAN_TXTLFIFO_ECC_OFFSET 0x0CC

TXTL FIFO ECC error counter.

Referenced by XCan_GetECCCount().

#define XCan_WriteReg | ( |  | BaseAddress,
|  |  | RegOffset,
|  |  | Data
| ) |  | Xil_Out32((BaseAddress) + (RegOffset), (Data))

This macro writes the given register.

Parameters

  BaseAddress | is the base address of the device
  RegOffset | is the register offset to be written
  Data | is the 32-bit value to write to the register

Returns
  None.

Note
  C-Style signature: u32 XCan_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data);

Referenced by XCan_AcceptFilterDisable(), XCan_AcceptFilterEnable(), XCan_AcceptFilterSet(), XCan_ClearBusErrorStatus(), XCan_EnterMode(), XCan_InterruptClear(), XCan_InterruptDisable(), XCan_InterruptEnable(), XCan_Reset(), XCan_ResetECC(), XCan_Send(), XCan_SendHighPriority(), XCan_SetBaudRatePrescaler(), and XCan_SetBitTiming().

## Typedef Documentation

typedef void(* XCan_ErrorHandler)(void *CallBackRef, u32 ErrorMask)

Callback type for error interrupt.

Parameters

  CallBackRef | is a callback reference passed in by the upper layer when setting the callback functions, and passed back to the upper layer when the callback is invoked.
  ErrorMask | is a bit mask indicating the cause of the error. Its value equals 'OR'ing one or more XCAN_ESR_* values defined in xcan_l.h

typedef void(* XCan_EventHandler)(void *CallBackRef, u32 Mask)

Callback type for all kinds of interrupts except sending frame interrupt, receiving frame interrupt, and error interrupt.

Parameters

  CallBackRef | is a callback reference passed in by the upper layer when setting the callback functions, and passed back to the upper layer when the callback is invoked.
  Mask | is a bit mask indicating the pending interrupts. Its value equals 'OR'ing one or more XCAN_IXR_* defined in xcan_l.h

typedef void(* XCan_SendRecvHandler)(void *CallBackRef)

Callback type for frame sending and reception interrupts.

Parameters

  CallBackRef | is a callback reference passed in by the upper layer when setting the callback functions, and passed back to the upper layer when the callback is invoked.

## Function Documentation

void XCan_AcceptFilterDisable | ( | XCan * | InstancePtr,
|  | u32 | FilterIndexes
| ) |  |

This routine disables individual acceptance filters.

Up to 4 filters could be disabled. If all acceptance filters are disabled then all received frames are stored in the RX FIFO.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FilterIndexes | specifies which filter(s) to disable. Use any XCAN_AFR_UAF*_MASK to disable one filter, and "Or" multiple XCAN_AFR_UAF*_MASK values if multiple filters need to be disabled. Any filter not specified in this parameter will keep its previous enable/disable setting. If all acceptance filters are disabled then all received frames are stored in the RX FIFO.

Returns
  None.

Note

Acceptance Filter Register is an optional register in Xilinx CAN device. If it is NOT existing in the device, this function should NOT be used. Calling this function in this case will cause an assertion failure.

References XCan::BaseAddress, XCan::IsReady, XCan::NumOfAcceptFilters, XCAN_AFR_OFFSET, XCAN_AFR_UAF_ALL_MASK, XCan_ReadReg, and XCan_WriteReg.

void XCan_AcceptFilterEnable | ( | XCan * | InstancePtr,
|  | u32 | FilterIndexes
| ) |  |

This routine enables individual acceptance filters.

Up to 4 filters could be enabled.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FilterIndexes | specifies which filter(s) to enable. Use any XCAN_AFR_UAF*_MASK to enable one filter, and "Or" multiple XCAN_AFR_UAF*_MASK values if multiple filters need to be enabled. Any filter not specified in this parameter will keep its previous enable/disable setting.

Returns
  None.

Note

Acceptance Filter Register is an optional register in Xilinx CAN device. If it is NOT existing in the device, this function should NOT be used. Calling this function in this case will cause an assertion failure.

References XCan::BaseAddress, XCan::IsReady, XCan::NumOfAcceptFilters, XCAN_AFR_OFFSET, XCAN_AFR_UAF_ALL_MASK, XCan_ReadReg, and XCan_WriteReg.

void XCan_AcceptFilterGet | ( | XCan * | 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.

Use XCAN_IDR_* defined in xcan_l.h to interpret the values. Read xcan.h and device specification for details.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FilterIndex | defines which Acceptance Filter Mask Register to get Mask and ID from. Use any single XCAN_FILTER_* value.
  MaskValue | will store the Mask value read from the chosen Acceptance Filter Mask Register after this function returns.
  IdValue | will store the ID value read from the chosen Acceptance Filter ID Register after this function returns.

Returns
  None.

Note

Acceptance Filter Mask and ID Registers are optional registers in Xilinx CAN device. If they are NOT existing in the device, this function should NOT be used. Calling this function in this case will cause an assertion failure.

References XCan::BaseAddress, XCan::IsReady, XCan::NumOfAcceptFilters, XCAN_AFIR1_OFFSET, XCAN_AFIR2_OFFSET, XCAN_AFIR3_OFFSET, XCAN_AFIR4_OFFSET, XCAN_AFMR1_OFFSET, XCAN_AFMR2_OFFSET, XCAN_AFMR3_OFFSET, XCAN_AFMR4_OFFSET, XCAN_AFR_UAF1_MASK, XCAN_AFR_UAF2_MASK, XCAN_AFR_UAF3_MASK, XCAN_AFR_UAF4_MASK, and XCan_ReadReg.

u32 XCan_AcceptFilterGetEnabled | ( | XCan * | InstancePtr | ) |

This function returns enabled acceptance filters.

Use XCAN_AFR_UAF*_MASK defined in xcan_l.h to interpret the returned value. If no acceptance filters are enabled then all received frames are stored in the RX FIFO.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  The value stored in Acceptance Filter Register.

Note

Acceptance Filter Register is an optional register in Xilinx CAN device. If it is NOT existing in the device, this function should NOT be used. Calling this function in this case will cause an assertion failure.

References XCan::BaseAddress, XCan::IsReady, XCan::NumOfAcceptFilters, XCAN_AFR_OFFSET, and XCan_ReadReg.

Referenced by XCan_AcceptFilterSet().

int XCan_AcceptFilterSet | ( | XCan * | 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.

Use XCAN_IDR_* defined in xcan_l.h to create the values to set the filter. Read xcan.h and device specification for details.

This function should be called only after:

- The given filter is disabled by calling XCan_AcceptFilterDisable();
- And the CAN device is ready to accept writes to AFMR and AFIR, i.e., XCan_IsAcceptFilterBusy() returns FALSE.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FilterIndex | defines which Acceptance Filter Mask and ID Register to set. Use any single XCAN_AFR_UAF*_MASK value.
  MaskValue | is the value to write to the chosen Acceptance Filter Mask Register.
  IdValue | is the value to write to the chosen Acceptance Filter ID Register.

Returns
  - XST_SUCCESS if the values were set successfully.
  - XST_FAILURE if the given filter was not disabled, or the CAN device was not ready to accept writes to AFMR and AFIR.

Note

Acceptance Filter Mask and ID Registers are optional registers in Xilinx CAN device. If they are NOT existing in the device, this function should NOT be used. Calling this function in this case will cause an assertion failure.

References XCan::BaseAddress, XCan::IsReady, XCan::NumOfAcceptFilters, XCan_AcceptFilterGetEnabled(), XCAN_AFIR1_OFFSET, XCAN_AFIR2_OFFSET, XCAN_AFIR3_OFFSET, XCAN_AFIR4_OFFSET, XCAN_AFMR1_OFFSET, XCAN_AFMR2_OFFSET, XCAN_AFMR3_OFFSET, XCAN_AFMR4_OFFSET, XCAN_AFR_UAF1_MASK, XCAN_AFR_UAF2_MASK, XCAN_AFR_UAF3_MASK, XCAN_AFR_UAF4_MASK, XCan_IsAcceptFilterBusy, and XCan_WriteReg.

void XCan_ClearBusErrorStatus | ( | XCan * | InstancePtr,
|  | u32 | Mask
| ) |  |

This function clears Error Status bit(s) previously set in Error Status Register (ESR).

Use the XCAN_ESR_* constants defined in xcan_l.h to create the value to pass in. If a bit was cleared in Error Status Register before this function is called, it will not be touched.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  Mask | is he 32-bit mask used to clear bits in Error Status Register. Multiple XCAN_ESR_* values could be 'OR'ed to clear multiple bits

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_ESR_OFFSET, and XCan_WriteReg.

Referenced by XCan_IntrHandler().

void XCan_EnterMode | ( | XCan * | InstancePtr,
|  | u8 | OperationMode
| ) |  |

This function allows the CAN device to enter one of the following operation modes:

- Configuration Mode: Pass in parameter XCAN_MODE_CONFIG
- Sleep Mode: Pass in parameter XCAN_MODE_SLEEP
- Normal Mode: Pass in parameter XCAN_MODE_NORMAL
- Loop Back Mode: Pass in parameter XCAN_MODE_LOOPBACK.

Read xcan.h and device specification for detailed description of each operation mode.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  OperationMode | specify which operation mode to enter. Valid value is any of XCAN_MODE_* defined in xcan.h. Please note no multiple modes could be entered at the same time.

Returns
  None.

Note

This function does NOT ensure CAN device enters the specified operation mode before returns the control to the caller. The caller is responsible for checking current operation mode using XCan_GetMode().

References XCan::BaseAddress, XCan::IsReady, XCan_GetMode(), XCAN_MODE_CONFIG, XCAN_MODE_LOOPBACK, XCAN_MODE_NORMAL, XCAN_MODE_SLEEP, XCAN_MSR_LBACK_MASK, XCAN_MSR_OFFSET, XCAN_MSR_SLEEP_MASK, XCAN_SRR_CEN_MASK, XCAN_SRR_OFFSET, and XCan_WriteReg.

Referenced by main(), XCan_SelfTest(), and XCanPolledExample().

u8 XCan_GetBaudRatePrescaler | ( | XCan * | InstancePtr | ) |

This routine gets Baud Rate Prescaler value.

The system clock for the CAN controller is divided by (Prescaler + 1) to generate the quantum clock needed for sampling and synchronization. Read the device specification for details.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  Current used Baud Rate Prescaler value. The value's range is from 0 to 255.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_BRPR_OFFSET, and XCan_ReadReg.

void XCan_GetBitTiming | ( | XCan * | InstancePtr,
|  | u8 * | SyncJumpWidth,
|  | u8 * | TimeSegment2,
|  | u8 * | TimeSegment1
| ) |  |

This routine gets Bit time.

Time segment 1, Time segment 2 and Synchronization Jump Width values are read in this function. According to device specification, the actual value of each of these fields is one more than the value read. Read the device specification for details.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  SyncJumpWidth | will store the Synchronization Jump Width value after this function returns. Its value ranges from 0 to 3.
  TimeSegment2 | will store the Time Segment 2 value after this function returns. Its value ranges from 0 to 7.
  TimeSegment1 | will store the Time Segment 1 value after this function returns. Its value ranges from 0 to 15.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_BTR_OFFSET, XCAN_BTR_SJW_MASK, XCAN_BTR_SJW_SHIFT, XCAN_BTR_TS1_MASK, XCAN_BTR_TS2_MASK, XCAN_BTR_TS2_SHIFT, and XCan_ReadReg.

void XCan_GetBusErrorCounter | ( | XCan * | InstancePtr,
|  | u8 * | RxErrorCount,
|  | u8 * | TxErrorCount
| ) |  |

This function reads Receive and Transmit error counters.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  RxErrorCount | will contain Receive Error Counter value after this function returns.
  TxErrorCount | will contain Transmit Error Counter value after this function returns.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_ECR_OFFSET, XCAN_ECR_REC_MASK, XCAN_ECR_REC_SHIFT, XCAN_ECR_TEC_MASK, and XCan_ReadReg.

u32 XCan_GetBusErrorStatus | ( | XCan * | InstancePtr | ) |

This function reads Error Status value from Error Status Register (ESR).

Use the XCAN_ESR_* constants defined in xcan_l.h to interpret the returned value.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  The 32-bit value read from Error Status Register.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_ESR_OFFSET, and XCan_ReadReg.

Referenced by XCan_IntrHandler().

XCan_Config * XCan_GetConfig | ( | unsigned int | InstanceIndex | ) |

This function looks for the device configuration based on the device index.

The table XCan_ConfigTable[] contains the configuration information for each device in the system.

Parameters

  InstanceIndex | is a 0-based integer indexing all CAN devices in the system.

Returns
  A pointer to the configuration table entry corresponding to the given device ID, or NULL if no match is found.

Note
  None.

void XCan_GetECCCount | ( | XCan * | InstancePtr | ) |

This function gets the count of ECC error count for one and two bit error in TX_TL FIFO, TX_OL FIFO, RX FIFO.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::ecc_1bit_rxfifo_cnt, XCan::ecc_1bit_txolfifo_cnt, XCan::ecc_1bit_txtlfifo_cnt, XCan::ecc_2bit_rxfifo_cnt, XCan::ecc_2bit_txolfifo_cnt, XCan::ecc_2bit_txtlfifo_cnt, XCan::IsReady, XCAN_ECC_2BIT_SHIFT, XCan_InterruptGetStatus(), XCAN_IXR_E1BERX_MASK, XCAN_IXR_E1BETXOL_MASK, XCAN_IXR_E1BETXTL_MASK, XCAN_IXR_E2BERX_MASK, XCAN_IXR_E2BETXOL_MASK, XCAN_IXR_E2BETXTL_MASK, XCAN_MASK_HIGH_16BITS, XCAN_MASK_LOW_16BITS, XCan_ReadReg, XCAN_RXFIFO_ECC_OFFSET, XCAN_TXOLFIFO_ECC_OFFSET, and XCAN_TXTLFIFO_ECC_OFFSET.

Referenced by XCan_IntrHandler().

u8 XCan_GetMode | ( | XCan * | InstancePtr | ) |

This routine returns current operation mode the CAN device is in.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - XCAN_MODE_CONFIG if the device is in Configuration Mode.
  - XCAN_MODE_SLEEP if the device is in Sleep Mode.
  - XCAN_MODE_NORMAL if the device is in Normal Mode.
  - XCAN_MODE_LOOPBACK if the device is in Loop Back Mode.

Note
  None.

References XCan::IsReady, XCan_GetStatus(), XCAN_MODE_CONFIG, XCAN_MODE_LOOPBACK, XCAN_MODE_NORMAL, XCAN_MODE_SLEEP, XCAN_SR_CONFIG_MASK, XCAN_SR_NORMAL_MASK, and XCAN_SR_SLEEP_MASK.

Referenced by main(), XCan_EnterMode(), XCan_SelfTest(), XCan_SetBaudRatePrescaler(), XCan_SetBitTiming(), and XCanPolledExample().

u32 XCan_GetStatus | ( | XCan * | InstancePtr | ) |

This function returns Status value from Status Register (SR).

Use the XCAN_SR_* constants defined in xcan_l.h to interpret the returned value.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  The 32-bit value read from Status Register.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCan_ReadReg, and XCAN_SR_OFFSET.

Referenced by XCan_GetMode().

int XCan_Initialize | ( | XCan * | InstancePtr,
|  | u16 | DeviceId
| ) |  |

This routine initializes a specific XCan instance/driver.

This function should only be used when no Virtual Memory support is needed. To use virtual memory, the caller should invoke XCan_VmInitialize(). See the description of XCan_VmInitialize() for detailed information.

This initialization entails:

- Search for device configuration given the device ID.
- Initialize Base Address field of the XCan structure using the device address in the found device configuration.
- Populate all other data fields in the XCan structure
- Reset the device.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  DeviceId | is the unique ID of the device controlled by this XCan instance. Passing in a device ID associates the generic XCan instance to a specific device, as chosen by the caller or application developer.

Returns
  - XST_SUCCESS if initialization was successful
    - XST_DEVICE_NOT_FOUND if device configuration information was not found for a device with the supplied device ID.

Note
  None.

References XCan_Config::BaseAddress, XCan::BaseAddress, and XCan_LookupConfig().

Referenced by main(), and XCanPolledExample().

void XCan_InterruptClear | ( | XCan * | InstancePtr,
|  | u32 | Mask
| ) |  |

This function clears interrupt(s).

Every bit set in Interrupt Status Register indicates that a specific type of interrupt is occurring, and this function clears one or more interrupts by writing a bit mask to Interrupt Clear Register.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  Mask | is the mask to clear. Bit positions of 1 will be cleared. Bit positions of 0 will not change the previous interrupt status. This mask is formed by OR'ing XCAN_IXR_* bits defined in xcan_l.h.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_ICR_OFFSET, XCan_InterruptGetStatus(), and XCan_WriteReg.

Referenced by XCan_IntrHandler(), and XCan_Recv().

void XCan_InterruptDisable | ( | XCan * | InstancePtr,
|  | u32 | Mask
| ) |  |

This routine disables interrupt(s).

Use the XCAN_IXR_* constants defined in xcan_l.h to create the bit-mask to disable interrupt(s).

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  Mask | is the mask to disable. Bit positions of 1 will be disabled. Bit positions of 0 will keep the previous setting. This mask is formed by OR'ing XCAN_IXR_* bits defined in xcan_l.h.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_IER_OFFSET, XCan_InterruptGetEnabled(), and XCan_WriteReg.

void XCan_InterruptEnable | ( | XCan * | InstancePtr,
|  | u32 | Mask
| ) |  |

This routine enables interrupt(s).

Use the XCAN_IXR_* constants defined in xcan_l.h to create the bit-mask to enable interrupts.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  Mask | is the mask to enable. Bit positions of 1 will be enabled. Bit positions of 0 will keep the previous setting. This mask is formed by OR'ing XCAN_IXR_* bits defined in xcan_l.h.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_IER_OFFSET, and XCan_WriteReg.

Referenced by main().

u32 XCan_InterruptGetEnabled | ( | XCan * | InstancePtr | ) |

This routine returns enabled interrupt(s).

Use the XCAN_IXR_* constants defined in xcan_l.h to interpret the returned value.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  Enabled interrupt(s) in a 32-bit format.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_IER_OFFSET, and XCan_ReadReg.

Referenced by XCan_InterruptDisable(), and XCan_IntrHandler().

u32 XCan_InterruptGetStatus | ( | XCan * | InstancePtr | ) |

This routine returns interrupt status read from Interrupt Status Register.

Use the XCAN_IXR_* constants defined in xcan_l.h to interpret the returned value.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  The value stored in Interrupt Status Register.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_ISR_OFFSET, and XCan_ReadReg.

Referenced by XCan_GetECCCount(), XCan_InterruptClear(), and XCan_IntrHandler().

void XCan_IntrHandler | ( | void * | InstancePtr | ) |

This routine is the interrupt handler for the CAN driver.

This handler reads the interrupt status from the ISR, determines the source of the interrupts, calls according callbacks, and finally clears the interrupts.

Application beyond this driver is responsible for providing callbacks to handle interrupts and installing the callbacks using XCan_SetHandler() during initialization phase. An example delivered with this driver demonstrates how this could be done.

Parameters

  InstancePtr | is a pointer to the XCan instance that just interrupted.

Returns
  None.

Note
  None.

References XCan::EnableECC, XCan::ErrorHandler, XCan::ErrorRef, XCan::EventHandler, XCan::EventRef, XCan::IsReady, XCan::RecvHandler, XCan::RecvRef, XCan::SendHandler, XCan::SendRef, XCan_ClearBusErrorStatus(), XCan_GetBusErrorStatus(), XCan_GetECCCount(), XCan_InterruptClear(), XCan_InterruptGetEnabled(), XCan_InterruptGetStatus(), XCAN_IXR_ARBLST_MASK, XCAN_IXR_BSOFF_MASK, XCAN_IXR_ECC_MASK, XCAN_IXR_ERROR_MASK, XCAN_IXR_RXNEMP_MASK, XCAN_IXR_RXOFLW_MASK, XCAN_IXR_RXUFLW_MASK, XCAN_IXR_SLP_MASK, XCAN_IXR_TXBFLL_MASK, XCAN_IXR_TXFLL_MASK, XCAN_IXR_TXOK_MASK, XCAN_IXR_WKUP_MASK, and XCan_ResetECC().

Referenced by main().

XCan_Config * XCan_LookupConfig | ( | u16 | DeviceId | ) |

This function looks for the device configuration based on the unique device ID.

The table XCan_ConfigTable[] contains the configuration information for each device in the system.

Parameters

  DeviceId | is the unique device ID of the device being looked up.

Returns
  A pointer to the configuration table entry corresponding to the given device ID, or NULL if no match is found.

Note
  None.

Referenced by main(), XCan_Initialize(), and XCan_VmInitialize().

int XCan_Recv | ( | XCan * | InstancePtr,
|  | u32 * | FramePtr
| ) |  |

This function receives a CAN Frame.

This function first checks if RX FIFO is empty, if not, it then reads a frame from the RX FIFO into the given buffer. This function returns error code immediately if there is no frame in the RX FIFO.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FramePtr | is a pointer to a 32-bit aligned buffer where the CAN frame to be written.

Returns
  - XST_SUCCESS if RX FIFO was not empty and a frame was read from RX FIFO successfully and written into the given buffer;
  - XST_NO_DATA if there is no frame to be received from the FIFO

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCan_InterruptClear(), XCan_IsRxEmpty, XCAN_IXR_RXNEMP_MASK, XCan_ReadReg, XCAN_RXFIFO_DLC_OFFSET, XCAN_RXFIFO_DW1_OFFSET, XCAN_RXFIFO_DW2_OFFSET, and XCAN_RXFIFO_ID_OFFSET.

Referenced by main(), and XCan_SelfTest().

void XCan_Reset | ( | XCan * | InstancePtr | ) |

This function resets the CAN device.

Calling this function resets the device immediately, and any pending transmission or reception is terminated at once. Both Object Layer and Transfer Layer are reset. This function does not reset the Physical Layer. All registers are reset to the default values, and no previous status will be restored. TX FIFO, RX FIFO and TX High Priority Buffer are also reset.

When a reset is required due to an internal error, the driver notifies the upper layer software of this need through the error status code or interrupts The upper layer software is responsible for calling this Reset function and then re-configuring the device.

The CAN device will be in Configuration Mode immediately after this function returns.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_SRR_OFFSET, XCAN_SRR_SRST_MASK, and XCan_WriteReg.

Referenced by main(), and XCan_SelfTest().

void XCan_ResetECC | ( | XCan * | InstancePtr | ) |

This function resets the ECC counters.

Calling this function resets all the ECC counters immediately. The register is reset to default value, and no previous status will be restored.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  None.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_ECC_CFG_OFFSET, XCAN_ECC_CFG_RST_MASK, and XCan_WriteReg.

Referenced by XCan_IntrHandler().

int XCan_SelfTest | ( | XCan * | InstancePtr | ) |

This function runs a self-test on the CAN driver/device.

The test resets the device, sets up the Loop Back mode, sends a standard frame, receives the frame, verifies the contents, and resets the device again.

Note that this is a destructive test in that resets of the device are performed. Refer to the device specification for the device status after the reset operation.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.

Returns
  - XST_SUCCESS if the self-test passed. i.e., the frame received via the internal loop back has the same contents as the sent frame.
    - XST_FAILURE Otherwise.

Note

If the CAN device does not work properly, this function may enter an infinite loop and will never return to the caller.
If XST_FAILURE is returned, the device is not reset so that the caller could have a chance to check reason(s) causing the failure.

References XCan::IsReady, TEST_CAN_DLC, TEST_MESSAGE_ID, XCan_CreateDlcValue, XCan_CreateIdValue, XCan_EnterMode(), XCan_GetMode(), XCan_IsRxEmpty, XCAN_MAX_FRAME_SIZE_IN_WORDS, XCAN_MODE_CONFIG, XCAN_MODE_LOOPBACK, XCan_Recv(), XCan_Reset(), XCan_Send(), XCan_SetBaudRatePrescaler(), and XCan_SetBitTiming().

Referenced by main(), and XCanPolledExample().

int XCan_Send | ( | XCan * | InstancePtr,
|  | u32 * | FramePtr
| ) |  |

This function sends a CAN Frame.

This function first checks if TX FIFO is full. If not, it then writes the given frame into the TX FIFO; otherwise, it returns error code immediately. This function does not wait for the given frame being sent to CAN bus.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FramePtr | is a pointer to a 32-bit aligned buffer containing the CAN frame to be sent.

Returns
  - XST_SUCCESS if TX FIFO was not full and the given frame was written into the FIFO;
  - XST_FIFO_NO_ROOM if there is no room in the TX FIFO for the given frame

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCan_IsTxFifoFull, XCAN_TXFIFO_DLC_OFFSET, XCAN_TXFIFO_DW1_OFFSET, XCAN_TXFIFO_DW2_OFFSET, XCAN_TXFIFO_ID_OFFSET, and XCan_WriteReg.

Referenced by main(), and XCan_SelfTest().

int XCan_SendHighPriority | ( | XCan * | InstancePtr,
|  | u32 * | FramePtr
| ) |  |

This routine sends a CAN High Priority frame.

This function first checks if TX High Priority Buffer is empty. If yes, it then writes the given frame into the Buffer. If not, This function returns immediately. This function does not wait for the given frame being sent to CAN bus.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  FramePtr | is a pointer to a 32-bit aligned buffer containing the CAN High Priority frame to be sent.

Returns
  - XST_SUCCESS if TX High Priority Buffer was not full and the given frame was written into the buffer;
  - XST_FIFO_NO_ROOM if there is no room in the TX High Priority Buffer for this frame.

Note

If the frame needs to be sent immediately and not delayed by processor's interrupts handling, the caller should disable interrupt at processor level before invoking this function.

References XCan::BaseAddress, XCan::IsReady, XCan_IsHighPriorityBufFull, XCAN_TXBUF_DLC_OFFSET, XCAN_TXBUF_DW1_OFFSET, XCAN_TXBUF_DW2_OFFSET, XCAN_TXBUF_ID_OFFSET, and XCan_WriteReg.

int XCan_SetBaudRatePrescaler | ( | XCan * | InstancePtr,
|  | u8 | Prescaler
| ) |  |

This routine sets Baud Rate Prescaler value.

The system clock for the CAN controller is divided by (Prescaler + 1) to generate the quantum clock needed for sampling and synchronization. Read the device specification for details.

Baud Rate Prescaler could be set only after CAN device entered Configuration Mode. So please call XCan_EnterMode() to enter Configuration Mode before using this function.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  Prescaler | is the value to set. Valid values are from 0 to 255.

Returns
  - XST_SUCCESS if the Baud Rate Prescaler value is set successfully.
  - XST_FAILURE if CAN device is not in Configuration Mode.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_BRPR_OFFSET, XCan_GetMode(), XCAN_MODE_CONFIG, and XCan_WriteReg.

Referenced by main(), XCan_SelfTest(), and XCanPolledExample().

int XCan_SetBitTiming | ( | XCan * | InstancePtr,
|  | u8 | SyncJumpWidth,
|  | u8 | TimeSegment2,
|  | u8 | TimeSegment1
| ) |  |

This routine sets Bit time.

Time segment 1, Time segment 2 and Synchronization Jump Width are set in this function. Device specification requires the values passed into this function be one less than the actual values of these fields. Read the device specification for details.

Bit time could be set only after CAN device entered Configuration Mode. Please call XCan_EnterMode() to enter Configuration Mode before using this function.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  SyncJumpWidth | is the Synchronization Jump Width value to set. Valid values are from 0 to 3.
  TimeSegment2 | is the Time Segment 2 value to set. Valid values are from 0 to 7.
  TimeSegment1 | is the Time Segment 1 value to set. Valid values are from 0 to 15.

Returns
  - XST_SUCCESS if the Bit time is set successfully.
  - XST_FAILURE if CAN device is not in Configuration Mode.
    - XST_INVALID_PARAM if any value of SyncJumpWidth, TimeSegment2 and TimeSegment1 is invalid.

Note
  None.

References XCan::BaseAddress, XCan::IsReady, XCAN_BTR_OFFSET, XCAN_BTR_SJW_MASK, XCAN_BTR_SJW_SHIFT, XCAN_BTR_TS1_MASK, XCAN_BTR_TS2_MASK, XCAN_BTR_TS2_SHIFT, XCan_GetMode(), XCAN_MODE_CONFIG, and XCan_WriteReg.

Referenced by main(), XCan_SelfTest(), and XCanPolledExample().

int XCan_SetHandler | ( | XCan * | InstancePtr,
|  | u32 | HandlerType,
|  | void * | CallBackFunc,
|  | void * | CallBackRef
| ) |  |

This routine installs an asynchronous callback function for the given HandlerType:

    HandlerType              Callback Function Type
    -----------------------  ---------------------------
    XCAN_HANDLER_SEND        XCan_SendRecvHandler
    XCAN_HANDLER_RECV        XCan_SendRecvHandler
    XCAN_HANDLER_ERROR       XCan_ErrorHandler
    XCAN_HANDLER_EVENT       XCan_EventHandler

    HandlerType              Invoked by this driver when:
    -----------------------  --------------------------------------------------
    XCAN_HANDLER_SEND        A frame transmitted by a call to
                             XCan_Send() has been sent successfully.

    XCAN_HANDLER_RECV        A frame has been received and is sitting in
                             the RX FIFO.

    XCAN_HANDLER_ERROR       An error interrupt is occurring.

    XCAN_HANDLER_EVENT       Any other kind of interrupt is occurring.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  HandlerType | specifies which handler is to be attached.
  CallBackFunc | is the address of the callback function.
  CallBackRef | is a user data item that will be passed to the callback function when it is invoked.

Returns
  - XST_SUCCESS when handler is installed.
  - XST_INVALID_PARAM when HandlerType is invalid.

Note
  Invoking this function for a handler that already has been installed replaces it with the new handler.

References XCan::ErrorHandler, XCan::ErrorRef, XCan::EventHandler, XCan::EventRef, XCan::IsReady, XCan::RecvHandler, XCan::RecvRef, XCan::SendHandler, XCan::SendRef, XCAN_HANDLER_ERROR, XCAN_HANDLER_EVENT, XCAN_HANDLER_RECV, and XCAN_HANDLER_SEND.

Referenced by main().

int XCan_VmInitialize | ( | XCan * | InstancePtr,
|  | u16 | DeviceId,
|  | UINTPTR | VirtAddr
| ) |  |

This routine initializes of a specific XCan instance/driver.

This function should only be used if Virtual Memory support is necessary. The caller is responsible for calculating the correct device base address in Virtual memory address space and passing it into this function.

This initialization entails:

- Search for device configuration given the device ID.
- Initialize Base Address field of the XCan structure using the given virtual address parameter value.
- Populate all other data fields in the XCan structure.
- Reset the device.

Parameters

  InstancePtr | is a pointer to the XCan instance to be worked on.
  DeviceId | is the unique ID of the device controlled by this XCan instance. Passing in a device ID associates the generic XCan instance to a specific device, as chosen by the caller or application developer.
  VirtAddr | is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from VirtAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called.

Returns
  - XST_SUCCESS if initialization was successful
  - XST_DEVICE_NOT_FOUND if device configuration information was not found for a device with the supplied device ID.

Note
  None.

References XCan::BaseAddress, and XCan_LookupConfig().

## Variable Documentation

XCan_Config XCan_ConfigTable[XPAR_XCAN_NUM_INSTANCES]

Initial value:
= {
{
XPAR_OPB_CAN_0_DEVICE_ID,
XPAR_OPB_CAN_0_BASEADDR,
XPAR_OPB_CAN_0_CAN_NUM_ACF,
XPAR_OPB_CAN_0_ENABLE_ECC,
}
}

This table contains configuration information for each CAN device in the system.

XCan_Config XCan_ConfigTable[]

This table contains configuration information for each CAN device in the system.