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

Overview

This file contains a design example using the SPI controller in slave mode.

This examples performs transfers in polled mode and has been tested with Aardvark Analyzer as Master. This example echoes data which it receives from the master. The slave controller expects MAX_DATA bytes of data from the master to transmit onto the SPI bus which the slave will receive into its Rx buffer. It will poll until the Rx FIFO is filled with the Threshold limit of data which is set to MAX_DATA. On sending data, the master will receive dummy bytes in response. Master has to send MAX_DATA dummy bytes to read back the echoed data.

Note

The slave mode test needs an external master to send data to the Spi device. This example has been tested with Aardvark Analyzer as Master. The Clock Polarity and Phase should match between master and the slave.

MODIFICATION HISTORY:
Ver   Who Date     Changes


2.0 sb 08/22/14 First release ms 04/05/17 Modified Comment lines in functions to recognize it as documentation block for doxygen generation. 3.9 sb 07/05/23 Added support for system device-tree flow. 3.13 sb 09/09/25 Fix GCC warnings. 3.14 vlt 12/18/25 Update Doxygen comments to include SDT flow details.

#include "xparameters.h"
#include "xspips.h"
#include "xil_printf.h"

Functions

int SpiPsSlavePolledExample (UINTPTR BaseAddress)
 The purpose of this function is to illustrate how to use the XSpiPs device driver in Slave mode. More...
 
int main (void)
 Main function to call the SPI Slave Example. More...
 

Function Documentation

int main ( void  )

Main function to call the SPI Slave Example.

Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if not successful
Note
None

References SpiPsSlavePolledExample().

int SpiPsSlavePolledExample ( UINTPTR  BaseAddress)

The purpose of this function is to illustrate how to use the XSpiPs device driver in Slave mode.

This function reads data from a SPI Master and will echo it back to the Master.

Parameters
BaseAddresscontains the base address of the device
Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if not successful
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XSpiPs_Config::BaseAddress, XSpiPs_CfgInitialize(), XSpiPs_LookupConfig(), and XSpiPs_PolledTransfer().

Referenced by main().