| canps Vitis Drivers API Documentation

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

Functions
xcanps_watermark_intr_example.c File Reference

## Overview

This example shows how to use the CAN driver/device in interrupt mode using the Rx Watermark Interrupt.

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 bau 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
    3.1   adk    10/11/15 Fixed CR#911958 Add support for Tx Watermark testing.
    3.7   ht     06/28/23 Added support for system device-tree flow.
                 07/10/23 Updated conditional macros for interrupt headers.
    3.10  ht     12/13/24 Fix C++ compilation errors and warnings in SDT flow.

## Functions
int | CanPsWatermarkIntrExample (XScuGic *IntcInstPtr, XCanPs *CanInstPtr, u16 CanDeviceId, u16 CanIntrId)
| The main entry point for showing the usage of XCanPs driver in interrupt mode. More...
int | main (void)
| This function is the main function of the Can Rx Watermark interrupt example. More...

## Function Documentation

int CanPsWatermarkIntrExample | ( | XScuGic * | IntcInstPtr,
|  | XCanPs * | CanInstPtr,
|  | u16 | CanDeviceId,
|  | u16 | CanIntrId
| ) |  |

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

The example configures the device for internal loop back mode, then sends multiple CAN frames and receives the same number of CAN frame's using the Rx Watermark Interrupt.

Parameters

  IntcInstPtr | is a pointer to the instance of the ScuGic driver.
  CanInstPtr | is a pointer to the instance of the CAN driver which is going to be connected to the interrupt controller.
  CanDeviceId | is the device Id of the CAN device and is typically XPAR_<CANPS_instance>_DEVICE_ID value from xparameters.h.
  CanIntrId | is the interrupt Id and is typically XPAR_<CANPS_instance>_INTR value from xparameters.h.

Returns
  XST_SUCCESS if successful, otherwise driver-specific error code.

Note
  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_CfgInitialize(), XCanPs_EnterMode(), XCanPs_GetMode(), XCANPS_HANDLER_ERROR, XCANPS_HANDLER_EVENT, XCANPS_HANDLER_RECV, XCANPS_HANDLER_SEND, XCanPs_IntrDisable(), XCanPs_IntrEnable(), XCanPs_IntrHandler(), XCANPS_IXR_ALL, XCANPS_IXR_RXNEMP_MASK, XCANPS_IXR_RXOK_MASK, XCANPS_IXR_TXFWMEMP_MASK, XCANPS_IXR_TXOK_MASK, 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 Rx Watermark interrupt example.

Returns
  - XST_SUCCESS if the example has completed successfully.
  - XST_FAILURE if the example has failed.

Note
  None

References CanPsWatermarkIntrExample().