/**
******************************************************************************
* @file ADC/ADC_Sequencer/Src/stm32f1xx_hal_msp.c
* @author MCD Application Team
* @brief HAL MSP module.
******************************************************************************
* @attention
*
*
© Copyright (c) 2016 STMicroelectronics.
* All rights reserved.
*
* 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 "main.h"
/** @addtogroup STM32F1xx_HAL_Examples
* @{
*/
/** @defgroup ADC_Sequencer
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
__HAL_RCC_AFIO_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();
/* System interrupt init*/
/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}
/** @defgroup HAL_MSP_Private_Functions
* @{
*/
/**
* @brief ADC MSP initialization
* This function configures the hardware resources used in this example:
* - Enable clock of ADC peripheral
* - Configure the GPIO associated to the peripheral channels
* - Configure the DMA associated to the peripheral
* - Configure the NVIC associated to the peripheral interruptions
* @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_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**ADC1 GPIO Configuration
PA2 ------> ADC1_IN2
*/
GPIO_InitStruct.Pin = GPIO_PIN_4;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
}
}
/**
* @brief ADC MSP de-initialization
* This function frees the hardware resources used in this example:
* - Disable clock of ADC peripheral
* - Revert GPIO associated to the peripheral channels to their default state
* - Revert DMA associated to the peripheral to its default state
* - Revert NVIC associated to the peripheral interruptions to its default state
* @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_ADC1_CLK_DISABLE();
/**ADC1 GPIO Configuration
PA2 ------> ADC1_IN2
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_4);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
/* USER CODE END ADC1_MspDeInit 1 */
}
}
#if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST)
/**
* @brief DAC MSP initialization
* This function configures the hardware resources used in this example:
* - Enable clock of peripheral
* - Configure the GPIO associated to the peripheral channels
* - Configure the NVIC associated to the peripheral interruptions
* @param hdac: DAC handle pointer
* @retval None
*/
void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* Enable GPIO clock */
DACx_CHANNEL_GPIO_CLK_ENABLE();
/* DAC peripheral clock enable */
DACx_CLK_ENABLE();
/*##-2- Configure peripheral GPIO ##########################################*/
/* Configure GPIO pin of the selected DAC channel */
GPIO_InitStruct.Pin = DACx_CHANNEL_TO_ADCx_CHANNELa_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(DACx_CHANNEL_TO_ADCx_CHANNELa_GPIO_PORT, &GPIO_InitStruct);
/*##-3- Configure the NVIC #################################################*/
/* Note: On this device, DAC has no interruption (no underrun IT) */
}
/**
* @brief DAC MSP de-initialization
* This function frees the hardware resources used in this example:
* - Disable clock of peripheral
* - Revert GPIO associated to the peripheral channels to their default state
* - Revert NVIC associated to the peripheral interruptions to its default state
* @param hadc: DAC handle pointer
* @retval None
*/
void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac)
{
/*##-1- Reset peripherals ##################################################*/
DACx_FORCE_RESET();
DACx_RELEASE_RESET();
/*##-2- Disable peripherals and GPIO Clocks ################################*/
/* De-initialize GPIO pin of the selected DAC channel */
HAL_GPIO_DeInit(DACx_CHANNEL_TO_ADCx_CHANNELa_GPIO_PORT, DACx_CHANNEL_TO_ADCx_CHANNELa_PIN);
/*##-3- Disable the NVIC for DAC ###########################################*/
/* Note: On this device, DAC has no interruption (no underrun IT) */
}
#endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/