標題: S32K144_Uart串口源程序 [打印本頁] 作者: GXLife 時間: 2019-1-3 12:46 標題: S32K144_Uart串口源程序 S32K144 自身NorFlash讀寫,在NXP官方編譯器S32 Design Studio for ARM Version 2018.R1(需要打補丁跟新到 RTM2.0版SDK)直接編譯。該串口代碼與官方庫不沖突,可繼續(xù)使用官方提供的便利工具,IO和Uart模塊的可視化配置,并且實現Uart方便的中斷接受,不丟失。從FIFO中直接提取數據,改善官方SDK庫效讀取率低,操作不方便等問題。
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);
}