首页 > 代码库 > STM32cube 串口接收任意长度数据

STM32cube 串口接收任意长度数据

void USART3_IRQHandler(void)

{

/* USER CODE BEGIN USART3_IRQn 0 */

uint32_t tmp_flag =0;

uint32_t temp;

tmp_flag = __HAL_UART_GET_FLAG(&huart3,UART_FLAG_IDLE);

if((tmp_flag != RESET))

{

  __HAL_UART_CLEAR_FEFLAG(&huart3);

  temp = huart3.Instance->SR;

  temp = huart3.Instance->DR;

  HAL_UART_DMAStop(&huart3);

  temp=hdma_usart3_rx.Instance->NDTR;

  rx_len = RXSIZE - temp;

  Rx_flag=1;

}

/* USER CODE END USART3_IRQn 0 */

  HAL_UART_IRQHandler(&huart3);

/* USER CODE BEGIN USART3_IRQn 1 */

/* USER CODE END USART3_IRQn 1 */

}

STM32cube 串口接收任意长度数据