Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_AnalogWatchdog/Src/stm32wbxx_hal_msp.c')
-rw-r--r--Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_AnalogWatchdog/Src/stm32wbxx_hal_msp.c171
1 files changed, 76 insertions, 95 deletions
diff --git a/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_AnalogWatchdog/Src/stm32wbxx_hal_msp.c b/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_AnalogWatchdog/Src/stm32wbxx_hal_msp.c
index e2ee7d6ae..df385bd96 100644
--- a/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_AnalogWatchdog/Src/stm32wbxx_hal_msp.c
+++ b/Projects/P-NUCLEO-WB55.Nucleo/Examples/ADC/ADC_AnalogWatchdog/Src/stm32wbxx_hal_msp.c
@@ -24,6 +24,7 @@
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
+extern DMA_HandleTypeDef hdma_adc1;
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
@@ -74,114 +75,94 @@ 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;
- static DMA_HandleTypeDef DmaHandle;
-
- /*##-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();
-
- /* Enable clock of ADCx peripheral (conversion clock) */
- /* Note: Configuration necessary only when ADC clock source is set to */
- /* asynchronous clock source: */
- /* "AdcHandle.Init.ClockPrescaler = ADC_CLOCK_ASYNC_xxx" */
- __HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_SYSCLK);
-
- /* Enable clock of DMA associated to the peripheral */
- ADCx_DMA_CLK_ENABLE();
-
- /*##-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);
-
- /*##-3- Configure the DMA ##################################################*/
- /* Configure DMA parameters */
- DmaHandle.Instance = ADCx_DMA;
-
- DmaHandle.Init.Request = DMA_REQUEST_ADC1;
- DmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY;
- DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
- DmaHandle.Init.MemInc = DMA_MINC_ENABLE;
- DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; /* Transfer from ADC by half-word to match with ADC configuration: ADC resolution 10 or 12 bits */
- DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; /* Transfer to memory by half-word to match with buffer variable type: half-word */
- DmaHandle.Init.Mode = DMA_CIRCULAR; /* DMA in circular mode to match with ADC configuration: DMA continuous requests */
- DmaHandle.Init.Priority = DMA_PRIORITY_HIGH;
-
- /* Deinitialize & Initialize the DMA for new transfer */
- HAL_DMA_DeInit(&DmaHandle);
- HAL_DMA_Init(&DmaHandle);
-
- /* Associate the initialized DMA handle to the ADC handle */
- __HAL_LINKDMA(hadc, DMA_Handle, DmaHandle);
-
- /*##-4- Configure the NVIC #################################################*/
- /* NVIC configuration for ADC interrupt */
- /* Priority: high-priority */
- HAL_NVIC_SetPriority(ADCx_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(ADCx_IRQn);
-
- /* NVIC configuration for DMA interrupt (transfer completion or error) */
- /* Priority: high-priority */
- HAL_NVIC_SetPriority(ADCx_DMA_IRQn, 1, 0);
- HAL_NVIC_EnableIRQ(ADCx_DMA_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 DMA Init */
+ /* ADC1 Init */
+ hdma_adc1.Instance = DMA1_Channel1;
+ hdma_adc1.Init.Request = DMA_REQUEST_ADC1;
+ hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;
+ hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;
+ hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
+ hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
+ hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
+ hdma_adc1.Init.Mode = DMA_CIRCULAR;
+ hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
+ if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1);
+
+ /* 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)
- {
+ /**ADC1 GPIO Configuration
+ PA1 ------> ADC1_IN6
+ */
+ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1);
+
+ /* ADC1 DMA DeInit */
HAL_DMA_DeInit(hadc->DMA_Handle);
+
+ /* 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);
-
- /* Disable the NVIC configuration for DMA interrupt */
- HAL_NVIC_DisableIRQ(ADCx_DMA_IRQn);
-
}
+/* USER CODE BEGIN 1 */
/* USER CODE END 1 */