/* Send a piece of data for SPI. 
This function computes the number of data to be written into D register or Tx FIFO, and write the data into it. At the same time, this function updates the values in master handle structure. */
static void FLEXIO_SPI_TransferSendTransaction(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle)
/* Send a piece of data for SPI. 
This function computes the number of data to be written into D register or Tx FIFO, and write the data into it. At the same time, this function updates the values in master handle structure. */
static void FLEXIO_SPI_TransferSendTransaction(FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle)
{
    uint16_t tmpData = FLEXIO_SPI_DUMMYDATA;
    if (handle->txData != NULL)
    {
        if (handle->bytePerFrame == 1U)
        {
            tmpData = *(handle->txData);
            handle->txData++;
        }
        else
        {
            tmpData = (uint32_t)(handle->txData[0]) << 8U;
            tmpData += handle->txData[1];
            handle->txData += 2U;
        }
    }
    else
    {
        tmpData = FLEXIO_SPI_DUMMYDATA;
    }
    handle->txRemainingBytes -= handle->bytePerFrame;
    FLEXIO_SPI_WriteData(base, handle->direction, tmpData);
    if (!handle->txRemainingBytes)
    {
        FLEXIO_SPI_DisableInterrupts(base, kFLEXIO_SPI_TxEmptyInterruptEnable);
    }
}