2019-07-20 16:47发布
caosix 发表于 2017-2-13 18:19 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if(huart->Instance==UART4)
最多设置5个标签!
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if(huart->Instance==UART4)
{
/* USER CODE BEGIN UART4_MspDeInit 0 */
HAL_UART_Receive_IT(&huart4,(uint8_t *)CD_In,16);
/* USER CODE END UART4_MspDeInit 0 */
}
else if(huart->Instance==UART5)
{
/* USER CODE BEGIN UART5_MspDeInit 0 */
HAL_UART_Receive_IT(&huart5,(uint8_t *)DD_In,16);
/* USER CODE END UART5_MspDeInit 0 */
}
else if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspDeInit 0 */
keychr = key_in[2]; //从液晶屏键盘码 AA+55+key 提取 key 键值
HAL_UART_Receive_IT(&huart1,(uint8_t *)key_in,3);
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_2); //翻转 LED灯 测试之用 。
/* USER CODE END USART1_MspDeInit 0 */
}
else if(huart->Instance==USART2)
{
/* USER CODE BEGIN USART2_MspDeInit 0 */
HAL_UART_Receive_IT(&huart2,(uint8_t *)AD_In,16);
/* USER CODE END USART2_MspDeInit 0 */
}
else if(huart->Instance==USART3)
{
/* USER CODE BEGIN USART3_MspDeInit 0 */
HAL_UART_Receive_IT(&huart3,(uint8_t *)BD_In,16);
/* USER CODE END USART3_MspDeInit 0 */
}
}
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
// printf("error code:%X ",huart->ErrorCode);
if(huart->Instance==UART4)
{
/* USER CODE BEGIN UART4_MspDeInit 0 */
HAL_UART_Receive_IT(&huart4,(uint8_t *)CD_In,16);
/* USER CODE END UART4_MspDeInit 0 */
}
else if(huart->Instance==UART5)
{
/* USER CODE BEGIN UART5_MspDeInit 0 */
HAL_UART_Receive_IT(&huart5,(uint8_t *)DD_In,16);
/* USER CODE END UART5_MspDeInit 0 */
}
else if(huart->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspDeInit 0 */
HAL_Delay(3);
HAL_UART_Receive_IT(&huart1,(uint8_t *)key_in,3);
HAL_Delay(3);
/* USER CODE END USART1_MspDeInit 0 */
}
else if(huart->Instance==USART2)
{
/* USER CODE BEGIN USART2_MspDeInit 0 */
HAL_UART_Receive_IT(&huart2,(uint8_t *)AD_In,16);
/* USER CODE END USART2_MspDeInit 0 */
}
else if(huart->Instance==USART3)
{
/* USER CODE BEGIN USART3_MspDeInit 0 */
HAL_UART_Receive_IT(&huart3,(uint8_t *)BD_In,16);
/* USER CODE END USART3_MspDeInit 0 */
}
}
俺 把 5个 串口 都 用起了,但是 还是觉得 囫囵吞枣 。
就这样 谢谢
一周热门 更多>