void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if (huart->Instance == USART_UX) /* 如果是串口1 */ { if ((g_usart_rx_sta & 0x8000) == 0) /* 接收未完成 */ { if (g_usart_rx_sta & 0x4000) /* 接收到了0x0d(即回车键) */ { if (g_rx_buffer[0] != 0x0a) /* 接收到的不是0x0a(即不是换行键) */ { g_usart_rx_sta = 0; /* 接收错误,重新开始 */ } else /* 接收到的是0x0a(即换行键) */ { g_usart_rx_sta |= 0x8000; /* 接收完成了 */ } } else /* 还没收到0X0d(即回车键) */ { if (g_rx_buffer[0] == 0x0d) g_usart_rx_sta |= 0x4000; else { g_usart_rx_buf[g_usart_rx_sta & 0X3FFF] = g_rx_buffer[0]; g_usart_rx_sta++; if (g_usart_rx_sta > (USART_REC_LEN - 1)) { g_usart_rx_sta = 0; /* 接收数据错误,重新开始接收 */ } } } } } }
时间: 2023-05-18 21:05:41 浏览: 435
uart.zip_HAL_USART_hal uart_hal usart 中断_hal库 uart
5星 · 资源好评率100%
Sorry, it seems that the code snippet you provided is incomplete. Can you please provide the full code so that I can assist you better?
阅读全文