text: /**
    ******************************************************************************
    * File Name          : USART.c
    * Description        : This file provides code for the configuration
    *                      of the USART instances.
    ******************************************************************************
    * @attention
    *
    * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
    * All rights reserved.</center></h2>
    *
    * This software component is licensed by ST under BSD 3-Clause license,
    * the "License"; You may not use this file except in compliance with the
    * License. You may obtain a copy of the License at:
    *                        opensource.org/licenses/BSD-3-Clause
    *
    ******************************************************************************
    */
  
  /* Includes ------------------------------------------------------------------*/
  #include "usart.h"
  
  /* USER CODE BEGIN 0 */
  
  /* USER CODE END 0 */
  
  UART_HandleTypeDef hlpuart1;
  UART_HandleTypeDef huart1;
  UART_HandleTypeDef huart3;
  
  /* LPUART1 init function */
  
  void MX_LPUART1_UART_Init(void)
  {
  
    hlpuart1.Instance = LPUART1;
    hlpuart1.Init.BaudRate = 115200;
    hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
    hlpuart1.Init.StopBits = UART_STOPBITS_1;
    hlpuart1.Init.Parity = UART_PARITY_NONE;
    hlpuart1.Init.Mode = UART_MODE_TX_RX;
    hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
    hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
    if (HAL_UART_Init(&hlpuart1) != HAL_OK)
    {
      Error_Handler();
    }
  
  }
  /* USART1 init function */
  
  void MX_USART1_UART_Init(void)
  {
  
    huart1.Instance = USART1;
    huart1.Init.BaudRate = 115200;
    huart1.Init.WordLength = UART_WORDLENGTH_8B;
    huart1.Init.StopBits = UART_STOPBITS_1;
    huart1.Init.Parity = UART_PARITY_NONE;
    huart1.Init.Mode = UART_MODE_TX_RX;
    huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart1.Init.OverSampling = UART_OVERSAMPLING_16;
    huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
    huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
    if (HAL_UART_Init(&huart1) != HAL_OK)
    {
      Error_Handler();
    }
  
  }
  /* USART3 init function */
  
  void MX_USART3_UART_Init(void)
  {
  
    huart3.Instance = USART3;
    huart3.Init.BaudRate = 115200;
    huart3.Init.WordLength = UART_WORDLENGTH_8B;
    huart3.Init.StopBits = UART_STOPBITS_1;
    huart3.Init.Parity = UART_PARITY_NONE;
    huart3.Init.Mode = UART_MODE_TX_RX;
    huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart3.Init.OverSampling = UART_OVERSAMPLING_16;
    huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
    huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
    if (HAL_UART_Init(&huart3) != HAL_OK)
    {
      Error_Handler();
    }
  
  }
  
  void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
  {
  
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    if(uartHandle->Instance==LPUART1)
    {
    /* USER CODE BEGIN LPUART1_MspInit 0 */
  
    /* USER CODE END LPUART1_MspInit 0 */
      /* LPUART1 clock enable */
      __HAL_RCC_LPUART1_CLK_ENABLE();
    
      __HAL_RCC_GPIOB_CLK_ENABLE();
      /**LPUART1 GPIO Configuration    
      PB10     ------> LPUART1_RX
      PB11     ------> LPUART1_TX 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  
    /* USER CODE BEGIN LPUART1_MspInit 1 */
  
    /* USER CODE END LPUART1_MspInit 1 */
    }
    else if(uartHandle->Instance==USART1)
    {
    /* USER CODE BEGIN USART1_MspInit 0 */
  
    /* USER CODE END USART1_MspInit 0 */
      /* USART1 clock enable */
      __HAL_RCC_USART1_CLK_ENABLE();
    
      __HAL_RCC_GPIOA_CLK_ENABLE();
      /**USART1 GPIO Configuration    
      PA9     ------> USART1_TX
      PA10     ------> USART1_RX 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
    /* USER CODE BEGIN USART1_MspInit 1 */
  
    /* USER CODE END USART1_MspInit 1 */
    }
    else if(uartHandle->Instance==USART3)
    {
    /* USER CODE BEGIN USART3_MspInit 0 */
  
    /* USER CODE END USART3_MspInit 0 */
      /* USART3 clock enable */
      __HAL_RCC_USART3_CLK_ENABLE();
    
      __HAL_RCC_GPIOC_CLK_ENABLE();
      /**USART3 GPIO Configuration    
      PC4     ------> USART3_TX
      PC5     ------> USART3_RX 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
      HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  
    /* USER CODE BEGIN USART3_MspInit 1 */
  
    /* USER CODE END USART3_MspInit 1 */
    }
  }
  
  void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
  {
  
    if(uartHandle->Instance==LPUART1)
    {
    /* USER CODE BEGIN LPUART1_MspDeInit 0 */
  
    /* USER CODE END LPUART1_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_LPUART1_CLK_DISABLE();
    
      /**LPUART1 GPIO Configuration    
      PB10     ------> LPUART1_RX
      PB11     ------> LPUART1_TX 
      */
      HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
  
      /* LPUART1 interrupt Deinit */
      HAL_NVIC_DisableIRQ(LPUART1_IRQn);
    /* USER CODE BEGIN LPUART1_MspDeInit 1 */
  
    /* USER CODE END LPUART1_MspDeInit 1 */
    }
    else if(uartHandle->Instance==USART1)
    {
    /* USER CODE BEGIN USART1_MspDeInit 0 */
  
    /* USER CODE END USART1_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_USART1_CLK_DISABLE();
    
      /**USART1 GPIO Configuration    
      PA9     ------> USART1_TX
      PA10     ------> USART1_RX 
      */
      HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
  
    /* USER CODE BEGIN USART1_MspDeInit 1 */
  
    /* USER CODE END USART1_MspDeInit 1 */
    }
    else if(uartHandle->Instance==USART3)
    {
    /* USER CODE BEGIN USART3_MspDeInit 0 */
  
    /* USER CODE END USART3_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_USART3_CLK_DISABLE();
    
      /**USART3 GPIO Configuration    
      PC4     ------> USART3_TX
      PC5     ------> USART3_RX 
      */
      HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4|GPIO_PIN_5);
  
    /* USER CODE BEGIN USART3_MspDeInit 1 */
  
    /* USER CODE END USART3_MspDeInit 1 */
    }
  } 
  
  /* USER CODE BEGIN 1 */
  
  /* USER CODE END 1 */
  
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  