qspips
Vitis Drivers API Documentation
xqspips_flash_polled_example.c File Reference

Overview

This file contains a design example using the QSPI driver (XQspiPs) in polled mode with a serial FLASH device.

This examples performs some transfers in Auto mode and Manual start mode, to illustrate the modes available. 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 1.01 srt 06/12/12 Changed to meet frequency requirements of READ command for CR 663787 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. See http://www.xilinx.com/support/answers/47596.htm. 2.01a sg 02/03/13 Created a function FlashReadID. Removed multiple initialization using SetOptions. 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. 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 QspiFlashPolledExample (XQspiPs *QspiInstancePtr, u16 QspiDeviceId)
 The purpose of this function is to illustrate how to use the XQspiPs device driver in polled 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.

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.
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.
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.
void FlashWrite ( XQspiPs QspiPtr,
u32  Address,
u32  ByteCount,
u8  Command 
)

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.
int main ( void  )

Main function to call the QSPI Flash example.

Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
Note
None

References QspiFlashPolledExample().

int QspiFlashPolledExample ( XQspiPs QspiInstancePtr,
u16  QspiDeviceId 
)

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

This function writes and reads data from a serial FLASH.

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(), FlashRead(), FlashReadID(), FlashWrite(), XQspiPs_CfgInitialize(), XQSPIPS_CLK_PRESCALE_8, XQSPIPS_FORCE_SSELECT_OPTION, XQSPIPS_HOLD_B_DRIVE_OPTION, XQspiPs_LookupConfig(), XQSPIPS_MANUAL_START_OPTION, XQspiPs_SelfTest(), XQspiPs_SetClkPrescaler(), XQspiPs_SetOptions(), and XQspiPs_SetSlaveSelect().

Referenced by main().