/* param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. return status of status_t.  */
status_t LPSPI_MasterTransferGetCount(LPSPI_Type *base, lpspi_master_handle_t *handle, size_t *count)
/* param base LPSPI peripheral address. param handle pointer to lpspi_master_handle_t structure which stores the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. return status of status_t.  */
status_t LPSPI_MasterTransferGetCount(LPSPI_Type *base, lpspi_master_handle_t *handle, size_t *count)
{
    assert(handle);
    if (!count)
    {
        return kStatus_InvalidArgument;
    }
    if (handle->state != kLPSPI_Busy)
    {
        *count = 0;
        return kStatus_NoTransferInProgress;
    }
    size_t remainingByte;
    if (handle->rxData)
    {
        remainingByte = handle->rxRemainingByteCount;
    }
    else
    {
        remainingByte = handle->txRemainingByteCount;
    }
    *count = handle->totalByteCount - remainingByte;
    return kStatus_Success;
}