/Projects/STM324x9I_EVAL/Examples/ADC/ADC_InjectedConversion_Interrupt/Src/stm32f4xx_hal_msp.c

https://github.com/Bosvark/STM32Cube_FW_F4_V1.1.0 · C · 132 lines · 25 code · 17 blank · 90 comment · 0 complexity · 05b3f145bfffe57ad010f3068e928b02 MD5 · raw file

  1. /**
  2. ******************************************************************************
  3. * @file ADC/ADC_InjectedConversion_Interrupt/Src/stm32f4xx_hal_msp.c
  4. * @author MCD Application Team
  5. * @version V1.0.1
  6. * @date 26-February-2014
  7. * @brief HAL MSP module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Includes ------------------------------------------------------------------*/
  38. #include "main.h"
  39. /** @addtogroup STM32F4xx_HAL_Examples
  40. * @{
  41. */
  42. /** @defgroup ADC_InjectedConversion_Interrupt
  43. * @{
  44. */
  45. /* Private typedef -----------------------------------------------------------*/
  46. /* Private define ------------------------------------------------------------*/
  47. /* Private macro -------------------------------------------------------------*/
  48. /* Private variables ---------------------------------------------------------*/
  49. /* Private function prototypes -----------------------------------------------*/
  50. /* Private functions ---------------------------------------------------------*/
  51. /** @defgroup HAL_MSP_Private_Functions
  52. * @{
  53. */
  54. /**
  55. * @brief ADC MSP Initialization
  56. * This function configures the hardware resources used in this example:
  57. * - Peripheral's clock enable
  58. * - Peripheral's GPIO Configuration
  59. * @param huart: UART handle pointer
  60. * @retval None
  61. */
  62. void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
  63. {
  64. GPIO_InitTypeDef GPIO_InitStruct;
  65. /*##-1- Enable peripherals and GPIO Clocks #################################*/
  66. /* ADC3 Periph clock enable */
  67. ADCx_CLK_ENABLE();
  68. /* Enable GPIO clock ****************************************/
  69. ADCx_REG_CHANNEL_GPIO_CLK_ENABLE();
  70. ADCx_INJ_CHANNEL_GPIO_CLK_ENABLE();
  71. /*##-2- Configure peripheral GPIO ##########################################*/
  72. /* ADC1 Channel11 GPIO pin configuration */
  73. GPIO_InitStruct.Pin = ADCx_REG_CHANNEL_PIN;
  74. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  75. GPIO_InitStruct.Pull = GPIO_NOPULL;
  76. HAL_GPIO_Init(ADCx_REG_CHANNEL_GPIO_PORT, &GPIO_InitStruct);
  77. /* ADC1 Channel12 GPIO pin configuration */
  78. GPIO_InitStruct.Pin = ADCx_INJ_CHANNEL_PIN;
  79. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  80. GPIO_InitStruct.Pull = GPIO_NOPULL;
  81. HAL_GPIO_Init(ADCx_INJ_CHANNEL_GPIO_PORT, &GPIO_InitStruct);
  82. /*##-3- Configure the NVIC #################################################*/
  83. /* NVIC configuration for conversion complete complete interrupt */
  84. HAL_NVIC_SetPriority(ADCx_IRQn, 15, 0);
  85. HAL_NVIC_EnableIRQ(ADCx_IRQn);
  86. }
  87. /**
  88. * @brief ADC MSP De-Initialization
  89. * This function frees the hardware resources used in this example:
  90. * - Disable the Peripheral's clock
  91. * - Revert GPIO to their default state
  92. * @param hadc: ADC handle pointer
  93. * @retval None
  94. */
  95. void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
  96. {
  97. /*##-1- Reset peripherals ##################################################*/
  98. ADCx_FORCE_RESET();
  99. ADCx_RELEASE_RESET();
  100. /*##-2- Disable peripherals and GPIO Clocks ################################*/
  101. /* De-initialize the ADC1 Channel11 GPIO pin */
  102. HAL_GPIO_DeInit(ADCx_REG_CHANNEL_GPIO_PORT, ADCx_REG_CHANNEL_PIN);
  103. /* De-initialize the ADC1 Channel12 GPIO pin */
  104. HAL_GPIO_DeInit(ADCx_INJ_CHANNEL_GPIO_PORT, ADCx_INJ_CHANNEL_PIN);
  105. }
  106. /**
  107. * @}
  108. */
  109. /**
  110. * @}
  111. */
  112. /**
  113. * @}
  114. */
  115. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/