BugID:18498796: Fix the error which is reported by XC5
@@ -185,6 +185,11 @@ void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
const PORT_UART_TYPE appPort = GetAppPortFromPhyInstanse(huart->Instance);
UART_MAPPING* uartIns = GetUARTMapping(appPort);
+
+ if (uartIns == NULL) {
+ return;
+ }
+
//Only try to recover the OVER ERR when the UART RCV using normal ISR
if (stm32_uart[appPort].hal_uart_handle.hdmarx == NULL) {
snprintf(error_info,sizeof(error_info),"\n### FATAL UART %d OVER RUN !!!\n",appPort);
@@ -428,6 +433,10 @@ static int32_t uart_receive_it(uart_dev_t *uart, void *data, uint32_t expect_siz
UART_MAPPING* uartIns = GetUARTMapping(uart->port);
+ if (uartIns == NULL) {
+ return ret;
+ }
+
while ( rx_count < expect_size )
{
@@ -522,6 +531,10 @@ static int32_t uart_receive_dma(uart_dev_t *uart, void *data, uint32_t expect_si
UART_MAPPING* uartIns = GetUARTMapping(uart->port);
+ if (uartIns == NULL) {
+ return ret;
+ }
+
if (stm32_uart[uart->port].uart_error_count) {
printf("WARNING : uart %d have already lose %d byte \r\n", uart->port, stm32_uart[uart->port].uart_error_count);
}
@@ -929,9 +942,14 @@ void HAL_UART_IdleCallback(UART_HandleTypeDef *huart)
const PORT_UART_TYPE appPort = GetAppPortFromPhyInstanse(huart->Instance);
UART_MAPPING* uartIns = GetUARTMapping(appPort);
+ if (uartIns == NULL) {
+ return;
+ }
+
if (stm32_uart[appPort].uart_dma_stop) {
- if(stm32_uart[appPort].uart_error_count<0xffffffff)
+ if (stm32_uart[appPort].uart_error_count < 0xffffffff) {
stm32_uart[appPort].uart_error_count++;
+ }
} else {
left_byte = __HAL_DMA_GET_COUNTER(huart->hdmarx);
/* if left_byte=0, means DMA transfer complete interrupt maybe has happened
