#include "xstatus.h"
#include "xcanps_hw.h"
Classes | |
struct | XCanPs_Config |
struct | XCanPs |
Defines | |
#define | XCANPS_H |
#define | XCanPs_IsTxDone(InstancePtr) |
#define | XCanPs_IsTxFifoFull(InstancePtr) |
#define | XCanPs_IsHighPriorityBufFull(InstancePtr) |
#define | XCanPs_IsRxEmpty(InstancePtr) |
#define | XCanPs_IsAcceptFilterBusy(InstancePtr) |
#define | XCanPs_CreateIdValue(StandardId, SubRemoteTransReq, IdExtension, ExtendedId, RemoteTransReq) |
#define | XCanPs_CreateDlcValue(DataLengCode) (((DataLengCode) << XCANPS_DLCR_DLC_SHIFT) & XCANPS_DLCR_DLC_MASK) |
#define | XCanPs_ClearTimestamp(InstancePtr) |
CAN operation modes | |
#define | XCANPS_MODE_CONFIG 0x00000001 |
#define | XCANPS_MODE_NORMAL 0x00000002 |
#define | XCANPS_MODE_LOOPBACK 0x00000004 |
#define | XCANPS_MODE_SLEEP 0x00000008 |
#define | XCANPS_MODE_SNOOP 0x00000010 |
Callback identifiers used as parameters to XCanPs_SetHandler() | |
#define | XCANPS_HANDLER_SEND 1 |
#define | XCANPS_HANDLER_RECV 2 |
#define | XCANPS_HANDLER_ERROR 3 |
#define | XCANPS_HANDLER_EVENT 4 |
Typedefs | |
typedef void(* | XCanPs_SendRecvHandler )(void *CallBackRef) |
typedef void(* | XCanPs_ErrorHandler )(void *CallBackRef, u32 ErrorMask) |
typedef void(* | XCanPs_EventHandler )(void *CallBackRef, u32 Mask) |
Functions | |
int | XCanPs_CfgInitialize (XCanPs *InstancePtr, XCanPs_Config *ConfigPtr, u32 EffectiveAddr) |
void | XCanPs_Reset (XCanPs *InstancePtr) |
u8 | XCanPs_GetMode (XCanPs *InstancePtr) |
void | XCanPs_EnterMode (XCanPs *InstancePtr, u8 OperationMode) |
u32 | XCanPs_GetStatus (XCanPs *InstancePtr) |
void | XCanPs_GetBusErrorCounter (XCanPs *InstancePtr, u8 *RxErrorCount, u8 *TxErrorCount) |
u32 | XCanPs_GetBusErrorStatus (XCanPs *InstancePtr) |
void | XCanPs_ClearBusErrorStatus (XCanPs *InstancePtr, u32 Mask) |
int | XCanPs_Send (XCanPs *InstancePtr, u32 *FramePtr) |
int | XCanPs_Recv (XCanPs *InstancePtr, u32 *FramePtr) |
int | XCanPs_SendHighPriority (XCanPs *InstancePtr, u32 *FramePtr) |
void | XCanPs_AcceptFilterEnable (XCanPs *InstancePtr, u32 FilterIndexes) |
void | XCanPs_AcceptFilterDisable (XCanPs *InstancePtr, u32 FilterIndexes) |
u32 | XCanPs_AcceptFilterGetEnabled (XCanPs *InstancePtr) |
int | XCanPs_AcceptFilterSet (XCanPs *InstancePtr, u32 FilterIndex, u32 MaskValue, u32 IdValue) |
void | XCanPs_AcceptFilterGet (XCanPs *InstancePtr, u32 FilterIndex, u32 *MaskValue, u32 *IdValue) |
int | XCanPs_SetBaudRatePrescaler (XCanPs *InstancePtr, u8 Prescaler) |
u8 | XCanPs_GetBaudRatePrescaler (XCanPs *InstancePtr) |
int | XCanPs_SetBitTiming (XCanPs *InstancePtr, u8 SyncJumpWidth, u8 TimeSegment2, u8 TimeSegment1) |
void | XCanPs_GetBitTiming (XCanPs *InstancePtr, u8 *SyncJumpWidth, u8 *TimeSegment2, u8 *TimeSegment1) |
int | XCanPs_SetRxIntrWatermark (XCanPs *InstancePtr, u8 Threshold) |
u8 | XCanPs_GetRxIntrWatermark (XCanPs *InstancePtr) |
int | XCanPs_SelfTest (XCanPs *InstancePtr) |
void | XCanPs_IntrEnable (XCanPs *InstancePtr, u32 Mask) |
void | XCanPs_IntrDisable (XCanPs *InstancePtr, u32 Mask) |
u32 | XCanPs_IntrGetEnabled (XCanPs *InstancePtr) |
u32 | XCanPs_IntrGetStatus (XCanPs *InstancePtr) |
void | XCanPs_IntrClear (XCanPs *InstancePtr, u32 Mask) |
void | XCanPs_IntrHandler (void *InstancePtr) |
int | XCanPs_SetHandler (XCanPs *InstancePtr, u32 HandlerType, void *CallBackFunc, void *CallBackRef) |
XCanPs_Config * | XCanPs_LookupConfig (u16 DeviceId) |
#define XCanPs_ClearTimestamp | ( | InstancePtr | ) |
XCanPs_WriteReg((InstancePtr)->CanConfig.BaseAddr, \ XCANPS_TCR_OFFSET, XCANPS_TCR_CTS_MASK)
This macro clears the timestamp in the Timestamp Control Register.
InstancePtr | is a pointer to the XCanPs instance. |
#define XCanPs_CreateDlcValue | ( | DataLengCode | ) | (((DataLengCode) << XCANPS_DLCR_DLC_SHIFT) & XCANPS_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.
#define XCanPs_CreateIdValue | ( | StandardId, | |||
SubRemoteTransReq, | |||||
IdExtension, | |||||
ExtendedId, | |||||
RemoteTransReq | ) |
((((StandardId) << XCANPS_IDR_ID1_SHIFT) & XCANPS_IDR_ID1_MASK) | \ (((SubRemoteTransReq) << XCANPS_IDR_SRR_SHIFT) & XCANPS_IDR_SRR_MASK)|\ (((IdExtension) << XCANPS_IDR_IDE_SHIFT) & XCANPS_IDR_IDE_MASK) | \ (((ExtendedId) << XCANPS_IDR_ID2_SHIFT) & XCANPS_IDR_ID2_MASK) | \ ((RemoteTransReq) & XCANPS_IDR_RTR_MASK))
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.
#define XCANPS_H |
#define XCANPS_HANDLER_ERROR 3 |
Handler type for error interrupt
#define XCANPS_HANDLER_EVENT 4 |
Handler type for all other interrupts
#define XCANPS_HANDLER_RECV 2 |
Handler type for frame reception interrupt
#define XCANPS_HANDLER_SEND 1 |
Handler type for frame sending interrupt
#define XCanPs_IsAcceptFilterBusy | ( | InstancePtr | ) |
((XCanPs_ReadReg(((InstancePtr)->CanConfig.BaseAddr), \ XCANPS_SR_OFFSET) & XCANPS_SR_ACFBSY_MASK) ? TRUE : FALSE)
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. The filter can be disabled using the XCanPs_AcceptFilterDisable function.
Use the XCanPs_Accept_* functions for configuring the acceptance filters.
InstancePtr | is a pointer to the XCanPs instance. |
#define XCanPs_IsHighPriorityBufFull | ( | InstancePtr | ) |
((XCanPs_ReadReg(((InstancePtr)->CanConfig.BaseAddr), \ XCANPS_SR_OFFSET) & XCANPS_SR_TXBFLL_MASK) ? TRUE : FALSE)
This macro checks if the Transmission High Priority Buffer is full.
InstancePtr | is a pointer to the XCanPs instance. |
#define XCanPs_IsRxEmpty | ( | InstancePtr | ) |
((XCanPs_ReadReg(((InstancePtr)->CanConfig.BaseAddr), \ XCANPS_ISR_OFFSET) & XCANPS_IXR_RXNEMP_MASK) ? FALSE : TRUE)
This macro checks if the receive FIFO is empty.
InstancePtr | is a pointer to the XCanPs instance. |
#define XCanPs_IsTxDone | ( | InstancePtr | ) |
((XCanPs_ReadReg(((InstancePtr)->CanConfig.BaseAddr), \ XCANPS_ISR_OFFSET) & XCANPS_IXR_TXOK_MASK) ? TRUE : FALSE)
This macro checks if the transmission is complete.
InstancePtr | is a pointer to the XCanPs instance. |
#define XCanPs_IsTxFifoFull | ( | InstancePtr | ) |
((XCanPs_ReadReg(((InstancePtr)->CanConfig.BaseAddr), \ XCANPS_SR_OFFSET) & XCANPS_SR_TXFLL_MASK) ? TRUE : FALSE)
This macro checks if the transmission FIFO is full.
InstancePtr | is a pointer to the XCanPs instance. |
#define XCANPS_MODE_CONFIG 0x00000001 |
Configuration mode
#define XCANPS_MODE_LOOPBACK 0x00000004 |
Loop Back mode
#define XCANPS_MODE_NORMAL 0x00000002 |
Normal mode
#define XCANPS_MODE_SLEEP 0x00000008 |
Sleep mode
#define XCANPS_MODE_SNOOP 0x00000010 |
Snoop mode
typedef void(* XCanPs_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 XCANPS_ESR_* values defined in xcanps_hw.h |
typedef void(* XCanPs_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 XCANPS_IXR_* defined in xcanps_hw.h |
typedef void(* XCanPs_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 XCanPs_AcceptFilterDisable | ( | XCanPs * | InstancePtr, | |
u32 | FilterIndexes | |||
) |
This routine disables individual acceptance filters. Up to 4 filters could be disabled. If all acceptance filters are disabled then all the received frames are stored in the RX FIFO.
InstancePtr | is a pointer to the XCanPs instance. | |
FilterIndexes | specifies which filter(s) to disable. Use any XCANPS_AFR_UAF*_MASK to disable one filter, and "Or" multiple XCANPS_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. |
void XCanPs_AcceptFilterEnable | ( | XCanPs * | InstancePtr, | |
u32 | FilterIndexes | |||
) |
This routine enables individual acceptance filters. Up to 4 filters could be enabled.
InstancePtr | is a pointer to the XCanPs instance. | |
FilterIndexes | specifies which filter(s) to enable. Use any XCANPS_AFR_UAF*_MASK to enable one filter, and "Or" multiple XCANPS_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. |
void XCanPs_AcceptFilterGet | ( | XCanPs * | 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 XCANPS_IDR_* defined in xcanps_hw.h to interpret the values. Read the xcanps.h file and device specification for details.
InstancePtr | is a pointer to the XCanPs instance. | |
FilterIndex | defines which Acceptance Filter Mask Register to get Mask and ID from. Use any single XCANPS_FILTER_* value. | |
MaskValue | is a pointer to the data in which the Mask value read from the chosen Acceptance Filter Mask Register is returned. | |
IdValue | is a pointer to the data in which the ID value read from the chosen Acceptance Filter ID Register is returned. |
u32 XCanPs_AcceptFilterGetEnabled | ( | XCanPs * | InstancePtr | ) |
This function returns enabled acceptance filters. Use XCANPS_AFR_UAF*_MASK defined in xcanps_hw.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 XCanPs instance. |
int XCanPs_AcceptFilterSet | ( | XCanPs * | 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 XCANPS_IDR_* defined in xcanps_hw.h to create the values to set the filter. Read the xcanps.h file and device specification for details.
This function should be called only after:
InstancePtr | is a pointer to the XCanPs instance. | |
FilterIndex | defines which Acceptance Filter Mask and ID Register to set. Use any single XCANPS_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. |
int XCanPs_CfgInitialize | ( | XCanPs * | InstancePtr, | |
XCanPs_Config * | ConfigPtr, | |||
u32 | EffectiveAddr | |||
) |
void XCanPs_ClearBusErrorStatus | ( | XCanPs * | InstancePtr, | |
u32 | Mask | |||
) |
This function clears Error Status bit(s) previously set in Error Status Register (ESR). Use the XCANPS_ESR_* constants defined in xcanps_hw.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 modified.
InstancePtr | is a pointer to the XCanPs instance. | |
Mask | is he 32-bit mask used to clear bits in Error Status Register. Multiple XCANPS_ESR_* values can be 'OR'ed to clear multiple bits. |
void XCanPs_EnterMode | ( | XCanPs * | InstancePtr, | |
u8 | OperationMode | |||
) |
This function allows the CAN device to enter one of the following operation modes:
Read the xcanps.h file and device specification for detailed description of each operation mode.
InstancePtr | is a pointer to the XCanPs instance. | |
OperationMode | specify which operation mode to enter. Valid value is any of XCANPS_MODE_* defined in xcanps.h. Multiple modes can not be entered at the same time. |
This function does NOT ensure CAN device enters the specified operation mode before it returns the control to the caller. The caller is responsible for checking current operation mode using XCanPs_GetMode().
u8 XCanPs_GetBaudRatePrescaler | ( | XCanPs * | 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 XCanPs instance. |
void XCanPs_GetBitTiming | ( | XCanPs * | 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 XCanPs instance. | |
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. |
void XCanPs_GetBusErrorCounter | ( | XCanPs * | InstancePtr, | |
u8 * | RxErrorCount, | |||
u8 * | TxErrorCount | |||
) |
This function reads Receive and Transmit error counters.
InstancePtr | is a pointer to the XCanPs instance. | |
RxErrorCount | is a pointer to data in which the Receive Error counter value is returned. | |
TxErrorCount | is a pointer to data in which the Transmit Error counter value is returned. |
u32 XCanPs_GetBusErrorStatus | ( | XCanPs * | InstancePtr | ) |
This function reads Error Status value from Error Status Register (ESR). Use the XCANPS_ESR_* constants defined in xcanps_hw.h to interpret the returned value.
InstancePtr | is a pointer to the XCanPs instance. |
u8 XCanPs_GetMode | ( | XCanPs * | InstancePtr | ) |
This routine returns the current operation mode of the CAN device.
InstancePtr | is a pointer to the XCanPs instance. |
u8 XCanPs_GetRxIntrWatermark | ( | XCanPs * | InstancePtr | ) |
This routine gets the Rx Full threshold from the Watermark Interrupt Register.
InstancePtr | is a pointer to the XCanPs instance. |
u32 XCanPs_GetStatus | ( | XCanPs * | InstancePtr | ) |
This function returns Status value from Status Register (SR). Use the XCANPS_SR_* constants defined in xcanps_hw.h to interpret the returned value.
InstancePtr | is a pointer to the XCanPs instance. |
void XCanPs_IntrClear | ( | XCanPs * | 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 XCanPs instance. | |
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 XCANPS_IXR_* bits defined in xcanps_hw.h. |
void XCanPs_IntrDisable | ( | XCanPs * | InstancePtr, | |
u32 | Mask | |||
) |
This routine disables interrupt(s). Use the XCANPS_IXR_* constants defined in xcanps_hw.h to create the bit-mask to disable interrupt(s).
InstancePtr | is a pointer to the XCanPs instance. | |
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 XCANPS_IXR_* bits defined in xcanps_hw.h. |
void XCanPs_IntrEnable | ( | XCanPs * | InstancePtr, | |
u32 | Mask | |||
) |
This routine enables interrupt(s). Use the XCANPS_IXR_* constants defined in xcanps_hw.h to create the bit-mask to enable interrupts.
InstancePtr | is a pointer to the XCanPs instance. | |
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 XCANPS_IXR_* bits defined in xcanps_hw.h. |
u32 XCanPs_IntrGetEnabled | ( | XCanPs * | InstancePtr | ) |
This routine returns enabled interrupt(s). Use the XCANPS_IXR_* constants defined in xcanps_hw.h to interpret the returned value.
InstancePtr | is a pointer to the XCanPs instance. |
u32 XCanPs_IntrGetStatus | ( | XCanPs * | InstancePtr | ) |
This routine returns interrupt status read from Interrupt Status Register. Use the XCANPS_IXR_* constants defined in xcanps_hw.h to interpret the returned value.
InstancePtr | is a pointer to the XCanPs instance. |
void XCanPs_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 XCanPs_SetHandler() during initialization phase. An example delivered with this driver demonstrates how this could be done.
InstancePtr | is a pointer to the XCanPs instance that just interrupted. |
XCanPs_Config* XCanPs_LookupConfig | ( | u16 | DeviceId | ) |
This function looks for the device configuration based on the unique device ID. The table XCanPs_ConfigTable[] contains the configuration information for each device in the system.
DeviceId | is the unique device ID of the device being looked up. |
int XCanPs_Recv | ( | XCanPs * | 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 XCanPs instance. | |
FramePtr | is a pointer to a 32-bit aligned buffer where the CAN frame to be written. |
void XCanPs_Reset | ( | XCanPs * | 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 XCanPs instance. |
int XCanPs_SelfTest | ( | XCanPs * | 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 the device specification for the device status after the reset operation.
InstancePtr | is a pointer to the XCanPs instance. |
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.
int XCanPs_Send | ( | XCanPs * | InstancePtr, | |
u32 * | FramePtr | |||
) |
This function sends a CAN Frame. If the TX FIFO is not full then the given frame is written into the the TX FIFO otherwise, it returns an error code immediately. This function does not wait for the given frame being sent to CAN bus.
InstancePtr | is a pointer to the XCanPs instance. | |
FramePtr | is a pointer to a 32-bit aligned buffer containing the CAN frame to be sent. |
int XCanPs_SendHighPriority | ( | XCanPs * | 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 XCanPs instance. | |
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 interrupt handling, the caller should disable interrupt at processor level before invoking this function.
int XCanPs_SetBaudRatePrescaler | ( | XCanPs * | 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 can be set only if the CAN device is in Configuration Mode. Call XCanPs_EnterMode() to enter Configuration Mode before using this function.
InstancePtr | is a pointer to the XCanPs instance. | |
Prescaler | is the value to set. Valid values are from 0 to 255. |
int XCanPs_SetBitTiming | ( | XCanPs * | 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 can be set only if the CAN device is in Configuration Mode. Call XCanPs_EnterMode() to enter Configuration Mode before using this function.
InstancePtr | is a pointer to the XCanPs instance. | |
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. |
int XCanPs_SetHandler | ( | XCanPs * | InstancePtr, | |
u32 | HandlerType, | |||
void * | CallBackFunc, | |||
void * | CallBackRef | |||
) |
This routine installs an asynchronous callback function for the given HandlerType:
HandlerType Callback Function Type ----------------------- ------------------------ XCANPS_HANDLER_SEND XCanPs_SendRecvHandler XCANPS_HANDLER_RECV XCanPs_SendRecvHandler XCANPS_HANDLER_ERROR XCanPs_ErrorHandler XCANPS_HANDLER_EVENT XCanPs_EventHandler
HandlerType Invoked by this driver when: ------------------------------------------------------------------------- XCANPS_HANDLER_SEND A frame transmitted by a call to XCanPs_Send() has been sent successfully.
XCANPS_HANDLER_RECV A frame(s) has been received and is sitting in the RX FIFO.
XCANPS_HANDLER_ERROR An error interrupt is occurring.
XCANPS_HANDLER_EVENT Any other kind of interrupt is occurring.
InstancePtr | is a pointer to the XCanPs instance. | |
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. |
int XCanPs_SetRxIntrWatermark | ( | XCanPs * | InstancePtr, | |
u8 | Threshold | |||
) |
This routine sets the Rx Full threshold in the Watermark Interrupt Register.
InstancePtr | is a pointer to the XCanPs instance. | |
Threshold | is the threshold to be set. The valid values are from 1 to 63. |
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.