canps
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
xcanps_intr_example.c File Reference

Overview

Contains an example of how to use the XCanPs driver directly.

This example shows the usage of the driver/device in interrupt mode.

Note
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 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.00a xd/sv 01/12/10 First release 2.1 adk 23/08/14 Fixed CR:798792 Peripheral test for CANPS IP in SDK claims a 40kbps baud rate but it's not. 3.1 mus 01/14/16 Added support for intc interrupt controller 3.7 ht 06/28/23 Added support for system device-tree flow. 07/10/23 Updated conditional macros for interrupt headers. 3.8 rma 01/12/23 Update example code to fix compilation warnings. 3.10 ht 12/13/24 Fix C++ compilation errors and warnings in SDT flow. 3.12 vlt 12/17/25 Update Doxygen comments to include SDT flow details.

#include "xparameters.h"
#include "xcanps.h"
#include "xil_exception.h"
#include "xil_printf.h"
#include "xinterrupt_wrap.h"

Functions

int CanPsIntrExample (XCanPs *CanInstPtr, UINTPTR BaseAddress)
 The main entry point for showing the XCanPs driver in interrupt mode. More...
 
int main (void)
 This function is the main function of the Can interrupt example. More...
 

Function Documentation

int CanPsIntrExample ( XCanPs CanInstPtr,
UINTPTR  BaseAddress 
)

The main entry point for showing the XCanPs driver in interrupt mode.

The example configures the device for internal loop back mode, then sends a CAN frame and receives the same CAN frame.

Parameters
CanInstPtris a pointer to the instance of the CAN driver which is going to be connected to the interrupt controller.
BaseAddresscontains the base address of the device
Returns
XST_SUCCESS if successful, otherwise driver-specific error code.
Note
- In XSCT/classic flow, DeviceId is used to look up the device configuration.
  • If the device is not working correctly, this function may enter an infinite loop and will never return to the caller.

References XCanPs_Config::BaseAddr, XCanPs_Config::IntrId, XCanPs_Config::IntrParent, XCanPs_CfgInitialize(), XCanPs_EnterMode(), XCanPs_GetMode(), XCANPS_HANDLER_ERROR, XCANPS_HANDLER_EVENT, XCANPS_HANDLER_RECV, XCANPS_HANDLER_SEND, XCanPs_IntrEnable(), XCanPs_IntrHandler(), XCANPS_IXR_ALL, XCanPs_LookupConfig(), XCANPS_MODE_LOOPBACK, XCanPs_SelfTest(), and XCanPs_SetHandler().

Referenced by main().

int main ( void  )

This function is the main function of the Can interrupt example.

Returns
  • XST_SUCCESS if the example has completed successfully.
  • XST_FAILURE if the example has failed.
Note
None.

References CanPsIntrExample().