1.27.14.8 QSPIx_WriteRead Function

C

// x - Instance of the QSPI peripheral

bool QSPIx_WriteRead
(
void* pTransmitData,
size_t txSize,
void* pReceiveData,
size_t rxSize
);

Summary

Write and Read data on QSPI peripheral. This is used in SPI mode only.

Description

This function should be used to write "txSize" number of bytes and read "rxSize" number of bytes on QSPI module. Data pointed by pTransmitData is transmitted and received data is saved in the location pointed by pReceiveData.

Precondition

The QSPIx_Initialize function must have been called. Callback has to be registered using QSPIx_CallbackRegister API if the peripheral instance has been configured in Interrupt mode and transfer completion status needs to be communicated back to application via callback.

Parameters

Param Description
*pTransmitData Pointer to the data which has to be transmitted. if it isNULL, that means only data receiving is expected. For 9 to 15bit mode, data should be right aligned in the 16 bit memory location.
txSize Number of bytes to be transmitted. Always, size should begiven in terms of bytes. For example, if 5 16-bit data are to be transmitted, the transmit size should be 10 bytes.
*pReceiveData Pointer to the location where received data has to be stored.It is user's responsibility to ensure pointed location has sufficient memory to store the read data. if it is NULL, that means only data transmission is expected. For 9 to 15bit mode, received data will be right aligned in the 16 bit memory location.
rxSize Number of bytes to be received. Always, size should begiven in terms of bytes. For example, if 5 16-bit data are to be received, the receive size should be 10 bytes. if "n" number of bytes has to be received AFTER transmitting "m" number of bytes, then "rxSize" should be set as "m+n".

Returns

  • In Blocking mode:

    • API returns True once the transfer is complete. It returns False if either of the size parameters are 0 and corresponding data pointer is NULL.

  • In interrupt mode:

    • If previous buffer request is not completed and a new transfer request comes, then this API will reject the new request and will return "False".

    • Also, Same as blocking mode, It returns False if either of the size parameters are 0 and corresponding data pointer is NULL.

Example

uint8_t txBuffer[4];
uint8_t rxBuffer[10];
size_t txSize = 4;
size_t rxSize = 10;
bool reqAccepted;

reqAccepted = QSPI0_WriteRead(&txBuffer, txSize, &rxBuffer, rxSize);

Remarks

Non-blocking interrupt mode configuration implementation of this function will be used by Harmony driver implementation APIs.