/* param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the EDMA transaction. return status of status_t.  */
status_t LPSPI_MasterTransferGetCountEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, size_t *count)
/* param base LPSPI peripheral base address. param handle pointer to lpspi_master_edma_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the EDMA transaction. return status of status_t.  */
status_t LPSPI_MasterTransferGetCountEDMA(LPSPI_Type *base, lpspi_master_edma_handle_t *handle, size_t *count)
{
    assert(handle != NULL);
    if (NULL == count)
    {
        return kStatus_InvalidArgument;
    }
    if (handle->state != (uint8_t)kLPSPI_Busy)
    {
        *count = 0;
        return kStatus_NoTransferInProgress;
    }
    size_t remainingByte;
    remainingByte =
        (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->edmaRxRegToRxDataHandle->base,
                                                                   handle->edmaRxRegToRxDataHandle->channel);
    *count = handle->totalByteCount - remainingByte;
    return kStatus_Success;
}