/* Process Locked */
__HAL_LOCK(huart);
huart->pRxBuffPtr = pData;//接收的数据缓存指针
huart->RxXferSize = Size;//接收的最大数据量字节数
huart->RxXferCount = Size;//还剩余的要接收的数据量字节数
huart->ErrorCode = HAL_UART_ERROR_NONE;
huart->RxState = HAL_UART_STATE_BUSY_RX;
/* Process Unlocked */
__HAL_UNLOCK(huart);
/* Enable the UART Parity Error Interrupt */
__HAL_UART_ENABLE_IT(huart, UART_IT_PE);//校验错误中断使能
/* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
__HAL_UART_ENABLE_IT(huart, UART_IT_ERR);//错误中断使能-帧错误,噪错误,满溢错误
/* Enable the UART Data Register not empty Interrupt */
__HAL_UART_ENABLE_IT(huart, UART_IT_RXNE);//接收中断使能【如果串口收到数据,则进入到串口处理函数HAL_UART_IRQHandler】
return HAL_OK;
} |