/* param base SPI peripheral base address. param handle A pointer to the spi_dma_handle_t structure which stores the transfer state. param count A number of bytes transferred by the non-blocking transaction. return status of status_t.  */
status_t SPI_MasterTransferGetCountDMA(SPI_Type *base, spi_dma_handle_t *handle, size_t *count)
/* param base SPI peripheral base address. param handle A pointer to the spi_dma_handle_t structure which stores the transfer state. param count A number of bytes transferred by the non-blocking transaction. return status of status_t.  */
status_t SPI_MasterTransferGetCountDMA(SPI_Type *base, spi_dma_handle_t *handle, size_t *count)
{
    assert(handle != NULL);
    if (NULL == count)
    {
        return kStatus_InvalidArgument;
    }
    if (handle->state != (uint8_t)kSPI_Busy)
    {
        *count = 0;
        return kStatus_NoTransferInProgress;
    }
    size_t bytes;
    bytes = DMA_GetRemainingBytes(handle->rxHandle->base, handle->rxHandle->channel);
    *count = handle->transferSize - bytes;
    return kStatus_Success;
}