qspips: xqspips_flash_lqspi_example.c File Reference

| qspips Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xqspips_flash_lqspi_example.c File Reference

## Overview

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

The example writes to the flash in QSPI mode and reads it back in Linear QSPI mode. 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
     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.
           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.

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

Parameters

  QspiPtr | is a pointer to the QSPI driver component to use.
  Address | contains the address of the first sector which needs to be erased.
  ByteCount | contains 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

  QspiPtr | is a pointer to the QSPI driver component to use.

Returns
  None.

Note
  None.

int FlashReadID | ( | void |  | ) |

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

Parameters

  None. |

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

  QspiPtr | is a pointer to the QSPI driver component to use.
  Address | contains the address to write data to in the FLASH.
  ByteCount | contains the number of bytes to write.
  Command | is 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 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

  None. |

Returns
  XST_SUCCESS if successful, else XST_FAILURE.

Note
  None.

int main | ( | void |  | ) |

Main function to call the QSPI Flash example.

Parameters

  None |

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note
  None

References LinearQspiFlashExample().