f767 中串口怎么定义多个?它是用回调函数。回调函数又不能多次使用

2019-07-20 16:47发布

本帖最后由 18784506782 于 2016-12-30 20:03 编辑


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
taizonglai
1楼-- · 2019-07-20 21:09
 精彩回答 2  元偷偷看……
caosix
2楼-- · 2019-07-21 00:22

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个 串口 都 用起了,但是 还是觉得 囫囵吞枣 。
18784506782
3楼-- · 2019-07-21 01:54
caosix 发表于 2017-2-13 18:19
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
  if(huart->Instance==UART4)

就这样 谢谢

一周热门 更多>