qspips
Vitis Drivers API Documentation
xqspips_dual_flash_lqspi_example.c File Reference

Overview

This file contains a design example using the QSPI driver (XQspiPs) in Linear QSPI mode, with two serial FLASH devices on separate buses.

With two flash memories on separate buses, even numbered bits in data words are written to the lower memory and odd numbered bits are written to the upper memory. This example writes to the two flash memories in QSPI mode and reads the data back from the flash memories, in Linear QSPI mode. It is recommended to use Manual CS + Auto start for best performance.

The hardware which this example runs on, must have a serial FLASH (Numonyx N25Q, Winbond W25Q, Spansion S25FL, ISSI IS25WP) for it to run. This example has been tested with the Numonyx Serial Flash (N25Q128) and IS25WP series flash parts.

Note

None.

 MODIFICATION HISTORY:
 Ver   Who Date     Changes


1.00 sdm 11/25/10 First release 2.00a kka 22/08/12 Updated the example as XQspiPs_PolledTransfer API has changed. Changed the prescalar to use divide by 8. The user can change the prescalar to a maximum of divide by 2 based on the reference clock in the system. Set the Holdb_dr bit in the configuration register using XQSPIPS_HOLD_B_DRIVE_OPTION. Setting this bit drives the HOLD bit of the QSPI controller. This is required for QSPI to be used in Non QSPI boot mode else there needs to be an external pullup on this line. ms 04/05/17 Modified Comment lines in functions to recognize it as documentation block for doxygen generation. 3.5 tjs 07/16/18 Added support for low density ISSI flash parts. Added FlashQuadEnable API to enable quad mode in flash. Added FlashReadID API to read and identify the flash. 3.6 akm 04/15/19 Modified FlashQuadEnable, FlashWrie and FlashErase APIs, to wait for the on going operation to complete before performing the next operation. 3.10 akm 08/17/22 Fix logical error in NumSect calculation. 3.11 akm 07/10/23 Add support for system device-tree flow for example.

Functions

void FlashErase (XQspiPs *QspiPtr, u32 Address, u32 ByteCount)
 This function erases the sectors in the serial FLASH connected to the QSPI interface. More...
 
void FlashWrite (XQspiPs *QspiPtr, u32 Address, u32 ByteCount, u8 Command)
 This function writes to the serial FLASH connected to the QSPI interface. More...
 
void FlashRead (XQspiPs *QspiPtr, u32 Address, u32 ByteCount, u8 Command)
 This function reads from the serial FLASH connected to the QSPI interface. More...
 
int FlashReadID (void)
 This function reads serial FLASH ID connected to the SPI interface. More...
 
void FlashQuadEnable (XQspiPs *QspiPtr)
 This function enables quad mode in the serial flash connected to the SPI interface. More...
 
int LinearQspiFlashExample (XQspiPs *QspiInstancePtr, u16 QspiDeviceId)
 The purpose of this function is to illustrate how to use the XQspiPs device driver in Linear mode. More...
 
int main (void)
 Main function to call the QSPI Flash example. More...
 

Function Documentation

void FlashErase ( XQspiPs QspiPtr,
u32  Address,
u32  ByteCount 
)

This function erases the sectors in the serial FLASH connected to the QSPI interface.

This function erases the sectors in the serial Flash connected to the QSPI interface.

Parameters
QspiPtris a pointer to the QSPI driver component to use.
Addresscontains the address of the first sector which needs to be erased.
ByteCountcontains the total size to be erased.
Returns
None.
Note
None.

References XQspiPs_PolledTransfer().

Referenced by DualStackExample(), LinearQspiFlashExample(), QspiFlashIntrExample(), QspiFlashPolledExample(), and QspiG128FlashExample().

void FlashQuadEnable ( XQspiPs QspiPtr)

This function enables quad mode in the serial flash connected to the SPI interface.

Parameters
QspiPtris a pointer to the QSPI driver component to use.
Returns
None.
Note
None.

References XQspiPs_PolledTransfer().

Referenced by DualStackExample(), LinearQspiFlashExample(), QspiFlashIntrExample(), and QspiFlashPolledExample().

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

This function reads from the serial FLASH connected to the QSPI interface.

Parameters
QspiPtris a pointer to the QSPI driver component to use.
Addresscontains the address to read data from in the FLASH.
ByteCountcontains the number of bytes to read.
Commandis the command used to read data from the flash. QSPI device supports one of the Read, Fast Read, Dual Read and Fast Read commands to read data from the flash.
Returns
None.
Note
None.

References XQspiPs_Transfer().

Referenced by QspiFlashIntrExample(), QspiFlashPolledExample(), and QspiG128FlashExample().

int FlashReadID ( void  )

This function reads serial FLASH ID connected to the SPI interface.

Returns
XST_SUCCESS if read id, otherwise XST_FAILURE.
Note
None.

References XQspiPs_PolledTransfer().

Referenced by DualStackExample(), LinearQspiFlashExample(), QspiFlashIntrExample(), QspiFlashPolledExample(), and QspiG128FlashExample().

void FlashWrite ( XQspiPs QspiPtr,
u32  Address,
u32  ByteCount,
u8  Command 
)

This function writes to the serial FLASH connected to the QSPI interface.

This function 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
QspiPtris a pointer to the QSPI driver component to use.
Addresscontains the address to write data to in the FLASH.
ByteCountcontains the number of bytes to write.
Commandis the command used to write data to the flash. QSPI device supports only Page Program command to write data to the flash.
Returns
None.
Note
None.

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
QspiPtris a pointer to the QSPI driver component to use.
Addresscontains the address to write data to in the Flash.
ByteCountcontains the number of bytes to write.
Commandis the command used to write data to the flash. QSPI device supports only Page Program command to write data to the flash.
Returns
None.
Note
None.

References XQspiPs_PolledTransfer().

Referenced by DualStackExample(), LinearQspiFlashExample(), QspiFlashIntrExample(), QspiFlashPolledExample(), and QspiG128FlashExample().

int LinearQspiFlashExample ( XQspiPs QspiInstancePtr,
u16  QspiDeviceId 
)

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

This function writes data to the serial FLASH in QSPI mode and reads data in Linear QSPI mode.

Parameters
QspiInstancePtris a pointer to the QSPIPS driver to use.
QspiDeviceIdis the XPAR_<QSPIPS_instance>_DEVICE_ID value from xparameters.h
Returns
XST_SUCCESS if successful, else XST_FAILURE.
Note
None.

This function writes data to the serial FLASH in QSPI mode and reads data in Linear QSPI mode.

Parameters
QspiInstancePtris a pointer to the QSPIPS driver to use.
QspiDeviceIdis the XPAR_<QSPIPS_instance>_DEVICE_ID value from xparameters.h.
Returns
XST_SUCCESS if successful, else XST_FAILURE.
Note
None.

References XQspiPs_Config::BaseAddress, FlashErase(), FlashQuadEnable(), FlashReadID(), FlashWrite(), XQspiPs_CfgInitialize(), XQSPIPS_CLK_PRESCALE_8, XQSPIPS_FORCE_SSELECT_OPTION, XQSPIPS_HOLD_B_DRIVE_OPTION, XQspiPs_LookupConfig(), XQSPIPS_LQSPI_MODE_OPTION, XQspiPs_LqspiRead(), XQSPIPS_MANUAL_START_OPTION, XQspiPs_SelfTest(), XQspiPs_SetClkPrescaler(), XQspiPs_SetLqspiConfigReg, XQspiPs_SetOptions(), and XQspiPs_SetSlaveSelect().

Referenced by main().

int main ( void  )

Main function to call the QSPI Flash example.

Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
Note
None

References LinearQspiFlashExample().