spi
Vitis Drivers API Documentation
xspi_low_level_example.c File Reference

Overview

This file contains a design example using the low-level driver of the SPI driver (XSpi).

These macros are found in xspi_l.h. A simple loopback test is done within an SPI device in polled mode. This example works only with 8-bit wide data transfers.

Note
This example works only with 8-bit wide data transfers in standard SPI mode. This example will not work if the axi_qspi device is confiured in dual/quad modes.

To make this example work for 16 bit transfers change u8 Buffer[BUFFER_SIZE] to u16 Buffer[BUFFER_SIZE]. The SPI Core should also be configured for 16 bit access during the build time.

To make this example work for 32 bit transfers change u8 Buffer[BUFFER_SIZE] to u32 Buffer[BUFFER_SIZE]. The SPI Core should also be configured for 32 bit access during the build time.

  MODIFICATION HISTORY:
  Ver   Who  Date     Changes


1.00b rpm 04/24/02 First release 1.00b jhl 09/10/02 Added code to ensure it works with a fast processor. 1.00b sv 05/16/05 Minor changes to comply to Doxygen and coding guidelines 3.00a ktn 10/28/09 Converted all register accesses to 32 bit access. 3.02a sdm 05/04/11 Added a note about dual/quad modes in axi_qspi. 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 XSpi_LowLevelExample (u32 BaseAddress)
 This function does a simple loopback test within an SPI device. More...
 
int main (void)
 This function is the main function of the SPI Low Level example. More...
 

Function Documentation

int main ( void  )

This function is the main function of the SPI Low Level example.

Returns
XST_SUCCESS to indicate success, else XST_FAILURE to indicate Failure.
Note
None

References XSpi_LowLevelExample().

int XSpi_LowLevelExample ( u32  BaseAddress)

This function does a simple loopback test within an SPI device.

Parameters
BaseAddressis the BaseAddress of the SPI device
Returns
XST_SUCCESS if successful, XST_FAILURE if unsuccessful
Note
None

References XSP_CR_ENABLE_MASK, XSP_CR_LOOPBACK_MASK, XSP_CR_MASTER_MODE_MASK, XSP_CR_OFFSET, XSP_CR_TRANS_INHIBIT_MASK, XSP_DRR_OFFSET, XSP_DTR_OFFSET, XSP_SR_OFFSET, XSP_SR_RX_EMPTY_MASK, XSP_SR_TX_EMPTY_MASK, XSP_SR_TX_FULL_MASK, XSpi_ReadReg, and XSpi_WriteReg.

Referenced by main().