为了测试串口互传,在回调函数里添加了以下代码:- void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- UNUSED(Size);
- if(huart->Instance==USART1)
- {
- UART1_Rx_len=Size;
- HAL_UART_Transmit(&huart3,UART1_Rx_buffer,UART1_Rx_len,UART1_Rx_len);
- HAL_UARTEx_ReceiveToIdle_DMA(&huart1,UART1_Rx_buffer,RX_BUF_MAX_LEN);
- }
- else if(huart->Instance==USART3)
- {
- UART3_Rx_len=Size;
- HAL_UART_Transmit(&huart1,UART3_Rx_buffer,UART3_Rx_len,UART3_Rx_len);
- HAL_UARTEx_ReceiveToIdle_DMA(&huart3,UART3_Rx_buffer,RX_BUF_MAX_LEN);
- }
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UARTEx_RxEventCallback can be implemented in the user file.
- */
- }
|