diff options
Diffstat (limited to 'Projects/NUCLEO-WB35CE/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c')
-rw-r--r-- | Projects/NUCLEO-WB35CE/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/Projects/NUCLEO-WB35CE/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c b/Projects/NUCLEO-WB35CE/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c new file mode 100644 index 000000000..f8f532304 --- /dev/null +++ b/Projects/NUCLEO-WB35CE/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c @@ -0,0 +1,156 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c + * @author MCD Application Team + * @brief HAL MSP module. + ****************************************************************************** + * @attention + * + * <h2><center>© 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 */ + + /* System interrupt init*/ + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/* USER CODE BEGIN 1 */ + +/** + * @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; + + /*##-1- Enable peripherals and GPIO Clocks #################################*/ + /* Enable clock of GPIO associated to the peripheral channels */ + ADCx_CHANNELa_GPIO_CLK_ENABLE(); + + /* Enable clock of ADCx peripheral (core clock) */ + ADCx_CLK_ENABLE(); + + /* Note: In case of usage of asynchronous clock for ADC, with ADC setting */ + /* "AdcHandle.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIVx", */ + /* the clock source has to be enabled at RCC top level using function */ + /* "HAL_RCCEx_PeriphCLKConfig()" or macro "__HAL_RCC_ADC_CONFIG()" */ + /* (refer to comments in driver file header). */ + + /*##-2- Configure peripheral GPIO ##########################################*/ + /* Configure GPIO pin of the selected ADC channel */ + GPIO_InitStruct.Pin = ADCx_CHANNELa_PIN; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADCx_CHANNELa_GPIO_PORT, &GPIO_InitStruct); + + /*##-4- Configure the NVIC #################################################*/ + /* NVIC configuration for ADC interrupt */ + /* Priority: high-priority */ + HAL_NVIC_SetPriority(ADCx_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(ADCx_IRQn); +} + +/** + * @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) +{ + /*##-1- Reset peripherals ##################################################*/ + ADCx_FORCE_RESET(); + ADCx_RELEASE_RESET(); + + /*##-2- Disable peripherals and GPIO Clocks ################################*/ + /* De-initialize GPIO pin of the selected ADC channel */ + HAL_GPIO_DeInit(ADCx_CHANNELa_GPIO_PORT, ADCx_CHANNELa_PIN); + + /*##-3- Disable the DMA ####################################################*/ + /* De-Initialize the DMA associated to the peripheral */ + if(hadc->DMA_Handle != NULL) + { + HAL_DMA_DeInit(hadc->DMA_Handle); + } + + /*##-4- Disable the NVIC ###################################################*/ + /* Disable the NVIC configuration for ADC interrupt */ + HAL_NVIC_DisableIRQ(ADCx_IRQn); + +} + + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |