static void rxCallback(void *driverState, uart_event_t event, void *userData)
{
/* Unused parameters */
(void)driverState;
(void)userData;
switch(event)
{
case UART_EVENT_RX_FULL:
if(uart_rx_handle.uart_rx_tail<UART_RX_SIZE-1)
{
uart_rx_handle.uart_rx_tail++;
LPUART_DRV_SetRxBuffer(INST_LPUART1, &uart_rx_handle.uart_rxbuff[(uart_rx_handle.uart_rx_tail)%UART_RX_SIZE], 1U);
}
else
{
uart_rx_handle.uart_rx_tail = 0;
}
rx_full_cnt++;
break;
case UART_EVENT_ERROR:
error_cnt++;
break;
case UART_EVENT_END_TRANSFER:
end_cnt++;
break;
default:
break;
}
/* Update the buffer index and the rx buffer */
LPUART_DRV_ReceiveData(INST_LPUART1, &uart_rx_handle.uart_rxbuff[uart_rx_handle.uart_rx_tail%UART_RX_SIZE], 1U);
}
這中斷回調(diào)函數(shù)中這樣接收,為何發(fā)快了會產(chǎn)生錯誤? |