1. UART_RTOS_Receive() in fsl_uart_freertos.c ,
int UART_RTOS_Receive(uart_rtos_handle_t *handle, uint8_t *buffer, uint32_t length, size_t *received)
{ ...
UART_TransferReceiveNonBlocking(handle->base, handle->t_state, &handle->rxTransfer, &n);
ev = xEventGroupWaitBits(handle->rxEvent,
RTOS_UART_COMPLETE | RTOS_UART_RING_BUFFER_OVERRUN | RTOS_UART_HARDWARE_BUFFER_OVERRUN,
pdTRUE, pdFALSE, portMAX_DELAY);
...
}
If a program act as master, it would first send something to the slave, and wait slave respond. but if the packet come from slave occure any error, master can not receive enough data that it want to, the RTOS_UART_COMPLETE event will never be fired, the program will blocked in xEventGroupWaitBits() forever. because the parameter uxBitsToWaitFor is set portMAX_DELAY(it's means to never timeout). I suggest add a timeout parameter for UART_RTOS_Receive() to give a chance for user, to handle if any error occure from incoming data issue.
2. UART_TransferHandleIRQ() in fsl_uart.c, do not need to call UART_TransferIsRxRingBufferFull() twice every time. I have make some change as follow.
void UART_TransferHandleIRQ(UART_Type *base, uart_handle_t *handle)
{
...
if (handle->rxRingBuffer)
{
while (count--)
{
if (UART_TransferIsRxRingBufferFull(handle))
{
if (handle->callback)
{
handle->callback(base, handle, kStatus_UART_RxRingBufferOverrun, handle->userData);
}
if (UART_TransferIsRxRingBufferFull(handle))
{
if (handle->rxRingBufferTail + 1U == handle->rxRingBufferSize)
{
handle->rxRingBufferTail = 0U;
}
else
{
handle->rxRingBufferTail++;
}
}
}
#if 0
if (UART_TransferIsRxRingBufferFull(handle))
{
if (handle->rxRingBufferTail + 1U == handle->rxRingBufferSize)
{
handle->rxRingBufferTail = 0U;
}
else
{
handle->rxRingBufferTail++;
}
}
#endif
handle->rxRingBuffer[handle->rxRingBufferHead] = base->D;
...
}