spips
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
Xspips_flash_polled_example

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 AAI_WRITE_CMD   0xAD
 Auto address increment write. 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 as 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   0x05
 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

int SpiPsFlashPolledExample (XSpiPs *SpiInstancePtr, UINTPTR BaseAddress)
 Illustrates how to use the XSpiPs device driver in polled mode. More...
 
int main (void)
 Calls the SPI Flash polled example. More...
 

Variables

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

Macro Definition Documentation

#define AAI_WRITE_CMD   0xAD

Auto address increment write.

#define ADDRESS_1_OFFSET   1

MSB byte of address to read or write.

#define ADDRESS_2_OFFSET   2

Middle byte of address to read or write.

#define ADDRESS_3_OFFSET   3

LSB byte of address to read or write.

#define BLOCK_ERASE_64K_CMD   0xD8

64 KB block erase command.

#define BULK_ERASE_CMD   0xC7

Bulk erase command.

#define CHIP_ERASE_CMD   0x60

Chip erase command.

#define COMMAND_OFFSET   0

Flash instruction.

#define DATA_OFFSET   4

Start of Data for Read/Write.

Referenced by SpiPsFlashPolledExample().

#define DUMMY_SIZE   1

Number of dummy bytes for fast read.

#define FAST_READ_CMD   0x0B

Fast read command.

#define FLASH_SPI_SELECT_0   0x00

Flash on chip select 0.

Referenced by SpiPsFlashPolledExample().

#define FLASH_SPI_SELECT_1   0x01

Flash on chip select 1.

Referenced by SpiPsFlashPolledExample().

#define GLOBAL_BLK_PROT_UNLK   0x98

Global Block-Protection Unlock register command.

#define MAX_DATA   1024*1024

Max data size.

Referenced by SpiPsFlashPolledExample().

#define OVERHEAD_SIZE   4

Command and address bytes.

#define RD_ID_SIZE   4

Read ID command + 3 bytes ID response.

#define READ_CMD   0x03

Read data command.

Referenced by SpiPsFlashPolledExample().

#define READ_ID   0x90

Read ID command.

#define READ_STATUS_CMD   0x05

Read status register command.

#define SST_FLASH_ID   0xBF

All SST flash parts have id as 0xBF.

#define SST_READ_ID   0x9F

SST flash read ID command.

#define UNIQUE_VALUE   0x05

Unique test data value.

Referenced by SpiPsFlashPolledExample().

#define WRITE_CMD   0x02

Page program command.

Referenced by SpiPsFlashPolledExample().

#define WRITE_DISABLE_CMD   0x04

Write disable command.

#define WRITE_ENABLE_CMD   0x06

Write enable command.

#define WRITE_STATUS_CMD   0x01

Write status register command.

Function Documentation

int main ( void  )

Calls the SPI Flash polled example.

Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if not successful

References SpiPsFlashPolledExample().

int SpiPsFlashPolledExample ( XSpiPs *  SpiInstancePtr,
UINTPTR  BaseAddress 
)

Illustrates how to use the XSpiPs device driver in polled mode.

The function writes and reads data from a serial flash.

Parameters
[in]SpiInstancePtrPointer to the SPI driver instance to use.
[in]BaseAddressThe base address of the device.
Returns
  • XST_SUCCESS if successful
  • XST_FAILURE if not successful
Note
- If the device slave select is not correct and the device is not responding on bus it reads a status of 0xFF for the status register as the bus is pulled up.
  • In XSCT/classic flow, the device configuration is looked up based on DeviceId.

References XSpiPs_Config::BaseAddress, DATA_OFFSET, FLASH_SPI_SELECT_0, FLASH_SPI_SELECT_1, MAX_DATA, READ_CMD, ReadBuffer, UNIQUE_VALUE, WRITE_CMD, WriteBuffer, XSpiPs_CfgInitialize(), XSPIPS_CLK_PRESCALE_8, XSPIPS_FORCE_SSELECT_OPTION, XSpiPs_LookupConfig(), XSPIPS_MANUAL_START_OPTION, XSPIPS_MASTER_OPTION, XSpiPs_SelfTest(), XSpiPs_SetClkPrescaler(), XSpiPs_SetOptions(), and XSpiPs_SetSlaveSelect().

Referenced by main().

Variable Documentation

Buffer for the data read from the flash.

u8 WriteBuffer[MAX_DATA+DATA_OFFSET]

Data to write to the flash.