qspips
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
Qspips_g128_flash_example

Macros

#define WRITE_STATUS_CMD   0x01
 Write status register command. More...
 
#define WRITE_CMD   0x02
 Page program command. More...
 
#define READ_CMD   0x03
 Normal read 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 DUAL_READ_CMD   0x3B
 Dual read command. More...
 
#define QUAD_READ_CMD   0x6B
 Quad read command. More...
 
#define BULK_ERASE_CMD   0xC7
 Bulk erase command. More...
 
#define SEC_ERASE_CMD   0xD8
 Sector erase command. More...
 
#define READ_ID   0x9F
 Read ID command. More...
 
#define READ_CONFIG_CMD   0x35
 Read config register command. More...
 
#define WRITE_CONFIG_CMD   0x01
 Write config register command. More...
 
#define BANK_REG_RD   0x16
 Bank register read. More...
 
#define BANK_REG_WR   0x17
 Bank register write. More...
 
#define EXTADD_REG_RD   0xC8
 Extended Address Register read; Micron name for the Bank register. More...
 
#define EXTADD_REG_WR   0xC5
 Extended address register write. More...
 
#define DIE_ERASE_CMD   0xC4
 Die erase command. More...
 
#define READ_FLAG_STATUS_CMD   0x70
 Read flag status command. 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_OFFSET   4
 Dummy byte offset for fast, dual and quad reads. More...
 
#define DUMMY_SIZE   1
 Number of dummy bytes for fast, dual and quad reads. More...
 
#define RD_ID_SIZE   4
 Read ID command + 3 bytes ID response. More...
 
#define BULK_ERASE_SIZE   1
 Bulk Erase command size. More...
 
#define SEC_ERASE_SIZE   4
 Sector Erase command + Sector address. More...
 
#define BANK_SEL_SIZE   2
 BRWR or EARWR command + 1 byte bank value. More...
 
#define RD_CFG_SIZE   2
 1 byte Configuration register + RD CFG command. More...
 
#define WR_CFG_SIZE   3
 WRR command + 1 byte each Status and Config Reg. More...
 
#define DIE_ERASE_SIZE   4
 Die Erase command + Die address. More...
 
#define OVERHEAD_SIZE   4
 Command and address byte count. More...
 
#define FLASH1BASE   0x0000000
 Base address of Flash1. More...
 
#define SIXTEENMB   0x1000000
 Sixteen MB. More...
 
#define FLASH_QUAD_EN_MASK   0x02
 Mask for quad enable bit in Flash configuration register. More...
 
#define FLASH_SRWD_MASK   0x80
 Status register write disable bit mask. More...
 
#define BANKMASK   0xF000000
 Bank mask. More...
 
#define MICRON_ID_BYTE0   0x20
 Micron manufacturer ID. More...
 
#define MICRON_ID_BYTE2_128   0x18
 Micron 128Mbit size ID. More...
 
#define MICRON_ID_BYTE2_256   0x19
 Micron 256Mbit size ID. More...
 
#define MICRON_ID_BYTE2_512   0x20
 Micron 512Mbit size ID. More...
 
#define MICRON_ID_BYTE2_1G   0x21
 Micron 1Gbit size ID. More...
 
#define SPANSION_ID_BYTE0   0x01
 Spansion manufacturer ID. More...
 
#define SPANSION_ID_BYTE2_128   0x18
 Spansion 128Mbit size ID. More...
 
#define SPANSION_ID_BYTE2_256   0x19
 Spansion 256Mbit size ID. More...
 
#define SPANSION_ID_BYTE2_512   0x20
 Spansion 512Mbit size ID. More...
 
#define WINBOND_ID_BYTE0   0xEF
 Winbond manufacturer ID. More...
 
#define WINBOND_ID_BYTE2_128   0x18
 Winbond 128Mbit size ID. More...
 
#define MACRONIX_ID_BYTE0   0xC2
 Macronix manufacturer ID. More...
 
#define MACRONIX_ID_BYTE2_256   0x19
 Macronix 256Mbit size ID. More...
 
#define MACRONIX_ID_BYTE2_512   0x1A
 Macronix 512Mbit size ID. More...
 
#define MACRONIX_ID_BYTE2_1G   0x1B
 Macronix 1Gbit size ID. More...
 
#define ISSI_ID_BYTE0   0x9D
 ISSI manufacturer ID. More...
 
#define ISSI_ID_BYTE2_256   0x19
 ISSI 256Mbit size ID. More...
 
#define SPANSION_INDEX_START   0
 Spansion start index. More...
 
#define FLASH_CFG_TBL_SINGLE_128_SP   SPANSION_INDEX_START
 Spansion 128Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_128_SP   (SPANSION_INDEX_START + 1)
 Spansion 128Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_128_SP   (SPANSION_INDEX_START + 2)
 Spansion 128Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_256_SP   (SPANSION_INDEX_START + 3)
 Spansion 256Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_256_SP   (SPANSION_INDEX_START + 4)
 Spansion 256Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_256_SP   (SPANSION_INDEX_START + 5)
 Spansion 256Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_512_SP   (SPANSION_INDEX_START + 6)
 Spansion 512Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_512_SP   (SPANSION_INDEX_START + 7)
 Spansion 512Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_512_SP   (SPANSION_INDEX_START + 8)
 Spansion 512Mbit parallel mode config table index. More...
 
#define MICRON_INDEX_START   (FLASH_CFG_TBL_PARALLEL_512_SP + 1)
 Micron start index. More...
 
#define FLASH_CFG_TBL_SINGLE_128_MC   MICRON_INDEX_START
 Micron 128Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_128_MC   (MICRON_INDEX_START + 1)
 Micron 128Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_128_MC   (MICRON_INDEX_START + 2)
 Micron 128Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_256_MC   (MICRON_INDEX_START + 3)
 Micron 256Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_256_MC   (MICRON_INDEX_START + 4)
 Micron 256Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_256_MC   (MICRON_INDEX_START + 5)
 Micron 256Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_512_MC   (MICRON_INDEX_START + 6)
 Micron 512Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_512_MC   (MICRON_INDEX_START + 7)
 Micron 512Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_512_MC   (MICRON_INDEX_START + 8)
 Micron 512Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_1GB_MC   (MICRON_INDEX_START + 9)
 Micron 1Gbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_1GB_MC   (MICRON_INDEX_START + 10)
 Micron 1Gbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_1GB_MC   (MICRON_INDEX_START + 11)
 Micron 1Gbit parallel mode config table index. More...
 
#define WINBOND_INDEX_START   (FLASH_CFG_TBL_PARALLEL_1GB_MC + 1)
 Winbond start index. More...
 
#define FLASH_CFG_TBL_SINGLE_128_WB   WINBOND_INDEX_START
 Winbond 128Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_128_WB   (WINBOND_INDEX_START + 1)
 Winbond 128Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_128_WB   (WINBOND_INDEX_START + 2)
 Winbond 128Mbit parallel mode config table index. More...
 
#define MACRONIX_INDEX_START   (FLASH_CFG_TBL_PARALLEL_128_WB + 1 - 3)
 Macronix start index. More...
 
#define FLASH_CFG_TBL_SINGLE_256_MX   MACRONIX_INDEX_START
 Macronix 256Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_256_MX   (MACRONIX_INDEX_START + 1)
 Macronix 256Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_256_MX   (MACRONIX_INDEX_START + 2)
 Macronix 256Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_512_MX   (MACRONIX_INDEX_START + 3)
 Macronix 512Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_512_MX   (MACRONIX_INDEX_START + 4)
 Macronix 512Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_512_MX   (MACRONIX_INDEX_START + 5)
 Macronix 512Mbit parallel mode config table index. More...
 
#define FLASH_CFG_TBL_SINGLE_1G_MX   (MACRONIX_INDEX_START + 6)
 Macronix 1Gbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_1G_MX   (MACRONIX_INDEX_START + 7)
 Macronix 1Gbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_1G_MX   (MACRONIX_INDEX_START + 8)
 Macronix 1Gbit parallel mode config table index. More...
 
#define ISSI_INDEX_START   (FLASH_CFG_TBL_PARALLEL_1G_MX + 1)
 ISSI start index. More...
 
#define FLASH_CFG_TBL_SINGLE_256_ISSI   ISSI_INDEX_START
 ISSI 256Mbit single mode config table index. More...
 
#define FLASH_CFG_TBL_STACKED_256_ISSI   (ISSI_INDEX_START + 1)
 ISSI 256Mbit stacked mode config table index. More...
 
#define FLASH_CFG_TBL_PARALLEL_256_ISSI   (ISSI_INDEX_START + 2)
 ISSI 256Mbit parallel mode config table index. More...
 
#define LQSPI_CR_FAST_QUAD_READ   0x0000006B
 Fast Quad Read output. More...
 
#define LQSPI_CR_1_DUMMY_BYTE   0x00000100
 1 Dummy Byte between address and return data. More...
 
#define DUAL_STACK_CONFIG_WRITE
 LQSPI configuration register value for dual stacked flash mode. More...
 
#define DUAL_QSPI_CONFIG_WRITE
 LQSPI configuration register value for dual parallel flash mode. More...
 
#define PAGE_COUNT   32
 Number of flash pages to be written. More...
 
#define MAX_PAGE_SIZE   1024
 Max page size to initialize write and read buffer. More...
 
#define TEST_ADDRESS   0x000000
 Flash address to which data is to be written. More...
 
#define UNIQUE_VALUE   0x06
 Start value of the data pattern. More...
 

Functions

int QspiG128FlashExample (XQspiPs *QspiInstancePtr, UINTPTR BaseAddress)
 Illustrates how to use the XQspiPs device driver in single, parallel and stacked modes using flash devices greater than 128Mb. More...
 
void FlashErase (XQspiPs *QspiPtr, u32 Address, u32 ByteCount, u8 *WriteBfrPtr)
 Erases the sectors in the serial Flash connected to the QSPI interface. More...
 
void FlashWrite (XQspiPs *QspiPtr, u32 Address, u32 ByteCount, u8 Command, u8 *WriteBfrPtr)
 Writes to the serial Flash connected to the QSPI interface. More...
 
int FlashReadID (XQspiPs *QspiPtr, u8 *WriteBfrPtr, u8 *ReadBfrPtr)
 Reads serial Flash ID connected to the SPI interface. More...
 
void FlashRead (XQspiPs *QspiPtr, u32 Address, u32 ByteCount, u8 Command, u8 *WriteBfrPtr, u8 *ReadBfrPtr)
 Performs an I/O read. More...
 
int SendBankSelect (XQspiPs *QspiPtr, u8 *WriteBfrPtr, u32 BankSel)
 Selects the current bank. More...
 
void BulkErase (XQspiPs *QspiPtr, u8 *WriteBfrPtr)
 Performs a bulk erase operation when the flash device has a single die. More...
 
void DieErase (XQspiPs *QspiPtr, u8 *WriteBfrPtr)
 Performs a die erase operation on all the die in the flash device. More...
 
u32 GetRealAddr (XQspiPs *QspiPtr, u32 Address)
 Translates the address based on the type of interconnection. More...
 
int main (void)
 Runs the QSPI greater than 128Mb flash example. More...
 

Variables

FlashInfo Flash_Config_Table [34]
 Flash Config Table. More...
 
u32 FlashMake
 Flash manufacturer ID. More...
 
u32 FCTIndex
 Flash configuration table index. More...
 
int Test = 1
 The following variable allows a test value to be added to the values that are written to the Flash such that unique values can be generated to guarantee the writes to the Flash were successful. More...
 
u8 ReadBuffer [(PAGE_COUNT *MAX_PAGE_SIZE)+(DATA_OFFSET+DUMMY_SIZE)*8]
 The following variables hold the data read from and written to the flash and they are global to avoid having large buffers on the stack. More...
 
u8 WriteBuffer [(PAGE_COUNT *MAX_PAGE_SIZE)+DATA_OFFSET]
 Write buffer. More...
 
u32 MaxData = PAGE_COUNT*256
 The following constants specify the max amount of data and the size of the the buffer required to hold the data and overhead to transfer the data to and from the Flash. More...
 

Macro Definition Documentation

#define ADDRESS_1_OFFSET   1

MSB byte of address to read or write.

Referenced by FlashRead(), and SendBankSelect().

#define ADDRESS_2_OFFSET   2

Middle byte of address to read or write.

Referenced by FlashRead().

#define ADDRESS_3_OFFSET   3

LSB byte of address to read or write.

Referenced by FlashRead().

#define BANK_REG_RD   0x16

Bank register read.

#define BANK_REG_WR   0x17

Bank register write.

#define BANK_SEL_SIZE   2

BRWR or EARWR command + 1 byte bank value.

Referenced by SendBankSelect().

#define BANKMASK   0xF000000

Bank mask.

Referenced by FlashRead().

#define BULK_ERASE_CMD   0xC7

Bulk erase command.

#define BULK_ERASE_SIZE   1

Bulk Erase command size.

#define COMMAND_OFFSET   0

Flash instruction.

Referenced by FlashRead(), and SendBankSelect().

#define DATA_OFFSET   4

Start of Data for Read/Write.

#define DIE_ERASE_CMD   0xC4

Die erase command.

#define DIE_ERASE_SIZE   4

Die Erase command + Die address.

#define DUAL_QSPI_CONFIG_WRITE
Value:
#define LQSPI_CR_1_DUMMY_BYTE
1 Dummy Byte between address and return data.
Definition: xqspips_g128_flash_example.c:283
#define XQSPIPS_LQSPI_CR_TWO_MEM_MASK
Both memories or one.
Definition: xqspips_hw.h:280
#define LQSPI_CR_FAST_QUAD_READ
Fast Quad Read output.
Definition: xqspips_g128_flash_example.c:282
#define XQSPIPS_LQSPI_CR_SEP_BUS_MASK
Separate memory bus.
Definition: xqspips_hw.h:281

LQSPI configuration register value for dual parallel flash mode.

#define DUAL_READ_CMD   0x3B

Dual read command.

Referenced by FlashRead().

#define DUAL_STACK_CONFIG_WRITE
Value:
#define LQSPI_CR_1_DUMMY_BYTE
1 Dummy Byte between address and return data.
Definition: xqspips_g128_flash_example.c:283
#define XQSPIPS_LQSPI_CR_TWO_MEM_MASK
Both memories or one.
Definition: xqspips_hw.h:280
#define LQSPI_CR_FAST_QUAD_READ
Fast Quad Read output.
Definition: xqspips_g128_flash_example.c:282

LQSPI configuration register value for dual stacked flash mode.

#define DUMMY_OFFSET   4

Dummy byte offset for fast, dual and quad reads.

#define DUMMY_SIZE   1

Number of dummy bytes for fast, dual and quad reads.

Referenced by FlashRead().

#define EXTADD_REG_RD   0xC8

Extended Address Register read; Micron name for the Bank register.

#define EXTADD_REG_WR   0xC5

Extended address register write.

Referenced by SendBankSelect().

#define FAST_READ_CMD   0x0B

Fast read command.

Referenced by FlashRead().

#define FLASH1BASE   0x0000000

Base address of Flash1.

#define FLASH_CFG_TBL_PARALLEL_128_MC   (MICRON_INDEX_START + 2)

Micron 128Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_128_SP   (SPANSION_INDEX_START + 2)

Spansion 128Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_128_WB   (WINBOND_INDEX_START + 2)

Winbond 128Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_1G_MX   (MACRONIX_INDEX_START + 8)

Macronix 1Gbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_1GB_MC   (MICRON_INDEX_START + 11)

Micron 1Gbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_256_ISSI   (ISSI_INDEX_START + 2)

ISSI 256Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_256_MC   (MICRON_INDEX_START + 5)

Micron 256Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_256_MX   (MACRONIX_INDEX_START + 2)

Macronix 256Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_256_SP   (SPANSION_INDEX_START + 5)

Spansion 256Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_512_MC   (MICRON_INDEX_START + 8)

Micron 512Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_512_MX   (MACRONIX_INDEX_START + 5)

Macronix 512Mbit parallel mode config table index.

#define FLASH_CFG_TBL_PARALLEL_512_SP   (SPANSION_INDEX_START + 8)

Spansion 512Mbit parallel mode config table index.

#define FLASH_CFG_TBL_SINGLE_128_MC   MICRON_INDEX_START

Micron 128Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_128_SP   SPANSION_INDEX_START

Spansion 128Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_128_WB   WINBOND_INDEX_START

Winbond 128Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_1G_MX   (MACRONIX_INDEX_START + 6)

Macronix 1Gbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_1GB_MC   (MICRON_INDEX_START + 9)

Micron 1Gbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_256_ISSI   ISSI_INDEX_START

ISSI 256Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_256_MC   (MICRON_INDEX_START + 3)

Micron 256Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_256_MX   MACRONIX_INDEX_START

Macronix 256Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_256_SP   (SPANSION_INDEX_START + 3)

Spansion 256Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_512_MC   (MICRON_INDEX_START + 6)

Micron 512Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_512_MX   (MACRONIX_INDEX_START + 3)

Macronix 512Mbit single mode config table index.

#define FLASH_CFG_TBL_SINGLE_512_SP   (SPANSION_INDEX_START + 6)

Spansion 512Mbit single mode config table index.

#define FLASH_CFG_TBL_STACKED_128_MC   (MICRON_INDEX_START + 1)

Micron 128Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_128_SP   (SPANSION_INDEX_START + 1)

Spansion 128Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_128_WB   (WINBOND_INDEX_START + 1)

Winbond 128Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_1G_MX   (MACRONIX_INDEX_START + 7)

Macronix 1Gbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_1GB_MC   (MICRON_INDEX_START + 10)

Micron 1Gbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_256_ISSI   (ISSI_INDEX_START + 1)

ISSI 256Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_256_MC   (MICRON_INDEX_START + 4)

Micron 256Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_256_MX   (MACRONIX_INDEX_START + 1)

Macronix 256Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_256_SP   (SPANSION_INDEX_START + 4)

Spansion 256Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_512_MC   (MICRON_INDEX_START + 7)

Micron 512Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_512_MX   (MACRONIX_INDEX_START + 4)

Macronix 512Mbit stacked mode config table index.

#define FLASH_CFG_TBL_STACKED_512_SP   (SPANSION_INDEX_START + 7)

Spansion 512Mbit stacked mode config table index.

#define FLASH_QUAD_EN_MASK   0x02

Mask for quad enable bit in Flash configuration register.

#define FLASH_SRWD_MASK   0x80

Status register write disable bit mask.

#define ISSI_ID_BYTE0   0x9D

ISSI manufacturer ID.

#define ISSI_ID_BYTE2_256   0x19

ISSI 256Mbit size ID.

#define ISSI_INDEX_START   (FLASH_CFG_TBL_PARALLEL_1G_MX + 1)

ISSI start index.

#define LQSPI_CR_1_DUMMY_BYTE   0x00000100

1 Dummy Byte between address and return data.

#define LQSPI_CR_FAST_QUAD_READ   0x0000006B

Fast Quad Read output.

#define MACRONIX_ID_BYTE0   0xC2

Macronix manufacturer ID.

#define MACRONIX_ID_BYTE2_1G   0x1B

Macronix 1Gbit size ID.

#define MACRONIX_ID_BYTE2_256   0x19

Macronix 256Mbit size ID.

#define MACRONIX_ID_BYTE2_512   0x1A

Macronix 512Mbit size ID.

#define MACRONIX_INDEX_START   (FLASH_CFG_TBL_PARALLEL_128_WB + 1 - 3)

Macronix start index.

#define MAX_PAGE_SIZE   1024

Max page size to initialize write and read buffer.

#define MICRON_ID_BYTE0   0x20

Micron manufacturer ID.

#define MICRON_ID_BYTE2_128   0x18

Micron 128Mbit size ID.

#define MICRON_ID_BYTE2_1G   0x21

Micron 1Gbit size ID.

#define MICRON_ID_BYTE2_256   0x19

Micron 256Mbit size ID.

#define MICRON_ID_BYTE2_512   0x20

Micron 512Mbit size ID.

#define MICRON_INDEX_START   (FLASH_CFG_TBL_PARALLEL_512_SP + 1)

Micron start index.

#define OVERHEAD_SIZE   4

Command and address byte count.

Referenced by FlashRead().

#define PAGE_COUNT   32

Number of flash pages to be written.

#define QUAD_READ_CMD   0x6B

Quad read command.

Referenced by FlashRead().

#define RD_CFG_SIZE   2

1 byte Configuration register + RD CFG command.

#define RD_ID_SIZE   4

Read ID command + 3 bytes ID response.

#define READ_CMD   0x03

Normal read command.

#define READ_CONFIG_CMD   0x35

Read config register command.

#define READ_FLAG_STATUS_CMD   0x70

Read flag status command.

Referenced by DieErase().

#define READ_ID   0x9F

Read ID command.

#define READ_STATUS_CMD   0x05

Read status register command.

Referenced by BulkErase(), and FlashErase().

#define SEC_ERASE_CMD   0xD8

Sector erase command.

#define SEC_ERASE_SIZE   4

Sector Erase command + Sector address.

#define SIXTEENMB   0x1000000

Sixteen MB.

Referenced by FlashRead().

#define SPANSION_ID_BYTE0   0x01

Spansion manufacturer ID.

#define SPANSION_ID_BYTE2_128   0x18

Spansion 128Mbit size ID.

#define SPANSION_ID_BYTE2_256   0x19

Spansion 256Mbit size ID.

#define SPANSION_ID_BYTE2_512   0x20

Spansion 512Mbit size ID.

#define SPANSION_INDEX_START   0

Spansion start index.

#define TEST_ADDRESS   0x000000

Flash address to which data is to be written.

#define UNIQUE_VALUE   0x06

Start value of the data pattern.

#define WINBOND_ID_BYTE0   0xEF

Winbond manufacturer ID.

#define WINBOND_ID_BYTE2_128   0x18

Winbond 128Mbit size ID.

#define WINBOND_INDEX_START   (FLASH_CFG_TBL_PARALLEL_1GB_MC + 1)

Winbond start index.

#define WR_CFG_SIZE   3

WRR command + 1 byte each Status and Config Reg.

#define WRITE_CMD   0x02

Page program command.

#define WRITE_CONFIG_CMD   0x01

Write config register command.

#define WRITE_DISABLE_CMD   0x04

Write disable command.

#define WRITE_ENABLE_CMD   0x06

Write enable command.

Referenced by FlashWrite().

#define WRITE_STATUS_CMD   0x01

Write status register command.

Function Documentation

void BulkErase ( XQspiPs *  QspiPtr,
u8 *  WriteBfrPtr 
)

Performs a bulk erase operation when the flash device has a single die.

Works for both Spansion and Micron.

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in,out]WriteBfrPtrPointer to command+address to be sent

References READ_STATUS_CMD.

void DieErase ( XQspiPs *  QspiPtr,
u8 *  WriteBfrPtr 
)

Performs a die erase operation on all the die in the flash device.

The function uses the die erase command for Micron 512Mbit and 1Gbit.

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in,out]WriteBfrPtrPointer to command+address to be sent

References READ_FLAG_STATUS_CMD.

void FlashErase ( XQspiPs *  QspiPtr,
u32  Address,
u32  ByteCount,
u8 *  WriteBfrPtr 
)

Erases the sectors in the serial Flash connected to the QSPI interface.

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in]AddressThe address of the first sector which needs to be erased.
[in]ByteCountThe total size to be erased.
[in,out]WriteBfrPtrPointer to the write buffer (which is to be transmitted)

References READ_STATUS_CMD.

void FlashRead ( XQspiPs *  QspiPtr,
u32  Address,
u32  ByteCount,
u8  Command,
u8 *  WriteBfrPtr,
u8 *  ReadBfrPtr 
)

Performs an I/O read.

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in]AddressThe address to read data from in the Flash.
[in]ByteCountThe number of bytes to read.
[in]CommandThe command used to read data from the flash. Supports normal, fast, dual and quad read commands.
[in,out]WriteBfrPtrPointer to the write buffer which contains data to be transmitted
[out]ReadBfrPtrPointer to the read buffer to which valid received data should be written

References ADDRESS_1_OFFSET, ADDRESS_2_OFFSET, ADDRESS_3_OFFSET, BANKMASK, COMMAND_OFFSET, DUAL_READ_CMD, DUMMY_SIZE, FAST_READ_CMD, Flash_Config_Table, GetRealAddr(), OVERHEAD_SIZE, QUAD_READ_CMD, SendBankSelect(), SIXTEENMB, and XQspiPs_PolledTransfer().

int FlashReadID ( XQspiPs *  QspiPtr,
u8 *  WriteBfrPtr,
u8 *  ReadBfrPtr 
)

Reads serial Flash ID connected to the SPI interface.

It then deduces the make and size of the flash and obtains the connection mode to point to corresponding parameters in the flash configuration table. The flash driver functions based on this and it presently supports Micron and Spansion - 128, 256 and 512Mbit and Winbond 128Mbit

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in,out]WriteBfrPtrPointer to the write buffer (which is to be transmitted)
[out]ReadBfrPtrPointer to the read buffer to which valid received data should be written.
Returns
XST_SUCCESS if read id, otherwise XST_FAILURE.
void FlashWrite ( XQspiPs *  QspiPtr,
u32  Address,
u32  ByteCount,
u8  Command,
u8 *  WriteBfrPtr 
)

Writes to the serial Flash connected to the QSPI interface.

All the data put into the buffer must be in the same page of the device with page boundaries being on 256 byte boundaries.

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in]AddressThe address to write data to in the Flash.
[in]ByteCountThe number of bytes to write.
[in]CommandThe command used to write data to the flash. QSPI device supports only Page Program command to write data to the flash.
[in,out]WriteBfrPtrPointer to the write buffer(which is to be transmitted)

References WRITE_ENABLE_CMD.

u32 GetRealAddr ( XQspiPs *  QspiPtr,
u32  Address 
)

Translates the address based on the type of interconnection.

In case of stacked, the function asserts the corresponding slave select.

Parameters
[in]QspiPtrPointer to the QSPI driver component to use.
[in]AddressAddress which is to be accessed (for erase, write or read).
Returns
RealAddr is the translated address - for single it is unchanged; for stacked, the lower flash size is subtracted; for parallel the address is divided by 2.

References FCTIndex, Flash_Config_Table, XQSPIPS_CONNECTION_MODE_PARALLEL, XQSPIPS_CONNECTION_MODE_SINGLE, XQSPIPS_CONNECTION_MODE_STACKED, XQspiPs_GetLqspiConfigReg, XQSPIPS_LQSPI_CR_U_PAGE_MASK, XQspiPs_SetLqspiConfigReg, and XQspiPs_SetSlaveSelect().

Referenced by FlashRead().

int main ( void  )

Runs the QSPI greater than 128Mb flash example.

Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
int QspiG128FlashExample ( XQspiPs *  QspiInstancePtr,
UINTPTR  BaseAddress 
)

Illustrates how to use the XQspiPs device driver in single, parallel and stacked modes using flash devices greater than 128Mb.

The function reads and writes data in I/O mode.

Parameters
[in]QspiInstancePtrPointer to the QSPIPS driver to use.
[in]BaseAddressThe base address of the device
Returns
XST_SUCCESS if successful, else XST_FAILURE.
Note
In XSCT/classic flow, the device configuration is looked up based on DeviceId.
int SendBankSelect ( XQspiPs *  QspiPtr,
u8 *  WriteBfrPtr,
u32  BankSel 
)

Selects the current bank.

Parameters
[in,out]QspiPtrPointer to the QSPI driver component to use.
[in,out]WriteBfrPtrPointer to the write buffer which contains data to be transmitted.
[in]BankSelThe bank to be selected in the flash device(s).
Returns
XST_SUCCESS if bank selected, otherwise XST_FAILURE.

References ADDRESS_1_OFFSET, BANK_SEL_SIZE, COMMAND_OFFSET, EXTADD_REG_WR, and XQspiPs_PolledTransfer().

Referenced by FlashRead().

Variable Documentation

u32 FCTIndex

Flash configuration table index.

Referenced by GetRealAddr().

FlashInfo Flash_Config_Table[34]

Flash Config Table.

Referenced by FlashRead(), and GetRealAddr().

u32 FlashMake

Flash manufacturer ID.

u32 MaxData = PAGE_COUNT*256

The following constants specify the max amount of data and the size of the the buffer required to hold the data and overhead to transfer the data to and from the Flash.

Initialized to single flash page size.

The following variables hold the data read from and written to the flash and they are global to avoid having large buffers on the stack.

The buffer size accounts for maximum page size and maximum banks - a separate read is performed for each bank, leading to that many (overhead+dummy) bytes.

int Test = 1

The following variable allows a test value to be added to the values that are written to the Flash such that unique values can be generated to guarantee the writes to the Flash were successful.

u8 WriteBuffer[(PAGE_COUNT *MAX_PAGE_SIZE)+DATA_OFFSET]

Write buffer.