Hi, Vlad
I am sorry for delayed response.
I does not use max buffer size.
I use rxCallback function like below.
/***************************** call back*************************/
/* UART rx callback for continuous reception, byte by byte */
void rxCallback(void *driverState, uart_event_t event, void *userData)
{
/* Unused parameters */
(void)driverState;
(void)userData;
/* Check the event type */
if (event == UART_EVENT_RX_FULL)
{
#if 0 /* */
/* The reception stops when newline is received or the buffer is full */
if ( (bufferIdx != (BUFFER_SIZE - 2U)))
{
/* Update the buffer index and the rx buffer */
bufferIdx++;
LPUART_DRV_SetRxBuffer(INST_LPUART1, &buffer[bufferIdx], 1U);
}
#endif
}
}
/*************** main ***************/
while (1)
{
/* Receive and store data byte by byte until new line character is received,
* or the buffer becomes full (256 characters received)
*/
LPUART_DRV_ReceiveData(INST_LPUART1, buffer, 1U);
/* Wait for transfer to be completed */
while(LPUART_DRV_GetReceiveStatus(INST_LPUART1, &bytesRemaining) == STATUS_BUSY);
/* Check the status */
status = LPUART_DRV_GetReceiveStatus(INST_LPUART1, &bytesRemaining);
if (status != STATUS_SUCCESS)
{
/* If an error occurred, send the error message and exit the loop */
LPUART_DRV_SendDataBlocking(INST_LPUART1, (uint8_t *)errorMsg, strlen(errorMsg), TIMEOUT);
break;
}
/* Append string terminator to the received data */
bufferIdx++;
buffer[bufferIdx] = 0U;
#if 0
/* If the received string is "Hello Board", send back "Hello World" */
if(strcmp((char *)buffer, "Hello Board\n") == 0)
{
strcpy((char *)buffer, "Hello World\n");
}
#endif
/* Send the received data back */
LPUART_DRV_SendDataBlocking(INST_LPUART1, buffer, bufferIdx, TIMEOUT);
/* Reset the buffer index to start a new reception */
bufferIdx = 0U;
}
Thanks and best regards,
Byungju