/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param count Number of bytes transferred so far by the non-blocking transaction. retval #kStatus_Success retval #kStatus_NoTransferInProgress There is not a DMA transaction currently in progress.  */
status_t LPI2C_MasterTransferGetCountEDMA(LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, size_t *count)
/* param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param count Number of bytes transferred so far by the non-blocking transaction. retval #kStatus_Success retval #kStatus_NoTransferInProgress There is not a DMA transaction currently in progress.  */
status_t LPI2C_MasterTransferGetCountEDMA(LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, size_t *count)
{
    assert(handle);
    if (!count)
    {
        return kStatus_InvalidArgument;
    }
    if (!handle->isBusy)
    {
        *count = 0;
        return kStatus_NoTransferInProgress;
    }
    uint32_t remaining = handle->transfer.dataSize;
    if (EDMA_GetNextTCDAddress(handle->tx) == 0)
    {
        if (handle->transfer.direction == kLPI2C_Write)
        {
            remaining =
                (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->tx->base, handle->tx->channel);
        }
        else
        {
            remaining =
                (uint32_t)handle->nbytes * EDMA_GetRemainingMajorLoopCount(handle->rx->base, handle->rx->channel);
        }
    }
    *count = handle->transfer.dataSize - remaining;
    return kStatus_Success;
}