- Main Page
- Data Structures
- Files
- Directories

- File List
- Globals

# xilisf.c File Reference

`#include "include/xilisf.h"`

## Functions
int | XIsf_Initialize (XIsf *InstancePtr, XIsf_Iface *SpiInstPtr, u8 SlaveSelect, u8 *WritePtr)
int | XIsf_SetSpiConfiguration (XIsf *InstancePtr, XIsf_Iface *SpiInstPtr, u32 Options, u8 PreScaler)
int | XIsf_GetStatus (XIsf *InstancePtr, u8 *ReadPtr)
int | XIsf_GetDeviceInfo (XIsf *InstancePtr, u8 *ReadPtr)
int | XIsf_WriteEnable (XIsf *InstancePtr, u8 WriteEnable)
int | XIsf_Ioctl (XIsf *InstancePtr, XIsf_IoctlOperation Operation)

## Detailed Description

This file contains the library functions to initialize, control and read the device information of the Serial Flash devices. Refer xilisf.h for detailed description.

     MODIFICATION HISTORY:

     Ver   Who      Date     Changes
     ----- -------  -------- -----------------------------------------------
     1.00a ksu/sdm  03/03/08 First release
     1.00a sdm      07/02/08 Changed the initialization so that the SPI
    			  Master works in Spi Mode 3 as the In-System Flash
    			  works only in Spi Mode 3
     2.00a ktn      11/27/09 Updated to use HAL processor APIs/definitions
     2.01a sdm      01/04/10 Added Support for Winbond W25QXX/W25XX devices
    			  The parameter PagesPerBlock in the struct
    			  IntelStmDeviceGeometry has been renamed to
    			  PagesPerSector.
     2.03a sdm      04/17/10 Updated to support Winbond memory W25Q128.
     2.04a sdm      08/17/10 Updated to support Numonyx (N25QXX) and Spansion
    			  flash memories
     3.00a srt	 06/20/12 Updated to support interfaces SPI PS and QSPI PS.
    			  New API:
    				XIsf_RegisterInterface()
    				XIsf_SetSpiConfiguration()
    				XIsf_SetTransferMode()
    			  Changed API:
    				XIsf_Initialize()
    				XIsf_Transfer()
    			  Added support to SST flash.
     3.01a srt	 02/06/13 Updated for changes made in QSPIPS driver (CR 698107).

## Function Documentation

int XIsf_GetDeviceInfo | ( | XIsf * | InstancePtr,
|  | u8 * | ReadPtr
| ) |

  | This API reads the Joint Electron Device Engineering Council (JEDEC) information of the Serial Flash. Parameters:
  | InstancePtr | is a pointer to the XIsf instance.
  | ReadPtr | is a pointer to the buffer where the Device information is copied.
Returns: XST_SUCCESS if successful else XST_FAILURE. Note: The Device information is stored at the second byte pointed by the ReadPtr.

int XIsf_GetStatus | ( | XIsf * | InstancePtr,
|  | u8 * | ReadPtr
| ) |

  | This API reads the Serial Flash Status Register. Parameters:
  | InstancePtr | is a pointer to the XIsf instance.
  | ReadPtr | is a pointer to the memory where the Status Register content is copied.
Returns: XST_SUCCESS if successful else XST_FAILURE. Note: The contents of the Status Register is stored at the second byte pointed by the ReadPtr.

int XIsf_Initialize | ( | XIsf * | InstancePtr,
|  | XIsf_Iface * | SpiInstPtr,
|  | u8 | SlaveSelect,
|  | u8 * | WritePtr
| ) |

  | The geometry of the underlying Serial Flash is determined by reading the Joint Electron Device Engineering Council (JEDEC) Device Information and the Status Register of the Serial Flash. This API when called initializes the SPI interface with default settings. With custom settings, user should call XIsf_SetSpiConfiguration() and then call this API. Parameters:
  | InstancePtr | is a pointer to the XIsf instance.
  | SpiInstPtr | is a pointer to the XIsf_Iface instance to be worked on.
  | SlaveSelect | is a 32-bit mask with a 1 in the bit position of the slave being selected. Only one slave can be selected at a time.
  | WritePtr | is a pointer to the buffer allocated by the user to be used by the In-system and Serial Flash Library to perform any read/write operations on the Serial Flash device. User applications must pass the address of this buffer for the Library to work. Write operations : The size of this buffer should be equal to the Number of bytes to be written to the Serial Flash + XISF_CMD_MAX_EXTRA_BYTES. The size of this buffer should be large enough for usage across all the applications that use a common instance of the Serial Flash. A minimum of one byte and a maximum of ISF_PAGE_SIZE bytes can be written to the Serial Flash, through a single Write operation. Read operations : The size of this buffer should be equal to XISF_CMD_MAX_EXTRA_BYTES, if the application only reads from the Serial Flash (no write operations).
Returns: - XST_SUCCESS if successful. XST_DEVICE_IS_STOPPED if the device must be started before transferring data. XST_FAILURE, otherwise. Note: - The XIsf_Initialize() API is a blocking call (for both polled and interrupt modes of the Spi driver). It reads the JEDEC information of the device and waits till the transfer is complete before checking if the information is valid. This library can support multiple instances of Serial Flash at a time, provided they are of the same device family (either Atmel, Intel or STM, Winbond or Spansion) as the device family is selected at compile time.

int XIsf_Ioctl | ( | XIsf * | InstancePtr,
|  | XIsf_IoctlOperation | Operation
| ) |

  | This API configures and controls the Intel, STM, Winbond and Spansion Serial Flash. Parameters:
  | InstancePtr | is a pointer to the XIsf instance.
  | Operation | is the type of Control operation to be performed on the Serial Flash. The different control operations are XISF_RELEASE_DPD: Release from Deep Power Down (DPD) Mode XISF_ENTER_DPD: Enter DPD Mode XISF_CLEAR_SR_FAIL_FLAGS: Clear the Status Register Fail Flags
Returns: XST_SUCCESS if successful else XST_FAILURE. Note: Atmel Serial Flash does not support any of these operations. Intel Serial Flash support Enter/Release from DPD Mode and Clear Status Register Fail Flags. STM, Winbond and Spansion Serial Flash support Enter/Release from DPD Mode. Winbond (W25QXX) Serial Flash support Enable High Performance mode.

int XIsf_SetSpiConfiguration | ( | XIsf * | InstancePtr,
|  | XIsf_Iface * | SpiInstPtr,
|  | u32 | Options,
|  | u8 | PreScaler
| ) |

  | This API sets the configuration of SPI. This will set the options and clock prescaler (if applicable). Parameters:
  | InstancePtr | is a pointer to the XIsf instance.
  | SpiInstPtr | is a pointer to the XIsf_Iface instance to be worked on.
  | Options | contains specified options to be set.
  | PreScaler | is the value of the clock prescaler to set.
Returns: XST_SUCCESS if successful else XST_FAILURE. Note: This API can be called before calling XIsf_Initialize() to initialize the SPI interface in other than default options mode. PreScaler is only applicable to PS SPI/QSPI.

int XIsf_WriteEnable | ( | XIsf * | InstancePtr,
|  | u8 | WriteEnable
| ) |

  | This API Enables/Disables writes to the Intel, STM, Winbond and Spansion Serial Flash. Parameters:
  | InstancePtr | is a pointer to the XIsf instance.
  | WriteEnable | specifies whether to Enable (XISF_CMD_ENABLE_WRITE) or Disable (XISF_CMD_DISABLE_WRITE) the writes to the Serial Flash.
Returns: XST_SUCCESS if successful else XST_FAILURE. Note: This API works only for Intel, STM, Winbond and Spansion Serial Flash. If this API is called for Atmel Flash, XST_FAILURE is returned.