先判断RTO且RTOR寄存器的RTO是0的例子:
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_RTOF))
{
__HAL_UART_CLEAR_FLAG(&huart1, UART_CLEAR_RTOF);
SET_TEST2;
for(int i = 0; i < 8; i ++)
{
if(!__HAL_UART_GET_FLAG(&huart1, UART_FLAG_RXFNE))
{
break;
}
rxBuf[rxCnt++] = USART1->RDR;
}
RESET_TEST2;
}
if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_RXFT))
{
SET_TEST0;
for(int i = 0; i < 8; i ++)
{
if(!__HAL_UART_GET_FLAG(&huart1, UART_FLAG_RXFNE))
{
break;
}
rxBuf[rxCnt++] = USART1->RDR;
}
RESET_TEST0;
}
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
/* USER CODE END USART1_IRQn 1 */
}
|