text: /* USER CODE BEGIN Header */
  /**
    ******************************************************************************
    * File Name          : stm32h7xx_hal_msp.c
    * Description        : This file provides code for the MSP Initialization 
    *                      and de-Initialization codes.
    ******************************************************************************
    * @attention
    *
    * <h2><center>&copy; Copyright (c) 2019 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
    *
    ******************************************************************************
    */
  /* USER CODE END Header */
  
  /* Includes ------------------------------------------------------------------*/
  #include "main.h"
  /* USER CODE BEGIN Includes */
  
  /* USER CODE END Includes */
  
  /* Private typedef -----------------------------------------------------------*/
  /* USER CODE BEGIN TD */
  
  /* USER CODE END TD */
  
  /* Private define ------------------------------------------------------------*/
  /* USER CODE BEGIN Define */
   
  /* USER CODE END Define */
  
  /* Private macro -------------------------------------------------------------*/
  /* USER CODE BEGIN Macro */
  
  /* USER CODE END Macro */
  
  /* Private variables ---------------------------------------------------------*/
  /* USER CODE BEGIN PV */
  
  /* USER CODE END PV */
  
  /* Private function prototypes -----------------------------------------------*/
  /* USER CODE BEGIN PFP */
  
  /* USER CODE END PFP */
  
  /* External functions --------------------------------------------------------*/
  /* USER CODE BEGIN ExternalFunctions */
  
  /* USER CODE END ExternalFunctions */
  
  /* USER CODE BEGIN 0 */
  
  /* USER CODE END 0 */
  /**
    * Initializes the Global MSP.
    */
  void HAL_MspInit(void)
  {
    /* USER CODE BEGIN MspInit 0 */
  
    /* USER CODE END MspInit 0 */
  
    __HAL_RCC_SYSCFG_CLK_ENABLE();
  
    /* System interrupt init*/
  
    /* USER CODE BEGIN MspInit 1 */
  
    /* USER CODE END MspInit 1 */
  }
  
  static uint32_t HAL_RCC_ADC12_CLK_ENABLED=0;
  
  /**
  * @brief ADC MSP Initialization
  * This function configures the hardware resources used in this example
  * @param hadc: ADC handle pointer
  * @retval None
  */
  void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
  {
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    if(hadc->Instance==ADC1)
    {
    /* USER CODE BEGIN ADC1_MspInit 0 */
  
    /* USER CODE END ADC1_MspInit 0 */
      /* Peripheral clock enable */
      HAL_RCC_ADC12_CLK_ENABLED++;
      if(HAL_RCC_ADC12_CLK_ENABLED==1){
        __HAL_RCC_ADC12_CLK_ENABLE();
      }
    
      __HAL_RCC_GPIOA_CLK_ENABLE();
      __HAL_RCC_GPIOB_CLK_ENABLE();
      /**ADC1 GPIO Configuration    
      PA6     ------> ADC1_INP3
      PB0     ------> ADC1_INP9
      PB1     ------> ADC1_INP5 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_6;
      GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
      GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
      GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  
    /* USER CODE BEGIN ADC1_MspInit 1 */
  
    /* USER CODE END ADC1_MspInit 1 */
    }
    else if(hadc->Instance==ADC2)
    {
    /* USER CODE BEGIN ADC2_MspInit 0 */
  
    /* USER CODE END ADC2_MspInit 0 */
      /* Peripheral clock enable */
      HAL_RCC_ADC12_CLK_ENABLED++;
      if(HAL_RCC_ADC12_CLK_ENABLED==1){
        __HAL_RCC_ADC12_CLK_ENABLE();
      }
    
      __HAL_RCC_GPIOA_CLK_ENABLE();
      /**ADC2 GPIO Configuration    
      PA3     ------> ADC2_INP15
      PA4     ------> ADC2_INP18
      PA5     ------> ADC2_INP19 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
      GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
    /* USER CODE BEGIN ADC2_MspInit 1 */
  
    /* USER CODE END ADC2_MspInit 1 */
    }
    else if(hadc->Instance==ADC3)
    {
    /* USER CODE BEGIN ADC3_MspInit 0 */
  
    /* USER CODE END ADC3_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_ADC3_CLK_ENABLE();
      __HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP);
  
      __HAL_RCC_GPIOF_CLK_ENABLE();
      /**ADC3 GPIO Configuration    
      PF10     ------> ADC3_INP6 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_10;
      GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  
    /* USER CODE BEGIN ADC3_MspInit 1 */
  
    /* USER CODE END ADC3_MspInit 1 */
    }
  
  }
  
  /**
  * @brief ADC MSP De-Initialization
  * This function freeze the hardware resources used in this example
  * @param hadc: ADC handle pointer
  * @retval None
  */
  void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
  {
    if(hadc->Instance==ADC1)
    {
    /* USER CODE BEGIN ADC1_MspDeInit 0 */
  
    /* USER CODE END ADC1_MspDeInit 0 */
      /* Peripheral clock disable */
      HAL_RCC_ADC12_CLK_ENABLED--;
      if(HAL_RCC_ADC12_CLK_ENABLED==0){
        __HAL_RCC_ADC12_CLK_DISABLE();
      }
    
      /**ADC1 GPIO Configuration    
      PA6     ------> ADC1_INP3
      PB0     ------> ADC1_INP9
      PB1     ------> ADC1_INP5 
      */
      HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6);
  
      HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1);
  
    /* USER CODE BEGIN ADC1_MspDeInit 1 */
  
    /* USER CODE END ADC1_MspDeInit 1 */
    }
    else if(hadc->Instance==ADC2)
    {
    /* USER CODE BEGIN ADC2_MspDeInit 0 */
  
    /* USER CODE END ADC2_MspDeInit 0 */
      /* Peripheral clock disable */
      HAL_RCC_ADC12_CLK_ENABLED--;
      if(HAL_RCC_ADC12_CLK_ENABLED==0){
        __HAL_RCC_ADC12_CLK_DISABLE();
      }
    
      /**ADC2 GPIO Configuration    
      PA3     ------> ADC2_INP15
      PA4     ------> ADC2_INP18
      PA5     ------> ADC2_INP19 
      */
      HAL_GPIO_DeInit(GPIOA, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);
  
    /* USER CODE BEGIN ADC2_MspDeInit 1 */
  
    /* USER CODE END ADC2_MspDeInit 1 */
    }
    else if(hadc->Instance==ADC3)
    {
    /* USER CODE BEGIN ADC3_MspDeInit 0 */
  
    /* USER CODE END ADC3_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_ADC3_CLK_DISABLE();
    
      /**ADC3 GPIO Configuration    
      PF10     ------> ADC3_INP6 
      */
      HAL_GPIO_DeInit(GPIOF, GPIO_PIN_10);
  
    /* USER CODE BEGIN ADC3_MspDeInit 1 */
  
    /* USER CODE END ADC3_MspDeInit 1 */
    }
  
  }
  
  /**
  * @brief ETH MSP Initialization
  * This function configures the hardware resources used in this example
  * @param heth: ETH handle pointer
  * @retval None
  */
  void HAL_ETH_MspInit(ETH_HandleTypeDef* heth)
  {
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    if(heth->Instance==ETH)
    {
    /* USER CODE BEGIN ETH_MspInit 0 */
  
    /* USER CODE END ETH_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_ETH1MAC_CLK_ENABLE();
      __HAL_RCC_ETH1TX_CLK_ENABLE();
      __HAL_RCC_ETH1RX_CLK_ENABLE();
    
      __HAL_RCC_GPIOC_CLK_ENABLE();
      __HAL_RCC_GPIOA_CLK_ENABLE();
      __HAL_RCC_GPIOB_CLK_ENABLE();
      /**ETH GPIO Configuration    
      PC1     ------> ETH_MDC
      PA1     ------> ETH_REF_CLK
      PA2     ------> ETH_MDIO
      PA7     ------> ETH_CRS_DV
      PC4     ------> ETH_RXD0
      PC5     ------> ETH_RXD1
      PB11     ------> ETH_TX_EN
      PB12     ------> ETH_TXD0
      PB13     ------> ETH_TXD1 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_PULLUP;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
      HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  
      GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
      
      GPIO_InitStruct.Pin = GPIO_PIN_1;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_PULLDOWN;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);    
      
  
      GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  
    /* USER CODE BEGIN ETH_MspInit 1 */
  
    /* USER CODE END ETH_MspInit 1 */
    }
  
  }
  
  /**
  * @brief ETH MSP De-Initialization
  * This function freeze the hardware resources used in this example
  * @param heth: ETH handle pointer
  * @retval None
  */
  void HAL_ETH_MspDeInit(ETH_HandleTypeDef* heth)
  {
    if(heth->Instance==ETH)
    {
    /* USER CODE BEGIN ETH_MspDeInit 0 */
  
    /* USER CODE END ETH_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_ETH1MAC_CLK_DISABLE();
      __HAL_RCC_ETH1TX_CLK_DISABLE();
      __HAL_RCC_ETH1RX_CLK_DISABLE();
    
      /**ETH GPIO Configuration    
      PC1     ------> ETH_MDC
      PA1     ------> ETH_REF_CLK
      PA2     ------> ETH_MDIO
      PA7     ------> ETH_CRS_DV
      PC4     ------> ETH_RXD0
      PC5     ------> ETH_RXD1
      PB11     ------> ETH_TX_EN
      PB12     ------> ETH_TXD0
      PB13     ------> ETH_TXD1 
      */
      HAL_GPIO_DeInit(GPIOC, GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5);
  
      HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7);
  
      HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13);
  
    /* USER CODE BEGIN ETH_MspDeInit 1 */
  
    /* USER CODE END ETH_MspDeInit 1 */
    }
  
  }
  
  /**
  * @brief QSPI MSP Initialization
  * This function configures the hardware resources used in this example
  * @param hqspi: QSPI handle pointer
  * @retval None
  */
  void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)
  {
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    if(hqspi->Instance==QUADSPI)
    {
    /* USER CODE BEGIN QUADSPI_MspInit 0 */
  
    /* USER CODE END QUADSPI_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_QSPI_CLK_ENABLE();
    
      __HAL_RCC_GPIOF_CLK_ENABLE();
      __HAL_RCC_GPIOB_CLK_ENABLE();
      /**QUADSPI GPIO Configuration    
      PF6     ------> QUADSPI_BK1_IO3
      PF7     ------> QUADSPI_BK1_IO2
      PF8     ------> QUADSPI_BK1_IO0
      PF9     ------> QUADSPI_BK1_IO1
      PB2     ------> QUADSPI_CLK
      PB10     ------> QUADSPI_BK1_NCS 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
      HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  
      GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
      HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  
      GPIO_InitStruct.Pin = GPIO_PIN_2|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_AF9_QUADSPI;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
      
      GPIO_InitStruct.Pin = GPIO_PIN_10;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_PULLUP;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
      GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  
    /* USER CODE BEGIN QUADSPI_MspInit 1 */
  
    /* USER CODE END QUADSPI_MspInit 1 */
    }
  
  }
  
  /**
  * @brief QSPI MSP De-Initialization
  * This function freeze the hardware resources used in this example
  * @param hqspi: QSPI handle pointer
  * @retval None
  */
  void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi)
  {
    if(hqspi->Instance==QUADSPI)
    {
    /* USER CODE BEGIN QUADSPI_MspDeInit 0 */
  
    /* USER CODE END QUADSPI_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_QSPI_CLK_DISABLE();
    
      /**QUADSPI GPIO Configuration    
      PF6     ------> QUADSPI_BK1_IO3
      PF7     ------> QUADSPI_BK1_IO2
      PF8     ------> QUADSPI_BK1_IO0
      PF9     ------> QUADSPI_BK1_IO1
      PB2     ------> QUADSPI_CLK
      PB10     ------> QUADSPI_BK1_NCS 
      */
      HAL_GPIO_DeInit(GPIOF, GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9);
  
      HAL_GPIO_DeInit(GPIOB, GPIO_PIN_2|GPIO_PIN_10);
  
    /* USER CODE BEGIN QUADSPI_MspDeInit 1 */
  
    /* USER CODE END QUADSPI_MspDeInit 1 */
    }
  
  }
  
  /**
  * @brief RTC MSP Initialization
  * This function configures the hardware resources used in this example
  * @param hrtc: RTC handle pointer
  * @retval None
  */
  void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
  {
    if(hrtc->Instance==RTC)
    {
    /* USER CODE BEGIN RTC_MspInit 0 */
  
    /* USER CODE END RTC_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_RTC_ENABLE();
    /* USER CODE BEGIN RTC_MspInit 1 */
  
    /* USER CODE END RTC_MspInit 1 */
    }
  
  }
  
  /**
  * @brief RTC MSP De-Initialization
  * This function freeze the hardware resources used in this example
  * @param hrtc: RTC handle pointer
  * @retval None
  */
  void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
  {
    if(hrtc->Instance==RTC)
    {
    /* USER CODE BEGIN RTC_MspDeInit 0 */
  
    /* USER CODE END RTC_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_RTC_DISABLE();
    /* USER CODE BEGIN RTC_MspDeInit 1 */
  
    /* USER CODE END RTC_MspDeInit 1 */
    }
  
  }
  
  /**
  * @brief TIM_Base MSP Initialization
  * This function configures the hardware resources used in this example
  * @param htim_base: TIM_Base handle pointer
  * @retval None
  */
  void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  {
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    if(htim_base->Instance==TIM1)
    {
    /* USER CODE BEGIN TIM1_MspInit 0 */
  
    /* USER CODE END TIM1_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_TIM1_CLK_ENABLE();
    
      __HAL_RCC_GPIOA_CLK_ENABLE();
      /**TIM1 GPIO Configuration    
      PA9     ------> TIM1_CH2
      PA10     ------> TIM1_CH3
      PA11     ------> TIM1_CH4
      PA12     ------> TIM1_ETR 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
      GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
    /* USER CODE BEGIN TIM1_MspInit 1 */
  
    /* USER CODE END TIM1_MspInit 1 */
    }
  
  }
  
  /**
  * @brief TIM_Base MSP De-Initialization
  * This function freeze the hardware resources used in this example
  * @param htim_base: TIM_Base handle pointer
  * @retval None
  */
  void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
  {
    if(htim_base->Instance==TIM1)
    {
    /* USER CODE BEGIN TIM1_MspDeInit 0 */
  
    /* USER CODE END TIM1_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_TIM1_CLK_DISABLE();
    
      /**TIM1 GPIO Configuration    
      PA9     ------> TIM1_CH2
      PA10     ------> TIM1_CH3
      PA11     ------> TIM1_CH4
      PA12     ------> TIM1_ETR 
      */
      HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12);
  
    /* USER CODE BEGIN TIM1_MspDeInit 1 */
  
    /* USER CODE END TIM1_MspDeInit 1 */
    }
  
  }
  
  /**
  * @brief UART MSP Initialization
  * This function configures the hardware resources used in this example
  * @param huart: UART handle pointer
  * @retval None
  */
  void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  {
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    if(huart->Instance==USART1)
    {
    /* USER CODE BEGIN USART1_MspInit 0 */
  
    /* USER CODE END USART1_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_USART1_CLK_ENABLE();
    
      __HAL_RCC_GPIOB_CLK_ENABLE();
      /**USART1 GPIO Configuration    
      PB14     ------> USART1_TX
      PB15     ------> USART1_RX 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
      GPIO_InitStruct.Alternate = GPIO_AF4_USART1;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  
    /* USER CODE BEGIN USART1_MspInit 1 */
  
    /* USER CODE END USART1_MspInit 1 */
    }
    else if(huart->Instance==USART2)
    {
    /* USER CODE BEGIN USART2_MspInit 0 */
  
    /* USER CODE END USART2_MspInit 0 */
      /* Peripheral clock enable */
      __HAL_RCC_USART2_CLK_ENABLE();
    
      __HAL_RCC_GPIOD_CLK_ENABLE();
      /**USART2 GPIO Configuration    
      PD4     ------> USART2_DE
      PD5     ------> USART2_TX
      PD6     ------> USART2_RX 
      */
      GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
      GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
      GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
      HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  
    /* USER CODE BEGIN USART2_MspInit 1 */
  
    /* USER CODE END USART2_MspInit 1 */
    }
  
  }
  
  /**
  * @brief UART MSP De-Initialization
  * This function freeze the hardware resources used in this example
  * @param huart: UART handle pointer
  * @retval None
  */
  void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  {
    if(huart->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    
      PB14     ------> USART1_TX
      PB15     ------> USART1_RX 
      */
      HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15);
  
    /* USER CODE BEGIN USART1_MspDeInit 1 */
  
    /* USER CODE END USART1_MspDeInit 1 */
    }
    else if(huart->Instance==USART2)
    {
    /* USER CODE BEGIN USART2_MspDeInit 0 */
  
    /* USER CODE END USART2_MspDeInit 0 */
      /* Peripheral clock disable */
      __HAL_RCC_USART2_CLK_DISABLE();
    
      /**USART2 GPIO Configuration    
      PD4     ------> USART2_DE
      PD5     ------> USART2_TX
      PD6     ------> USART2_RX 
      */
      HAL_GPIO_DeInit(GPIOD, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6);
  
    /* USER CODE BEGIN USART2_MspDeInit 1 */
  
    /* USER CODE END USART2_MspDeInit 1 */
    }
  
  }
  
  static uint32_t FMC_Initialized = 0;
  
  static void HAL_FMC_MspInit(void){
    /* USER CODE BEGIN FMC_MspInit 0 */
  
    /* USER CODE END FMC_MspInit 0 */
    GPIO_InitTypeDef GPIO_InitStruct ={0};
    if (FMC_Initialized) {
      return;
    }
    FMC_Initialized = 1;
  
    /* Peripheral clock enable */
    __HAL_RCC_FMC_CLK_ENABLE();
    
    /** FMC GPIO Configuration  
    PF0   ------> FMC_A0
    PF1   ------> FMC_A1
    PF2   ------> FMC_A2
    PF3   ------> FMC_A3
    PF4   ------> FMC_A4
    PF5   ------> FMC_A5
    PC0   ------> FMC_SDNWE
    PC2_C   ------> FMC_SDNE0
    PC3_C   ------> FMC_SDCKE0
    PF11   ------> FMC_SDNRAS
    PF12   ------> FMC_A6
    PF13   ------> FMC_A7
    PF14   ------> FMC_A8
    PF15   ------> FMC_A9
    PG0   ------> FMC_A10
    PG1   ------> FMC_A11
    PE7   ------> FMC_D4
    PE8   ------> FMC_D5
    PE9   ------> FMC_D6
    PE10   ------> FMC_D7
    PE11   ------> FMC_D8
    PE12   ------> FMC_D9
    PE13   ------> FMC_D10
    PE14   ------> FMC_D11
    PE15   ------> FMC_D12
    PD8   ------> FMC_D13
    PD9   ------> FMC_D14
    PD10   ------> FMC_D15
    PD14   ------> FMC_D0
    PD15   ------> FMC_D1
    PG2   ------> FMC_A12
    PG4   ------> FMC_BA0
    PG5   ------> FMC_BA1
    PG8   ------> FMC_SDCLK
    PD0   ------> FMC_D2
    PD1   ------> FMC_D3
    PG15   ------> FMC_SDNCAS
    PE0   ------> FMC_NBL0
    PE1   ------> FMC_NBL1
    */
    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 
                            |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 
                            |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
    HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  
    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  
    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4 
                            |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
    HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  
    GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 
                            |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
                            |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  
    GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 
                            |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  
    /* USER CODE BEGIN FMC_MspInit 1 */
  
    /* USER CODE END FMC_MspInit 1 */
  }
  
  void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){
    /* USER CODE BEGIN SDRAM_MspInit 0 */
  
    /* USER CODE END SDRAM_MspInit 0 */
    HAL_FMC_MspInit();
    /* USER CODE BEGIN SDRAM_MspInit 1 */
  
    /* USER CODE END SDRAM_MspInit 1 */
  }
  
  static uint32_t FMC_DeInitialized = 0;
  
  static void HAL_FMC_MspDeInit(void){
    /* USER CODE BEGIN FMC_MspDeInit 0 */
  
    /* USER CODE END FMC_MspDeInit 0 */
    if (FMC_DeInitialized) {
      return;
    }
    FMC_DeInitialized = 1;
    /* Peripheral clock enable */
    __HAL_RCC_FMC_CLK_DISABLE();
    
    /** FMC GPIO Configuration  
    PF0   ------> FMC_A0
    PF1   ------> FMC_A1
    PF2   ------> FMC_A2
    PF3   ------> FMC_A3
    PF4   ------> FMC_A4
    PF5   ------> FMC_A5
    PC0   ------> FMC_SDNWE
    PC2_C   ------> FMC_SDNE0
    PC3_C   ------> FMC_SDCKE0
    PF11   ------> FMC_SDNRAS
    PF12   ------> FMC_A6
    PF13   ------> FMC_A7
    PF14   ------> FMC_A8
    PF15   ------> FMC_A9
    PG0   ------> FMC_A10
    PG1   ------> FMC_A11
    PE7   ------> FMC_D4
    PE8   ------> FMC_D5
    PE9   ------> FMC_D6
    PE10   ------> FMC_D7
    PE11   ------> FMC_D8
    PE12   ------> FMC_D9
    PE13   ------> FMC_D10
    PE14   ------> FMC_D11
    PE15   ------> FMC_D12
    PD8   ------> FMC_D13
    PD9   ------> FMC_D14
    PD10   ------> FMC_D15
    PD14   ------> FMC_D0
    PD15   ------> FMC_D1
    PG2   ------> FMC_A12
    PG4   ------> FMC_BA0
    PG5   ------> FMC_BA1
    PG8   ------> FMC_SDCLK
    PD0   ------> FMC_D2
    PD1   ------> FMC_D3
    PG15   ------> FMC_SDNCAS
    PE0   ------> FMC_NBL0
    PE1   ------> FMC_NBL1
    */
    HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 
                            |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 
                            |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
  
    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3);
  
    HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4 
                            |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15);
  
    HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 
                            |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
                            |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
  
    HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 
                            |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
  
    /* USER CODE BEGIN FMC_MspDeInit 1 */
  
    /* USER CODE END FMC_MspDeInit 1 */
  }
  
  void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){
    /* USER CODE BEGIN SDRAM_MspDeInit 0 */
  
    /* USER CODE END SDRAM_MspDeInit 0 */
    HAL_FMC_MspDeInit();
    /* USER CODE BEGIN SDRAM_MspDeInit 1 */
  
    /* USER CODE END SDRAM_MspDeInit 1 */
  }
  
  /* USER CODE BEGIN 1 */
  
  /* USER CODE END 1 */
  
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  