1.1.9.8 QMSPIx_DMATransferWrite Function

C

// x - Instance of the QMSPI peripheral

uint32_t QMSPIx_DMATransferWrite(QMSPI_DESCRIPTOR_XFER_T *qmspiDescXfer, void* pTransmitData, size_t txSize);

Summary

Writes data to the QMSPI slave device.

Description

This function can be used to write maximum of one page of data to the specified address of the serial flash device connected as a QMSPI slave. If the number of bytes to be written is greater than the page size then QMSPIx_DMATransferWrite API needs to be called multiple times.

Note: Before sending next write request, QMSPIx_Read() can be called to read the status register of the slave device to check if the previous write operation is completed.

Precondition

QMSPIx_Initialize must have been called for the associated QMSPI instance. Write enable command has to be sent before write memory request.

Parameters

Param Description
*qmspiDescXfer Pointer to QMSPI descriptor transfer structure.
*pTransmitData Pointer to transmit buffer holding the data to write into memory.
txSize Number of bytes to write.

Returns

Number of bytes written in memory.

Example

    uint32_t i;
    QMSPI_DESCRIPTOR_XFER_T qmspiDescXfer;

    APP_WriteEnable();

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

    qmspiDescXfer.command = APP_CMD_QUAD_INPUT_PAGE_PROGRAM;
    qmspiDescXfer.address = address;
    qmspiDescXfer.qmspi_ifc_mode = QUAD_OUTPUT;
    qmspiDescXfer.ldma_enable = true;
    qmspiDescXfer.ldma_channel_num = QMSPI_LDMA_CHANNEL_0;

    for (i = 0; i < APP_PAGE_PROGRAM_SIZE_BYTES; i++)
    {
        appData.transmitBuffer[i] = pPageData[i];
    }
    QMSPI0_DMATransferWrite(&qmspiDescXfer, appData.transmitBuffer, APP_PAGE_PROGRAM_SIZE_BYTES);