spi
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
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. 4.16 vlt 12/18/25 Update Doxygen comments to include SDT flow details. *

#include "xparameters.h"
#include "xspi.h"
#include "xspi_l.h"
#include "xil_printf.h"

Functions

int SpiPolledExample (XSpi *SpiInstancePtr, UINTPTR BaseAddress)
 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,
UINTPTR  BaseAddress 
)

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
SpiInstancePtris a pointer to the instance of Spi component.
BaseAddresscontains the base address of the device
Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
Note
- In XSCT/classic flow, DeviceId is used to look up the device configuration.
  • 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().