| spi Vitis Drivers API Documentation

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

Functions
xspi_intr_example.c File Reference

## Overview

This file contains a design example using the Spi driver (XSpi) and the Spi device using the interrupt mode.

This example works with a PPC/MicroBlaze processor.

Note

None.

      MODIFICATION HISTORY:

      Ver   Who  Date     Changes

      1.01a sv   05/29/06 First release for Test App Integration
                          for Interrupt examples
      1.11a sdm  03/03/08 Minor changes to comply to Doxygen and coding guidelines
      3.00a ktn  10/22/09 Converted all register accesses to 32 bit access.
                          Updated to use the HAL APIs/macros. Replaced call to
                          XSpi_Initialize API with XSpi_LookupConfig and
                          XSpi_CfgInitialize.
      3.02a sdm  05/04/11 Updated to run the loopback test only in standard spi
                          mode.
      4.2   ms   01/23/17 Added 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.
      4.5   akm  07/12/19 Fixed compilation error by passing the correct interrupt
                          controller instance to SpiIntrExample() function.
      4.11  sb   07/11/23 Added support for system device-tree flow.
    *

## Functions
int | SpiIntrExample (INTC *IntcInstancePtr, XSpi *SpiInstancePtr, u16 SpiDeviceId, u16 SpiIntrId)
| This function does a minimal test on the Spi device and driver as a design example. More...
void | SpiIntrHandler (void *CallBackRef, u32 StatusEvent, u32 ByteCount)
| This function is the handler which performs processing for the SPI driver. More...
int | main (void)
| Main function to call the Spi interrupt example. More...

## Function Documentation

int main | ( | void |  | ) |

Main function to call the Spi interrupt example.

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note
  None

References SpiIntrExample().

int SpiIntrExample | ( | INTC * | IntcInstancePtr,
|  | XSpi * | SpiInstancePtr,
|  | u16 | SpiDeviceId,
|  | u16 | SpiIntrId
| ) |  |

This function does a minimal test on the Spi device and driver as a design example.

The purpose of this function is to illustrate how to use the XSpi component using the interrupt mode.

This function sends data and expects to receive the same data.

Parameters

  IntcInstancePtr | is a pointer to the instance of the INTC component.
  SpiInstancePtr | is a pointer to the instance of Spi component.
  SpiDeviceId | is the Device ID of the Spi Device and is the XPAR_<SPI_instance>_DEVICE_ID value from xparameters.h.
  SpiIntrId | is the interrupt Id and is typically XPAR_<INTC_instance>_<SPI_instance>_VEC_ID value from xparameters.h .

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note

This function contains an infinite loop such that if interrupts are not working it may never return.

References XSpi_Config::BaseAddress, SpiIntrHandler(), XSpi::SpiMode, XSP_MASTER_OPTION, XSpi_CfgInitialize(), XSpi_InterruptHandler(), XSpi_LookupConfig(), XSpi_SelfTest(), XSpi_SetOptions(), XSpi_SetStatusHandler(), XSpi_Start(), and XSpi_Transfer().

Referenced by main().

void SpiIntrHandler | ( | void * | CallBackRef,
|  | u32 | StatusEvent,
|  | u32 | ByteCount
| ) |  |

This function is the handler which performs processing for the SPI driver.

It is called from an interrupt context such that the amount of processing performed should be minimized. It is called when a transfer of SPI data completes or an error occurs.

This handler provides an example of how to handle SPI interrupts and is application specific.

Parameters

  CallBackRef | is the upper layer callback reference passed back when the callback function is invoked.
  StatusEvent | is the event that just occurred.
  ByteCount | is the number of bytes transferred up until the event occurred.

Returns
  None.

Note
  None.

Referenced by SpiIntrExample().