void USART3_IRQHandler(void) { ? /* USER CODE BEGIN USART3_IRQn 0 */
? /* USER CODE END USART3_IRQn 0 */ ? HAL_UART_IRQHandler(&huart3); ? /* USER CODE BEGIN USART3_IRQn 1 */ ? HAL_UART_IDLE_IRQHandler(&huart3);
? /* USER CODE END USART3_IRQn 1 */ } ?
?void HAL_UART_IDLE_IRQHandler(UART_HandleTypeDef *huart) ?{ ?? ?uint32_t isrflags?? ?= ?READ_REG(huart->Instance->SR);? ?? ?//if((USART_SR_IDLE & isrflags) != RESET && ( huart->RxXferCount > 0)) ?? ?if( __HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE))? ?? ?{ ?? ??? ?__HAL_UART_CLEAR_IDLEFLAG(huart); ?? ? ? /* Disable the UART Data Register not empty Interrupt */ ?? ? ? __HAL_UART_DISABLE_IT(huart, UART_IT_RXNE); ?? ? ? /* Disable the UART Parity Error Interrupt */ ?? ? ? __HAL_UART_DISABLE_IT(huart, UART_IT_PE); ?? ? ? /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */ ?? ? ? __HAL_UART_DISABLE_IT(huart, UART_IT_ERR); ?? ? ? /* Rx process is completed, restore huart->RxState to Ready */ ?? ? ? huart1.RxState = HAL_UART_STATE_READY; ? ?? ? ? HAL_UART_RxCpltCallback(huart);? ?? ?}else if((USART_SR_IDLE & isrflags) != RESET && ( huart->RxXferCount == 0 )) ?? ?{? ?? ??? ?__HAL_UART_CLEAR_IDLEFLAG(huart); ?? ?}? ?}
void uart_rx_setting(UART_HandleTypeDef *huart) {
?? ?if(huart == &huart1) ?? ?{ ?? ??? ?HAL_UART_Receive_DMA(huart, stUart1Rx.rx_buf,MAX_RX_SIZE); ?? ??? ? ?? ?} ?? ?else if(huart == &huart2) ?? ?{ ?? ??? ?HAL_UART_Receive_DMA(huart, stUart2Rx.rx_buf,MAX_RX_SIZE); ?? ?} ?? ?else if(huart == &huart3) ?? ?{ ?? ??? ?HAL_UART_Receive_DMA(huart, stUart3Rx.rx_buf,MAX_RX_SIZE); ?? ?} ?? ?__HAL_UART_ENABLE_IT(huart, UART_IT_IDLE); ?? ?__HAL_UART_CLEAR_FLAG(huart, UART_FLAG_IDLE);
}
?void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { ?? ? ?? ?if(huart == &huart1) ?? ?{ ?? ??? ?test1++; ?? ??? ?stUart1Rx.rx_len = MAX_RX_SIZE - __HAL_DMA_GET_COUNTER(&hdma_usart1_rx); ?? ??? ?stUart1Rx.rx_cnt = stUart1Rx.rx_len; ?? ??? ?stUart1Rx.rx_len = 0; ?? ?} ?? ?else if(huart == &huart2) ?? ?{ ?? ??? ?test2++;
?? ??? ?stUart2Rx.rx_len = MAX_RX_SIZE - __HAL_DMA_GET_COUNTER(&hdma_usart2_rx); ?? ??? ?stUart2Rx.rx_cnt = stUart2Rx.rx_len; ?? ??? ?stUart2Rx.rx_len = 0; ?? ??? ?__HAL_DMA_SET_COUNTER(&hdma_usart2_rx, MAX_RX_SIZE); ?? ?} ?? ?else if(huart == &huart3) ?? ?{
?? ??? ?test3++; ?? ??? ?stUart3Rx.rx_len = MAX_RX_SIZE - __HAL_DMA_GET_COUNTER(&hdma_usart3_rx); ?? ??? ?stUart3Rx.rx_cnt = stUart3Rx.rx_len; ?? ??? ?stUart3Rx.rx_len = 0; ?? ??? ?__HAL_DMA_SET_COUNTER(&hdma_usart3_rx, MAX_RX_SIZE); ?? ?} ?? ?HAL_UART_DMAStop(huart); ?? ?uart_rx_setting(huart); }
?void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) ?{ ?? ? if(huart == &huart1) ?? ? { ?? ??? ? ?? ?? ?? ? } ?? ? else if(huart == &huart2) ?? ? { ?? ?? ?? ? } ?? ? else if(huart == &huart3) ?? ? { ?? ?? ?? ?? ?? ? }
?} ?
|