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

Overview

Implements a design example using the SPI driver (XSpiPs) in interrupt mode with a serial flash device.

The example performs transfers in Manual start mode using interrupts. The hardware which this example runs on, must have a serial flash for it to run. The example has been tested with SST25W080.

MODIFICATION HISTORY:
Ver   Who Date     Changes


1.00 sg 1/30/13 First release ms 04/05/17 Modified Comment lines in functions to recognize it as documentation block for doxygen generation. 3.2 nsk 03/26/19 Add support for versal 3.9 sb 07/05/23 Added support for system device-tree flow. 3.13 sb 09/09/25 Fix flash status register check in erase function 3.14 vlt 12/18/25 Update Doxygen comments to include SDT flow details. 3.15 vn 08/26/26 Fix Doxygen warnings. 3.15 tb 09/30/26 Align Doxygen comments with AMD documentation standards

#include "xparameters.h"
#include "xplatform_info.h"
#include "xspips.h"
#include "xscugic.h"
#include "xil_exception.h"
#include "xil_printf.h"
#include "xinterrupt_wrap.h"

Macros

#define WRITE_STATUS_CMD   0x01
 Write status register command. More...
 
#define WRITE_CMD   0x02
 Page program command. More...
 
#define READ_CMD   0x03
 Read data command. More...
 
#define WRITE_DISABLE_CMD   0x04
 Write disable command. More...
 
#define READ_STATUS_CMD   0x05
 Read status register command. More...
 
#define WRITE_ENABLE_CMD   0x06
 Write enable command. More...
 
#define FAST_READ_CMD   0x0B
 Fast read command. More...
 
#define CHIP_ERASE_CMD   0x60
 Chip erase command. More...
 
#define BULK_ERASE_CMD   0xC7
 Bulk erase command. More...
 
#define BLOCK_ERASE_64K_CMD   0xD8
 64 KB block erase command. More...
 
#define READ_ID   0x90
 Read ID command. More...
 
#define SST_READ_ID   0x9F
 SST flash read ID command. More...
 
#define GLOBAL_BLK_PROT_UNLK   0x98
 Global Block-Protection Unlock register command. More...
 
#define SST_FLASH_ID   0xBF
 All SST flash parts have ID 0xBF. More...
 
#define COMMAND_OFFSET   0
 Flash instruction. More...
 
#define ADDRESS_1_OFFSET   1
 MSB byte of address to read or write. More...
 
#define ADDRESS_2_OFFSET   2
 Middle byte of address to read or write. More...
 
#define ADDRESS_3_OFFSET   3
 LSB byte of address to read or write. More...
 
#define DATA_OFFSET   4
 Start of Data for Read/Write. More...
 
#define DUMMY_SIZE   1
 Number of dummy bytes for fast read. More...
 
#define RD_ID_SIZE   4
 Read ID command + 3 bytes ID response. More...
 
#define OVERHEAD_SIZE   4
 Command and address bytes. More...
 
#define UNIQUE_VALUE   0x55
 Unique test data value. More...
 
#define MAX_DATA   1024*1024
 Max data size. More...
 
#define FLASH_SPI_SELECT_1   0x01
 Flash on chip select 1. More...
 
#define FLASH_SPI_SELECT_0   0x00
 Flash on chip select 0. More...
 

Functions

void SpiPsHandler (void *CallBackRef, u32 StatusEvent, unsigned int ByteCount)
 Handles the status events of the SPI driver. More...
 
int SpiPsFlashIntrExample (XSpiPs *SpiInstancePtr, UINTPTR BaseAddress)
 Illustrates how to use the XSpiPs device driver in interrupt mode. More...
 
int main (void)
 Calls the SPI Flash interrupt example. More...
 

Variables

volatile int TransferInProgress
 Indicates that an SPI transfer is in progress. More...
 
int Error
 Tracks any errors that occur during interrupt processing. More...
 
u8 ReadBuffer [MAX_DATA+DATA_OFFSET+DUMMY_SIZE]
 Buffer for the data read from the flash. More...
 
u8 WriteBuffer [MAX_DATA+DATA_OFFSET]
 Data to write to the flash. More...