void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if(huart->Instance == huart1.Instance)//´®¿Ú1´¥·¢ÖÐ¶Ï { HAL_UART_Receive_IT(&huart1, &uart1_value, 1); uart1_buf[uart1_num++] = uart1_value; uart1_time = 0; } if(huart->Instance == Huart_wifi.Instance)//´®¿Ú´¥·¢ÖÐ¶Ï { if(huart->Instance == Huart_wifi.Instance)//´®¿Ú´¥·¢ { HAL_UART_Receive_IT(&Huart_wifi, &uartwifi_value, 1); if(ESP8266_cnt >= sizeof(ESP8266_buf)) ESP8266_cnt = 0; //·ÀÖ¹´®¿Ú±»Ë¢±¬ ESP8266_buf[ESP8266_cnt++] = uartwifi_value; } } } /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
时间: 2024-02-29 16:56:31 浏览: 146
uart.zip_HAL_USART_hal uart_hal usart 中断_hal库 uart
5星 · 资源好评率100%
这是一个使用HAL库编写的STM32串口接收回调函数。当接收到数据时,该函数会检测是哪个串口接收到了数据,并将数据存储到对应的缓冲区中。其中,第一个if语句用于处理串口1接收到的数据,第二个if语句用于处理另一个名为Huart_wifi的串口接收到的数据。如果发生错误,会调用Error_Handler函数进行处理。此外,该代码还包含了一个断言函数,用于在参数错误时进行报错。
阅读全文