|
楼主 |
发表于 2015-11-6 18:07:56
|
显示全部楼层
大家再看看串口接收的处理函数!
- /**
- * @brief Handle UART interrupt request.
- * @param huart: UART handle.
- * @retval None
- */
- void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
- {
- // /* UART parity error interrupt occurred -------------------------------------*/
- // if((__HAL_UART_GET_IT(huart, UART_IT_PE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_PE) != RESET))
- // {
- // __HAL_UART_CLEAR_IT(huart, UART_CLEAR_PEF);
- //
- // huart->ErrorCode |= HAL_UART_ERROR_PE;
- // /* Set the UART state ready to be able to start again the process */
- // huart->State = HAL_UART_STATE_READY;
- // }
- //
- // /* UART frame error interrupt occurred --------------------------------------*/
- // if((__HAL_UART_GET_IT(huart, UART_IT_FE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR) != RESET))
- // {
- // __HAL_UART_CLEAR_IT(huart, UART_CLEAR_FEF);
- //
- // huart->ErrorCode |= HAL_UART_ERROR_FE;
- // /* Set the UART state ready to be able to start again the process */
- // huart->State = HAL_UART_STATE_READY;
- // }
- //
- // /* UART noise error interrupt occurred --------------------------------------*/
- // if((__HAL_UART_GET_IT(huart, UART_IT_NE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR) != RESET))
- // {
- // __HAL_UART_CLEAR_IT(huart, UART_CLEAR_NEF);
- //
- // huart->ErrorCode |= HAL_UART_ERROR_NE;
- // /* Set the UART state ready to be able to start again the process */
- // huart->State = HAL_UART_STATE_READY;
- // }
- //
- /* UART Over-Run interrupt occurred -----------------------------------------*/
- if((__HAL_UART_GET_IT(huart, UART_IT_ORE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR) != RESET))
- {
- __HAL_UART_CLEAR_IT(huart, UART_CLEAR_OREF);
- // huart->ErrorCode |= HAL_UART_ERROR_ORE;
- // /* Set the UART state ready to be able to start again the process */
- // huart->State = HAL_UART_STATE_READY;
- }
- //
- // /* Call UART Error Call back function if need be --------------------------*/
- // if(huart->ErrorCode != HAL_UART_ERROR_NONE)
- // {
- // HAL_UART_ErrorCallback(huart);
- // }
- //
- // /* UART wakeup from Stop mode interrupt occurred -------------------------------------*/
- // if((__HAL_UART_GET_IT(huart, UART_IT_WUF) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_WUF) != RESET))
- // {
- // __HAL_UART_CLEAR_IT(huart, UART_CLEAR_WUF);
- // /* Set the UART state ready to be able to start again the process */
- // huart->State = HAL_UART_STATE_READY;
- // HAL_UARTEx_WakeupCallback(huart);
- // }
- /* UART in mode Receiver ---------------------------------------------------*/
- if((__HAL_UART_GET_IT(huart, UART_IT_RXNE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_RXNE) != RESET))
- {
- // UART_Receive_IT(huart);
- aRxBuffer[i] = huart->Instance->RDR;
- i++;
- // xTimerResetFromISR(USART1_RX_TimeOut_Tmr,0);
- /* Clear RXNE interrupt flag */
- __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
- }
- // /* UART in mode Transmitter ------------------------------------------------*/
- // if((__HAL_UART_GET_IT(huart, UART_IT_TXE) != RESET) &&(__HAL_UART_GET_IT_SOURCE(huart, UART_IT_TXE) != RESET))
- // {
- // UART_Transmit_IT(huart);
- // }
- //
- // /* UART in mode Transmitter (transmission end) -----------------------------*/
- // if((__HAL_UART_GET_IT(huart, UART_IT_TC) != RESET) &&(__HAL_UART_GET_IT_SOURCE(huart, UART_IT_TC) != RESET))
- // {
- // UART_EndTransmit_IT(huart);
- // }
- }
复制代码
|
|