diff options
Diffstat (limited to 'Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c')
-rw-r--r-- | Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c | 119 |
1 files changed, 55 insertions, 64 deletions
diff --git a/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c b/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c index fa083fc97..afbe72913 100644 --- a/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c +++ b/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_SingleConversion_TriggerSW_IT/Src/stm32wbxx_hal_msp.c @@ -74,82 +74,73 @@ void HAL_MspInit(void) /* 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) +* @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; - - /*##-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); + 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_ADC_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PA1 ------> ADC1_IN6 + */ + GPIO_InitStruct.Pin = GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC1_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(ADC1_IRQn); + /* 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) +* @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) { - /*##-1- Reset peripherals ##################################################*/ - ADCx_FORCE_RESET(); - ADCx_RELEASE_RESET(); + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ - /*##-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); + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC_CLK_DISABLE(); - /*##-3- Disable the DMA ####################################################*/ - /* De-Initialize the DMA associated to the peripheral */ - if(hadc->DMA_Handle != NULL) - { - HAL_DMA_DeInit(hadc->DMA_Handle); + /**ADC1 GPIO Configuration + PA1 ------> ADC1_IN6 + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC1_IRQn); + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ } - /*##-4- Disable the NVIC ###################################################*/ - /* Disable the NVIC configuration for ADC interrupt */ - HAL_NVIC_DisableIRQ(ADCx_IRQn); - } +/* USER CODE BEGIN 1 */ /* USER CODE END 1 */ |