| spi Vitis Drivers API Documentation

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

Functions
xspi_polled_example.c File Reference

## Overview

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

To put the driver in polled mode the Global Interrupt must be disabled after the Spi is Initialized and Spi driver is started.

This example works with a PPC/MicroBlaze processor.

Note

None.

      MODIFICATION HISTORY:

      Ver   Who  Date     Changes

      1.00a sdm  03/03/08 First Release
      3.00a ktn  10/28/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.11  sb   07/11/23 Added support for system device-tree flow.
    *

## Functions
int | SpiPolledExample (XSpi *SpiInstancePtr, u16 SpiDeviceId)
| This function does a minimal test on the Spi device and driver as a design example. More...
int | main (void)
| Main function to call the Spi Polled example. More...

## Function Documentation

int main | ( | void |  | ) |

Main function to call the Spi Polled example.

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note
  None

References SpiPolledExample().

int SpiPolledExample | ( | XSpi * | SpiInstancePtr,
|  | u16 | SpiDeviceId
| ) |  |

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 polled mode.

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

Parameters

  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.

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note

This function contains an infinite loop such that if the Spi device is not working it may never return.

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

Referenced by main().