/* Check the status of the UART and gather information about any ongoing receive operations.  */
UARTDRV_Status_t UARTDRV_GetReceiveStatus(UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *itemsReceived, UARTDRV_Count_t *itemsRemaining)
/* Check the status of the UART and gather information about any ongoing receive operations.  */
UARTDRV_Status_t UARTDRV_GetReceiveStatus(UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *itemsReceived, UARTDRV_Count_t *itemsRemaining)
{
  UARTDRV_Buffer_t *rxBuffer = NULL;
  Ecode_t retVal = ECODE_EMDRV_UARTDRV_OK;
  uint32_t remaining = 0;
  if (handle->rxQueue->used > 0)
  {
    retVal = GetTailBuffer(handle->rxQueue, &rxBuffer);
    DMADRV_TransferRemainingCount(handle->rxDmaCh,
                                  (int*)&remaining);
  }
  if (rxBuffer && (retVal == ECODE_EMDRV_UARTDRV_OK))
  {
    *itemsReceived = rxBuffer->transferCount - remaining;
    *itemsRemaining = remaining;
    *buffer = rxBuffer->data;
  }
  else
  {
    *itemsRemaining = 0;
    *itemsReceived = 0;
    *buffer = NULL;
  }
  return UARTDRV_GetPeripheralStatus(handle);
}