1.1.9 QUAD MODE SPI HOST CONTROLLER (QMSPI)

The Quad Mode SPI Host Controller (QMSPI) may be used to communicate with various peripheral devices that use a Serial Peripheral Interface, such as EEPROMS, DACs and ADCs. The controller can be configured to support advanced SPI Flash devices with multiphase access protocols. Data can be transferred in Half Duplex, Single Data Rate, Dual Data Rate and Quad Data Rate modes. In all modes and all SPI clock speeds, the controller supports back-to-back reads and writes without clock stretching if internal bandwidth permits.

Using The Library

The QMSPI Peripheral Library is used to interface with the QMSPI based Serial Flash Memories operating in Single-bit SPI, Dual SPI and Quad SPI. The QMSPI Peripheral library provides blocking API's, which can be used to perform the following functionalists on the QMSPI Slave device.

Command and Register read/write

QMSPI_XFER_T data type needs to be filled for the following operations:
  • Send a command to the slave device
  • Read data from a register
  • Write data to a register

Memory read/write

QMSPI_DESCRIPTOR_XFER_T data type needs to be filled for the following operations:

  • Read data from the FLASH memory
  • Write data to the FLASH memory

Here is an example code to read data from W25 FLASH memory using QMSPI peripheral

 
    QMSPI_DESCRIPTOR_XFER_T qmspiDescXfer;

    memset(&qmspiDescXfer, 0x00, sizeof(QMSPI_DESCRIPTOR_XFER_T));

    qmspiDescXfer.address = address;
    qmspiDescXfer.qmspi_ifc_mode = QUAD_OUTPUT;
    qmspiDescXfer.ldma_enable = true;
    qmspiDescXfer.ldma_channel_num = QMSPI_LDMA_CHANNEL_0;
    qmspiDescXfer.command = APP_CMD_MEMORY_FAST_READ_QUAD;
    qmspiDescXfer.num_of_dummy_byte = 4;

    QMSPI0_DMATransferRead(&qmspiDescXfer, pReadBuffer, nBytes);

Library Interface

QMSPI peripheral library provides the following interfaces:

Functions

Name Description
QMSPIx_Initialize Initializes given instance of the QMSPI peripheral
QMSPIx_ChipSelectSetup Enables the specified hardware chip select
QMSPIx_TransferSetup Configure QMSPI operational parameters at run time
QMSPIx_TapControlSet Set control tap adjustment to QMSPI peripheral
QMSPIx_Write Writes command/register to QMSPI slave device
QMSPIx_Read Reads register from the QMSPI slave device
QMSPIx_IsTransmitterBusy Returns transfer status of QMSPI peripheral
QMSPIx_DMATransferWrite Writes data to the QMSPI slave device
QMSPIx_DMATransferRead Reads data from the QMSPI slave device
QMSPIx_CallbackRegister Allows application to register callback with PLIB
Data types and constants
Name Type Description
QMSPI_CHIP_SELECT Enum Defines the data type to specify chip select number
QMSPI_INTERFACE_MODE Enum Defines the data type to specify interface mode
QMSPI_LDMA_CHANNEL_NUM Typedef Defines the data type to specify LDMA channel number
QMSPI_CLOCK_PHASE_MOSI Enum Identifies QMSPI Clock Phase MOSI Options
QMSPI_CLOCK_PHASE_MISO Enum Identifies QMSPI Clock Phase MISO Options
QMSPI_CLOCK_POLARITY Enum Identifies QMSPI Clock Polarity Options
QMSPI_TRANSFER_SETUP Struct Identifies the setup parameters which can be changed dynamically
QMSPI_XFER_T Struct Defines the data type for the QMSPI command/register transfer
QMSPI_DESCRIPTOR_XFER_T Struct Defines the data type for the QMSPI memory transfer
QMSPI_CALLBACK Typedef Pointer to a Callback function