/* Receive a piece of data for SPI master. 
This function computes the number of data to receive from D register or Rx FIFO, and write the data to destination address. At the same time, this function updates the values in master handle structure. */
static void FLEXIO_SPI_TransferReceiveTransaction(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle)
/* Receive a piece of data for SPI master. 
This function computes the number of data to receive from D register or Rx FIFO, and write the data to destination address. At the same time, this function updates the values in master handle structure. */
static void FLEXIO_SPI_TransferReceiveTransaction(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle)
{
    uint16_t tmpData;
    tmpData = FLEXIO_SPI_ReadData(base, handle->direction);
    if (handle->rxData != NULL)
    {
        if (handle->bytePerFrame == 1U)
        {
            *handle->rxData = tmpData;
            handle->rxData++;
        }
        else
        {
            if (handle->direction == kFLEXIO_SPI_MsbFirst)
            {
                *((uint16_t *)(handle->rxData)) = tmpData;
            }
            else
            {
                *((uint16_t *)(handle->rxData)) = (((tmpData << 8) & 0xff00U) | ((tmpData >> 8) & 0x00ffU));
            }
            handle->rxData += 2U;
        }
    }
    handle->rxRemainingBytes -= handle->bytePerFrame;
}