/* Receive a piece of data for ECSPI 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 ECSPI_ReceiveTransfer(ECSPI_Type *base, ecspi_master_handle_t *handle)
/* Receive a piece of data for ECSPI 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 ECSPI_ReceiveTransfer(ECSPI_Type *base, ecspi_master_handle_t *handle)
{
    assert(base);
    uint32_t dataCounts = 0U;
    dataCounts =
        (ECSPI_GetRxFifoCount(base) < handle->rxRemainingBytes) ? ECSPI_GetRxFifoCount(base) : handle->rxRemainingBytes;
    ECSPI_ReadNonBlocking(base, handle->rxData, dataCounts);
    if (NULL != handle->rxData)
    {
        handle->rxData += dataCounts;
    }
    handle->rxRemainingBytes -= dataCounts;
}