2.86 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

NameDescription
QMSPIx_InitializeInitializes given instance of the QMSPI peripheral
QMSPIx_ChipSelectSetupEnables the specified hardware chip select
QMSPIx_TransferSetupConfigure QMSPI operational parameters at run time
QMSPIx_TapControlSetSet control tap adjustment to QMSPI peripheral
QMSPIx_WriteWrites command/register to QMSPI slave device
QMSPIx_ReadReads register from the QMSPI slave device
QMSPIx_IsTransmitterBusyReturns transfer status of QMSPI peripheral
QMSPIx_DMATransferWriteWrites data to the QMSPI slave device
QMSPIx_DMATransferReadReads data from the QMSPI slave device
QMSPIx_CallbackRegisterAllows application to register callback with PLIB
Data types and constants
NameTypeDescription
QMSPI_CHIP_SELECTEnumDefines the data type to specify chip select number
QMSPI_INTERFACE_MODEEnumDefines the data type to specify interface mode
QMSPI_LDMA_CHANNEL_NUMTypedefDefines the data type to specify LDMA channel number
QMSPI_CLOCK_PHASE_MOSIEnumIdentifies QMSPI Clock Phase MOSI Options
QMSPI_CLOCK_PHASE_MISOEnumIdentifies QMSPI Clock Phase MISO Options
QMSPI_CLOCK_POLARITYEnumIdentifies QMSPI Clock Polarity Options
QMSPI_TRANSFER_SETUPStructIdentifies the setup parameters which can be changed dynamically
QMSPI_XFER_TStructDefines the data type for the QMSPI command/register transfer
QMSPI_DESCRIPTOR_XFER_TStructDefines the data type for the QMSPI memory transfer
QMSPI_CALLBACKTypedefPointer to a Callback function
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.