用到的是DMA发送数据,接收还是普通的串口接收。
/* USER CODE BEGIN 0 */ uint8_t aRxBuffer[1]; uint8_t aTxBuffer[]="ok"; /* USER CODE END 0 */
/* USER CODE BEGIN 2 */ HAL_UART_Receive_IT(&huart1,aRxBuffer,1); HAL_UART_Transmit_DMA(&huart1,aTxBuffer,sizeof(aTxBuffer)); /* USER CODE END 2 */
/* USER CODE BEGIN 4 */ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) { HAL_UART_Transmit(&huart1,aRxBuffer,1,0); HAL_UART_Receive_IT(&huart1,aRxBuffer,1); } /* USER CODE END 4 */
总结:只使用DMA做发送处理,接收还是用了串口接收中断。
原文:https://www.cnblogs.com/lailai-laird/p/12618786.html