can
Vitis Drivers API Documentation
|
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... | |
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... | |
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_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_ALL |
Mask for basic interrupts. More... | |
CAN Frame Identifier (TX High Priority Buffer/TX/RX/Acceptance Filter | |
#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... | |
CAN frame length constants | |
#define | XCAN_MAX_FRAME_SIZE 16 |
Maximum CAN frame length in bytes. More... | |
#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 |
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.
DataLengCode | indicates Data Length Code value. |
Read the CAN specification for meaning of Data Length Code.
Referenced by main(), and XCan_SelfTest().
#define XCan_CreateIdValue | ( | StandardId, | |
SubRemoteTransReq, | |||
IdExtension, | |||
ExtendedId, | |||
RemoteTransReq | |||
) |
This macro calculates CAN message identifier value given identifier field values.
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. |
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_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 | ) |
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
Referenced by XCan_AcceptFilterSet().
#define XCan_IsHighPriorityBufFull | ( | InstancePtr | ) |
This macro checks if the Transmission High Priority Buffer is full.
InstancePtr | is a pointer to the XCan instance to be worked on. |
Referenced by XCan_SendHighPriority().
#define XCAN_ISR_OFFSET 0x01C |
Interrupt Status Register.
Referenced by XCan_InterruptGetStatus().
#define XCan_IsRxEmpty | ( | InstancePtr | ) |
This macro checks if the receive FIFO is empty.
InstancePtr | is a pointer to the XCan instance to be worked on. |
Referenced by XCan_Recv(), and XCan_SelfTest().
#define XCan_IsTxDone | ( | InstancePtr | ) |
This macro checks if the transmission is complete.
InstancePtr | is a pointer to the XCan instance to be worked on. |
#define XCan_IsTxFifoFull | ( | InstancePtr | ) |
This macro checks if the transmission FIFO is full.
InstancePtr | is a pointer to the XCan instance to be worked on. |
Referenced by main(), and XCan_Send().
#define XCAN_IXR_ALL |
Mask for basic interrupts.
Referenced by main(), and XCan_InterruptEnable().
#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_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_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.
BaseAddress | is the base address of the device |
RegOffset | is the register offset to be read |
Referenced by XCan_AcceptFilterDisable(), XCan_AcceptFilterEnable(), XCan_AcceptFilterGet(), XCan_AcceptFilterGetEnabled(), XCan_GetBaudRatePrescaler(), XCan_GetBitTiming(), XCan_GetBusErrorCounter(), XCan_GetBusErrorStatus(), 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_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_WriteReg | ( | BaseAddress, | |
RegOffset, | |||
Data | |||
) | Xil_Out32((BaseAddress) + (RegOffset), (Data)) |
This macro writes the given register.
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 |
Referenced by XCan_AcceptFilterDisable(), XCan_AcceptFilterEnable(), XCan_AcceptFilterSet(), XCan_ClearBusErrorStatus(), XCan_EnterMode(), XCan_InterruptClear(), XCan_InterruptDisable(), XCan_InterruptEnable(), XCan_Reset(), XCan_Send(), XCan_SendHighPriority(), XCan_SetBaudRatePrescaler(), and XCan_SetBitTiming().
typedef void(* XCan_ErrorHandler)(void *CallBackRef, u32 ErrorMask) |
Callback type for error interrupt.
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.
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
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:
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. |
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.
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 |
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:
Read xcan.h and device specification for detailed description of each operation mode.
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. |
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
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.
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. |
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.
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. |
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
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.
InstanceIndex | is a 0-based integer indexing all CAN devices in the system. |
u8 XCan_GetMode | ( | XCan * | InstancePtr | ) |
This routine returns current operation mode the CAN device is in.
InstancePtr | is a pointer to the XCan instance to be worked on. |
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
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:
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. |
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.
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. |
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).
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. |
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.
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. |
References XCan::BaseAddress, XCan::IsReady, XCAN_IER_OFFSET, XCan_InterruptGetEnabled(), XCAN_IXR_ALL, 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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
References XCan::BaseAddress, XCan::IsReady, XCAN_IER_OFFSET, and XCan_ReadReg.
Referenced by XCan_InterruptDisable(), XCan_InterruptEnable(), 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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
References XCan::BaseAddress, XCan::IsReady, XCAN_ISR_OFFSET, and XCan_ReadReg.
Referenced by 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.
InstancePtr | is a pointer to the XCan instance that just interrupted. |
References XCan::ErrorHandler, XCan::ErrorRef, XCan::EventHandler, XCan::EventRef, XCan::IsReady, XCan::RecvHandler, XCan::RecvRef, XCan::SendHandler, XCan::SendRef, XCan_ClearBusErrorStatus(), XCan_GetBusErrorStatus(), XCan_InterruptClear(), XCan_InterruptGetEnabled(), XCan_InterruptGetStatus(), XCAN_IXR_ARBLST_MASK, XCAN_IXR_BSOFF_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, and XCAN_IXR_WKUP_MASK.
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.
DeviceId | is the unique device ID of the device being looked up. |
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.
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. |
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
References XCan::BaseAddress, XCan::IsReady, XCAN_SRR_OFFSET, XCAN_SRR_SRST_MASK, and XCan_WriteReg.
Referenced by main(), and XCan_SelfTest().
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.
InstancePtr | is a pointer to the XCan instance to be worked on. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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:
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. |
References XCan::BaseAddress, and XCan_LookupConfig().
XCan_Config XCan_ConfigTable[XPAR_XCAN_NUM_INSTANCES] |
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.