canfd
Vitis Drivers API Documentation
|
Contains an example of how to use the XCan driver directly.
The example here shows using the driver/device in polled mode.
The Baud Rate Prescaler Register (BRPR) and Bit Timing Register (BTR) are setup such that CAN baud rate equals 40Kbps, assuming that the the CAN clock frequency is 24MHz. The user needs to modify these values based on the desired baud rate and the CAN clock frequency. For more information see the CAN 2.0A, CAN 2.0B, ISO 11898-1 specifications.
MODIFICATION HISTORY:
Ver Who Date Changes
1.0 nsk 06/04/15 First release 1.2 ms 01/23/17 Modified xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. ms 04/05/17 Added tabspace for return statements in functions for proper documentation while generating doxygen. 1.3 ask 08/08/18 Changed the Can ID to 11 bit value as standard Can ID is 11 bit. 2.8 ht 06/19/23 Added support for system device-tree flow. 2.8 gm 06/22/23 Call XCanFd_stop to release canfd node.
Functions | |
int | XCanFdPolledExample (u16 DeviceId) |
The entry point for showing the XCan driver in polled mode. More... | |
int | main (void) |
Main function to call the example. More... | |
int main | ( | void | ) |
Main function to call the example.
This function is not included if the example is generated from the TestAppGen test tool.
References XCanFdPolledExample().
int XCanFdPolledExample | ( | u16 | DeviceId | ) |
The entry point for showing the XCan driver in polled mode.
The example configures the device for internal loopback mode, then sends a Can frame, receives the same Can frame, and verifies the frame contents.
DeviceId | is the XPAR_CAN_<instance_num>_DEVICE_ID value from xparameters.h. |
XST_SUCCESS if successful, otherwise driver-specific error code.
If the device is not working correctly, this function may enter an infinite loop and will never return to the caller.
References XCanFd_Config::BaseAddress, TEST_BRPR_BAUD_PRESCALAR, TEST_BTR_FIRST_TIMESEGMENT, TEST_BTR_SECOND_TIMESEGMENT, TEST_BTR_SYNCJUMPWIDTH, TEST_FBRPR_BAUD_PRESCALAR, TEST_FBTR_FIRST_TIMESEGMENT, TEST_FBTR_SECOND_TIMESEGMENT, TEST_FBTR_SYNCJUMPWIDTH, TEST_MESSAGE_ID, XCanFd_AcceptFilterDisable(), XCanFd_AcceptFilterEnable(), XCANFD_AFR_UAF_ALL_MASK, XCanFd_CfgInitialize(), XCanFd_CreateIdValue, XCanFd_EnterMode(), XCANFD_GET_RX_MODE, XCanFd_Get_RxBuffers, XCanFd_GetMode(), XCanFd_LookupConfig(), XCANFD_MODE_CONFIG, XCANFD_MODE_LOOPBACK, XCanFd_RxBuff_MailBox_Active(), XCanFd_RxBuff_MailBox_DeActive(), XCanFd_SelfTest(), XCanFd_Set_MailBox_IdMask(), XCanFd_SetBaudRatePrescaler(), XCanFd_SetBitRateSwitch_DisableNominal(), XCanFd_SetBitTiming(), XCanFd_SetFBaudRatePrescaler(), XCanFd_SetFBitTiming(), and XCanFd_stop().
Referenced by main().