obsidian-notes/代码/串口DMA不定长接收.md
CSSC-WORK\murmur 3e6078442b init version
2024-04-15 11:19:57 +08:00

822 B

title updated created tags
串口DMA不定长接收 2022-01-11 01:27:13Z 2022-01-08 13:18:08Z
mcu
串口
代码块

串口不定长接收利用的是串口接收中的空闲中断

处理空闲中断

/**
* @brief This function handles USART1 global interrupt.
*/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
uint32_t flag,tmp;
flag = __HAL_UART_GET_FLAG(&huart1,UART_FLAG_IDLE);
if (flag != RESET) {        
__HAL_UART_CLEAR_IDLEFLAG(&huart1);
tmp = huart1.Instance->SR;
tmp = huart1.Instance->DR;
HAL_UART_DMAStop(&huart1);
tmp = hdma_usart1_rx.Instance->CNDTR;
rxlen = 200 - tmp;
isrxend = 1;
}
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
/* USER CODE END USART1_IRQn 1 */
}
	</div>

#串口 #mcu #代码块