text: /* USER CODE BEGIN Header */
  /**
    ******************************************************************************
    * @file    Examples/ADC/ADC_SingleConversion_TriggerTimer_DMA/Src/main.c
    * @author  MCD Application Team
    * @brief   Use ADC to convert a single channel at each trig from timer.
    *          Conversion data are transferred by DMA into a table,
    *          indefinitely (circular mode).
    *          Example using the STM32L5xx ADC HAL API.
    ******************************************************************************
    * @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"
  
  /* Private includes ----------------------------------------------------------*/
  /* USER CODE BEGIN Includes */
  
  /* USER CODE END Includes */
  
  /* Private typedef -----------------------------------------------------------*/
  /* USER CODE BEGIN PTD */
  
  /* USER CODE END PTD */
  
  /* Private define ------------------------------------------------------------*/
  /* USER CODE BEGIN PD */
  
  /* USER CODE END PD */
  
  /* Private macro -------------------------------------------------------------*/
  /* USER CODE BEGIN PM */
  
  /* USER CODE END PM */
  
  /* Private variables ---------------------------------------------------------*/
  ADC_HandleTypeDef hadc1;
  DMA_HandleTypeDef hdma_adc1;
  
  DAC_HandleTypeDef hdac1;
  
  TIM_HandleTypeDef htim2;
  
  /* USER CODE BEGIN PV */
  
  /* Variables for ADC conversion data */
  __IO   uint16_t   aADCxConvertedData[ADC_CONVERTED_DATA_BUFFER_SIZE]; /* ADC group regular conversion data (array of data) */
  
  /* Variables for ADC conversion data computation to physical values */
  uint16_t   aADCxConvertedData_Voltage_mVolt[ADC_CONVERTED_DATA_BUFFER_SIZE];  /* Value of voltage calculated from ADC conversion data (unit: mV) (array of data) */
  
  /* Variable to report status of DMA transfer of ADC group regular conversions */
  /*  0: DMA transfer is not completed                                          */
  /*  1: DMA transfer is completed                                              */
  /*  2: DMA transfer has not yet been started yet (initial state)              */
  __IO   uint8_t ubDmaTransferStatus = 2; /* Variable set into DMA interruption callback */
  
  /* Variable to manage push button on board: interface between ExtLine interruption and main program */
  __IO   uint8_t ubUserButtonClickEvent = RESET;  /* Event detection: Set after User Button interrupt */
  
  /* USER CODE END PV */
  
  /* Private function prototypes -----------------------------------------------*/
  void SystemClock_Config(void);
  static void MX_ICACHE_Init(void);
  static void MX_GPIO_Init(void);
  static void MX_DMA_Init(void);
  static void MX_DAC1_Init(void);
  static void MX_TIM2_Init(void);
  static void MX_ADC1_Init(void);
  /* USER CODE BEGIN PFP */
  /* Private function prototypes -----------------------------------------------*/
  static void Generate_waveform_SW_update_Config(void);
  static void Generate_waveform_SW_update(void);
  /* USER CODE END PFP */
  
  /* Private user code ---------------------------------------------------------*/
  /* USER CODE BEGIN 0 */
  
  /* USER CODE END 0 */
  
  /**
    * @brief  The application entry point.
    * @retval int
    */
  int main(void)
  {
    /* USER CODE BEGIN 1 */
    uint32_t tmp_index_adc_converted_data = 0;
    /* USER CODE END 1 */
  
    /* MCU Configuration--------------------------------------------------------*/
  
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();
  
    /* USER CODE BEGIN Init */
  
    /* USER CODE END Init */
  
    /* Configure the system clock */
    SystemClock_Config();
  
    /* USER CODE BEGIN SysInit */
  
    /* USER CODE END SysInit */
  
    /* Initialize all configured peripherals */
    MX_ICACHE_Init();
    MX_GPIO_Init();
    MX_DMA_Init();
    MX_DAC1_Init();
    MX_TIM2_Init();
    MX_ADC1_Init();
    /* USER CODE BEGIN 2 */
    for (tmp_index_adc_converted_data = 0; tmp_index_adc_converted_data < ADC_CONVERTED_DATA_BUFFER_SIZE; tmp_index_adc_converted_data++)
    {
      aADCxConvertedData[tmp_index_adc_converted_data] = VAR_CONVERTED_DATA_INIT_VALUE;
    }
    
    /* Initialize LED on board */
    BSP_LED_Init(LED1);
    
    /* Configure User push-button in Interrupt mode */
    BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);
    
    /* Run the ADC calibration in single-ended mode */
    if (HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED) != HAL_OK)
    {
      /* Calibration Error */
      Error_Handler();
    }
  
    /* Configure the DAC peripheral and generate a constant voltage of Vdda/2.  */
    Generate_waveform_SW_update_Config();
    /* USER CODE END 2 */
  
    /* Infinite loop */
    /* USER CODE BEGIN WHILE */
    /*## Enable Timer ########################################################*/
    if (HAL_TIM_Base_Start(&htim2) != HAL_OK)
    {
      /* Counter enable error */
      Error_Handler();
    }
    
    /*## Start ADC conversions ###############################################*/
    /* Start ADC group regular conversion with DMA */
    if (HAL_ADC_Start_DMA(&hadc1,
                          (uint32_t *)aADCxConvertedData,
                          ADC_CONVERTED_DATA_BUFFER_SIZE
                         ) != HAL_OK)
    {
      /* ADC conversion start error */
      Error_Handler();
    }  
    
    while (1)
    {
      /* Modifies modifies the voltage level, to generate a waveform circular,  */
      /* shape of ramp: Voltage is increasing at each press on push button,     */
      /* from 0 to maximum range (Vdda) in 4 steps, then starting back from 0V. */
      /* Voltage is updated incrementally at each call of this function.        */
      Generate_waveform_SW_update();
      
      /* Wait for event on push button to perform following actions */
      while ((ubUserButtonClickEvent) == RESET)
      {
      }
      /* Reset variable for next loop iteration (with debounce) */
      HAL_Delay(200);
      ubUserButtonClickEvent = RESET;
      
      /* Note: Variable "ubUserButtonClickEvent" is set into push button        */
      /*       IRQ handler, refer to function "HAL_GPIO_EXTI_Callback()".       */
  
      /* USER CODE END WHILE */
  
      /* USER CODE BEGIN 3 */
      /* Note: LED state depending on DMA transfer status is set into DMA       */
      /*       IRQ handler, refer to functions "HAL_ADC_ConvCpltCallback()"     */
      /*       and "HAL_ADC_ConvHalfCpltCallback()".                            */
  
      /* Note: ADC conversions data are stored into array                       */
      /*       "aADCxConvertedData"                                             */
      /*       (for debug: see variable content into watch window).             */
      
      /* Note: ADC conversion data are computed to physical values              */
      /*       into array "aADCxConvertedData_Voltage_mVolt"                    */
      /*       using helper macro "__ADC_CALC_DATA_VOLTAGE()".                  */
      /*       (for debug: see variable content into watch window).             */
  
    }
    /* USER CODE END 3 */
  }
  
  /**
    * @brief System Clock Configuration
    * @retval None
    */
  void SystemClock_Config(void)
  {
    RCC_OscInitTypeDef RCC_OscInitStruct = {0};
    RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  
    /** Configure the main internal regulator output voltage
    */
    if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE0) != HAL_OK)
    {
      Error_Handler();
    }
    /** Initializes the RCC Oscillators according to the specified parameters
    * in the RCC_OscInitTypeDef structure.
    */
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
    RCC_OscInitStruct.MSIState = RCC_MSI_ON;
    RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
    RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
    RCC_OscInitStruct.PLL.PLLM = 1;
    RCC_OscInitStruct.PLL.PLLN = 55;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
    RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
    RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
    if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
    {
      Error_Handler();
    }
    /** Initializes the CPU, AHB and APB buses clocks
    */
    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                                |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  
    if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
    {
      Error_Handler();
    }
  }
  
  /**
    * @brief ADC1 Initialization Function
    * @param None
    * @retval None
    */
  static void MX_ADC1_Init(void)
  {
  
    /* USER CODE BEGIN ADC1_Init 0 */
  
    /* USER CODE END ADC1_Init 0 */
  
    ADC_MultiModeTypeDef multimode = {0};
    ADC_ChannelConfTypeDef sConfig = {0};
  
    /* USER CODE BEGIN ADC1_Init 1 */
  
    /* USER CODE END ADC1_Init 1 */
    /** Common config
    */
    hadc1.Instance = ADC1;
    hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
    hadc1.Init.Resolution = ADC_RESOLUTION_12B;
    hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
    hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
    hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
    hadc1.Init.LowPowerAutoWait = DISABLE;
    hadc1.Init.ContinuousConvMode = DISABLE;
    hadc1.Init.NbrOfConversion = 1;
    hadc1.Init.DiscontinuousConvMode = DISABLE;
    hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T2_TRGO;
    hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
    hadc1.Init.DMAContinuousRequests = ENABLE;
    hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
    hadc1.Init.OversamplingMode = DISABLE;
    if (HAL_ADC_Init(&hadc1) != HAL_OK)
    {
      Error_Handler();
    }
    /** Configure the ADC multi-mode
    */
    multimode.Mode = ADC_MODE_INDEPENDENT;
    if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
    {
      Error_Handler();
    }
    /** Configure Regular Channel
    */
    sConfig.Channel = ADC_CHANNEL_9;
    sConfig.Rank = ADC_REGULAR_RANK_1;
    sConfig.SamplingTime = ADC_SAMPLETIME_92CYCLES_5;
    sConfig.SingleDiff = ADC_SINGLE_ENDED;
    sConfig.OffsetNumber = ADC_OFFSET_NONE;
    sConfig.Offset = 0;
    if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
    {
      Error_Handler();
    }
    /* USER CODE BEGIN ADC1_Init 2 */
  
    /* USER CODE END ADC1_Init 2 */
  
  }
  
  /**
    * @brief DAC1 Initialization Function
    * @param None
    * @retval None
    */
  static void MX_DAC1_Init(void)
  {
  
    /* USER CODE BEGIN DAC1_Init 0 */
  
    /* USER CODE END DAC1_Init 0 */
  
    DAC_ChannelConfTypeDef sConfig = {0};
  
    /* USER CODE BEGIN DAC1_Init 1 */
  
    /* USER CODE END DAC1_Init 1 */
    /** DAC Initialization
    */
    hdac1.Instance = DAC1;
    if (HAL_DAC_Init(&hdac1) != HAL_OK)
    {
      Error_Handler();
    }
    /** DAC channel OUT1 config
    */
    sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
    sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
    sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
    sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_ENABLE;
    sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
    if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)
    {
      Error_Handler();
    }
    /* USER CODE BEGIN DAC1_Init 2 */
  
    /* USER CODE END DAC1_Init 2 */
  
  }
  
  /**
    * @brief ICACHE Initialization Function
    * @param None
    * @retval None
    */
  static void MX_ICACHE_Init(void)
  {
  
    /* USER CODE BEGIN ICACHE_Init 0 */
  
    /* USER CODE END ICACHE_Init 0 */
  
    /* USER CODE BEGIN ICACHE_Init 1 */
  
    /* USER CODE END ICACHE_Init 1 */
    /** Enable instruction cache in 1-way (direct mapped cache)
    */
    if (HAL_ICACHE_ConfigAssociativityMode(ICACHE_1WAY) != HAL_OK)
    {
      Error_Handler();
    }
    if (HAL_ICACHE_Enable() != HAL_OK)
    {
      Error_Handler();
    }
    /* USER CODE BEGIN ICACHE_Init 2 */
  
    /* USER CODE END ICACHE_Init 2 */
  
  }
  
  /**
    * @brief TIM2 Initialization Function
    * @param None
    * @retval None
    */
  static void MX_TIM2_Init(void)
  {
  
    /* USER CODE BEGIN TIM2_Init 0 */
  
    /* USER CODE END TIM2_Init 0 */
  
    TIM_ClockConfigTypeDef sClockSourceConfig = {0};
    TIM_MasterConfigTypeDef sMasterConfig = {0};
  
    /* USER CODE BEGIN TIM2_Init 1 */
  
    /* USER CODE END TIM2_Init 1 */
    htim2.Instance = TIM2;
    htim2.Init.Prescaler = 1;
    htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
    htim2.Init.Period = 39999;
    htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
    htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
    if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
    {
      Error_Handler();
    }
    sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
    if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
    {
      Error_Handler();
    }
    sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
    sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
    if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
    {
      Error_Handler();
    }
    /* USER CODE BEGIN TIM2_Init 2 */
  
    /* USER CODE END TIM2_Init 2 */
  
  }
  
  /**
    * Enable DMA controller clock
    */
  static void MX_DMA_Init(void)
  {
  
    /* DMA controller clock enable */
    __HAL_RCC_DMAMUX1_CLK_ENABLE();
    __HAL_RCC_DMA1_CLK_ENABLE();
  
    /* DMA interrupt init */
    /* DMA1_Channel1_IRQn interrupt configuration */
    HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
  
  }
  
  /**
    * @brief GPIO Initialization Function
    * @param None
    * @retval None
    */
  static void MX_GPIO_Init(void)
  {
  
    /* GPIO Ports Clock Enable */
    __HAL_RCC_GPIOA_CLK_ENABLE();
  
  }
  
  /* USER CODE BEGIN 4 */
  
  /**
    * @brief  For this example, generate a waveform voltage on a spare DAC
    *         channel, so user has just to connect a wire between DAC channel 
    *         (pin PA4) and ADC channel (pin PA4) to run this example.
    *         (this prevents the user from resorting to an external signal
    *         generator).
    *         This function configures the DAC and generates a constant voltage of Vdda/2.
    * @note   Voltage level can be modifying afterwards using function
    *         "Generate_waveform_SW_update()".
    * @param  None
    * @retval None
    */
  static void Generate_waveform_SW_update_Config(void)
  {
    /* Set DAC Channel data register: channel corresponding to ADC channel ADC_CHANNEL_9 */
    /* Set DAC output to 1/2 of full range (4095 <=> Vdda=3.3V): 2048 <=> 1.65V */
    if (HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, DIGITAL_SCALE_12BITS/2) != HAL_OK)
    {
      /* Setting value Error */
      Error_Handler();
    }
    
    /* Enable DAC Channel: channel corresponding to ADC channel ADC_CHANNEL_9 */
    if (HAL_DAC_Start(&hdac1, DAC_CHANNEL_1) != HAL_OK)
    {
      /* Start Error */
      Error_Handler();
    }
  
  }
  
  /**
    * @brief  For this example, generate a waveform voltage on a spare DAC
    *         channel, so user has just to connect a wire between DAC channel 
    *         (pin PA4) and ADC channel (pin PA4) to run this example.
    *         (this prevents the user from resorting to an external signal
    *         generator).
    *         This function modifies the voltage level, to generate a
    *         waveform circular, shape of ramp: Voltage is increasing at each 
    *         press on push button, from 0 to maximum range (Vdda) in 4 steps,
    *         then starting back from 0V.
    *         Voltage is updated incrementally at each call of this function.
    * @note   Preliminarily, DAC must be configured once using
    *         function "Generate_waveform_SW_update_Config()".
    * @param  None
    * @retval None
    */
  static void Generate_waveform_SW_update(void)
  {
    static uint8_t ub_dac_steps_count = 0;      /* Count number of clicks: Incremented after User Button interrupt */
    
    /* Set DAC voltage on channel corresponding to ADC_CHANNEL_9              */
    /* in function of user button clicks count.                                   */
    /* Set DAC output on 5 voltage levels, successively to:                       */
    /*  - minimum of full range (0 <=> ground 0V)                                 */
    /*  - 1/4 of full range (4095 <=> Vdda=3.3V): 1023 <=> 0.825V                 */
    /*  - 1/2 of full range (4095 <=> Vdda=3.3V): 2048 <=> 1.65V                  */
    /*  - 3/4 of full range (4095 <=> Vdda=3.3V): 3071 <=> 2.475V                 */
    /*  - maximum of full range (4095 <=> Vdda=3.3V)                              */
    if (HAL_DAC_SetValue(&hdac1,
                         DAC_CHANNEL_1,
                         DAC_ALIGN_12B_R,
                         ((DIGITAL_SCALE_12BITS * ub_dac_steps_count) / 4)
                        ) != HAL_OK)
    {
      /* Start Error */
      Error_Handler();
    }
    
    /* Wait for voltage settling time */
    HAL_Delay(1);
    
    /* Manage ub_dac_steps_count to increment it in 4 steps and circularly.   */
    if (ub_dac_steps_count < 4)
    {
      ub_dac_steps_count++;
    }
    else
    {
      ub_dac_steps_count = 0;
    }
  
  }
  
  /******************************************************************************/
  /*   USER IRQ HANDLER TREATMENT                                               */
  /******************************************************************************/
  
  /**
    * @brief EXTI line detection callbacks
    * @param GPIO_Pin: Specifies the pins connected EXTI line
    * @retval None
    */
  void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
  {
   if (GPIO_Pin == BUTTON_USER_PIN)
   {
     /* Set variable to report push button event to main program */
     ubUserButtonClickEvent = SET;
   }
  }
  
  /**
    * @brief  Conversion complete callback in non blocking mode 
    * @param  hadc: ADC handle
    * @note   This example shows a simple way to report end of conversion
    *         and get conversion result. You can add your own implementation.
    * @retval None
    */
  void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
  {
    uint32_t tmp_index = 0;
    
    /* Computation of ADC conversions raw data to physical values               */
    /* using LL ADC driver helper macro.                                        */
    /* Management of the 2nd half of the buffer */
    for (tmp_index = (ADC_CONVERTED_DATA_BUFFER_SIZE/2); tmp_index < ADC_CONVERTED_DATA_BUFFER_SIZE; tmp_index++)
    {
      aADCxConvertedData_Voltage_mVolt[tmp_index] = __ADC_CALC_DATA_VOLTAGE(VDDA_APPLI, aADCxConvertedData[tmp_index]);
    }
    
    /* Update status variable of DMA transfer */
    ubDmaTransferStatus = 1;
    
    /* Set LED depending on DMA transfer status */
    /* - Turn-on if DMA transfer is completed */
    /* - Turn-off if DMA transfer is not completed */
    BSP_LED_On(LED1);
  }
  
  /**
    * @brief  Conversion DMA half-transfer callback in non blocking mode 
    * @note   This example shows a simple way to report end of conversion
    *         and get conversion result. You can add your own implementation.
    * @retval None
    */
  void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc)
  {
    uint32_t tmp_index = 0;
    
    /* Computation of ADC conversions raw data to physical values               */
    /* using LL ADC driver helper macro.                                        */
    /* Management of the 1st half of the buffer */
    for (tmp_index = 0; tmp_index < (ADC_CONVERTED_DATA_BUFFER_SIZE/2); tmp_index++)
    {
      aADCxConvertedData_Voltage_mVolt[tmp_index] = __ADC_CALC_DATA_VOLTAGE(VDDA_APPLI, aADCxConvertedData[tmp_index]);
    }
    
    /* Update status variable of DMA transfer */
    ubDmaTransferStatus = 0;
    
    /* Set LED depending on DMA transfer status */
    /* - Turn-on if DMA transfer is completed */
    /* - Turn-off if DMA transfer is not completed */
    BSP_LED_Off(LED1);
  }
  
  /**
    * @brief  ADC error callback in non blocking mode
    *        (ADC conversion with interruption or transfer by DMA)
    * @param  hadc: ADC handle
    * @retval None
    */
  void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)
  {
    /* In case of ADC error, call main error handler */
    Error_Handler();
  }
  
  /* USER CODE END 4 */
  
  /**
    * @brief  This function is executed in case of error occurrence.
    * @retval None
    */
  void Error_Handler(void)
  {
    /* USER CODE BEGIN Error_Handler_Debug */
    /* User can add his own implementation to report the HAL error return state */
    while(1) 
    {
      /* Toggle LED1 */
      BSP_LED_Off(LED1);
      HAL_Delay(800);
      BSP_LED_On(LED1);
      HAL_Delay(200);
    }
    /* USER CODE END Error_Handler_Debug */
  }
  
  #ifdef  USE_FULL_ASSERT
  /**
    * @brief  Reports the name of the source file and the source line number
    *         where the assert_param error has occurred.
    * @param  file: pointer to the source file name
    * @param  line: assert_param error line source number
    * @retval None
    */
  void assert_failed(uint8_t *file, uint32_t line)
  {
    /* USER CODE BEGIN 6 */
    /* User can add his own implementation to report the file name and line number,
      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
    Error_Handler();
    /* USER CODE END 6 */
  }
  #endif /* USE_FULL_ASSERT */
  
  /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  