/Projects/STM32H745I-DISCO/Demonstrations/CM7/Src/stm32h7xx_hal_msp.c

https://github.com/STMicroelectronics/STM32CubeH7 · C · 167 lines · 44 code · 32 blank · 91 comment · 0 complexity · 520c2dc270f2177c3ac383198fa8c41d MD5 · raw file

  1. /**
  2. ******************************************************************************
  3. * @file Demonstration/STM32H745-Discovery_Demo/CM7/Src/stm32h7xx_hal_msp.c
  4. * @author MCD Application Team
  5. * @brief HAL MSP module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main_oscillo_cm7.h"
  21. /** @addtogroup STM32H7xx_HAL_Demonstration
  22. * @{
  23. */
  24. /** @addtogroup Oscilloscope_SignalsGenerator
  25. * @{
  26. */
  27. /* Private typedef -----------------------------------------------------------*/
  28. extern DMA_HandleTypeDef DmaHandle;
  29. /* Private define ------------------------------------------------------------*/
  30. /* Private macro -------------------------------------------------------------*/
  31. /* Private variables ---------------------------------------------------------*/
  32. /* Private function prototypes -----------------------------------------------*/
  33. /* Private functions ---------------------------------------------------------*/
  34. /** @defgroup HAL_MSP_Private_Functions
  35. * @{
  36. */
  37. /**
  38. * @brief ADC MSP Init
  39. * @param hadc : ADC handle
  40. * @retval None
  41. */
  42. /*####### 1- TIM Initialization #################################*/
  43. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
  44. {
  45. TIMx_CLK_ENABLE();
  46. }
  47. /*####### 2- TIM De-Initialization ##############################*/
  48. /**
  49. * @brief TIM MSP De-Initialization
  50. * This function frees the hardware resources used in this example:
  51. * - Disable the Peripheral's clock
  52. * - Revert GPIO to their default state
  53. * @param htim: TIM handle pointer
  54. * @retval None
  55. */
  56. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
  57. {
  58. /*##-1- Reset peripherals ##################################################*/
  59. __HAL_RCC_TIMx_FORCE_RESET();
  60. __HAL_RCC_TIMx_RELEASE_RESET();
  61. }
  62. /**
  63. * @brief DAC MSP Initialization
  64. * This function configures the hardware resources used in this example:
  65. * - Peripheral's clock enable
  66. * - Peripheral's GPIO Configuration
  67. * @param hdac: DAC handle pointer
  68. * @retval None
  69. */
  70. void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac)
  71. {
  72. GPIO_InitTypeDef GPIO_InitStruct;
  73. static DMA_HandleTypeDef hdma_dac1;
  74. /*##-1- Enable peripherals and GPIO Clocks #################################*/
  75. /* Enable GPIO clock ****************************************/
  76. DACx_CHANNEL_GPIO_CLK_ENABLE();
  77. /* DAC Periph clock enable */
  78. DACx_CLK_ENABLE();
  79. /* DMA1 clock enable */
  80. DMAx_CLK_ENABLE();
  81. /*##-2- Configure peripheral GPIO ##########################################*/
  82. /* DAC Channel1 GPIO pin configuration */
  83. GPIO_InitStruct.Pin = DACx_CHANNEL_PIN;
  84. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  85. GPIO_InitStruct.Pull = GPIO_NOPULL;
  86. HAL_GPIO_Init(DACx_CHANNEL_GPIO_PORT, &GPIO_InitStruct);
  87. /*##-3- Configure the DMA ##########################################*/
  88. /* Set the parameters to be configured for DACx_DMA_STREAM */
  89. hdma_dac1.Instance = DACx_DMA_INSTANCE;
  90. hdma_dac1.Init.Request = DMA_REQUEST_DAC1;
  91. hdma_dac1.Init.Direction = DMA_MEMORY_TO_PERIPH;
  92. hdma_dac1.Init.PeriphInc = DMA_PINC_DISABLE;
  93. hdma_dac1.Init.MemInc = DMA_MINC_ENABLE;
  94. hdma_dac1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
  95. hdma_dac1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
  96. hdma_dac1.Init.Mode = DMA_CIRCULAR;
  97. hdma_dac1.Init.Priority = DMA_PRIORITY_HIGH;
  98. HAL_DMA_Init(&hdma_dac1);
  99. /* Associate the initialized DMA handle to the DAC handle */
  100. __HAL_LINKDMA(hdac, DMA_Handle1, hdma_dac1);
  101. /*##-4- Configure the NVIC for DMA #########################################*/
  102. /* Enable the DMA1_Stream5 IRQ Channel */
  103. HAL_NVIC_SetPriority(DACx_DMA_IRQn, 2, 0);
  104. HAL_NVIC_EnableIRQ(DACx_DMA_IRQn);
  105. }
  106. /**
  107. * @brief DeInitializes the DAC MSP.
  108. * @param hdac: pointer to a DAC_HandleTypeDef structure that contains
  109. * the configuration information for the specified DAC.
  110. * @retval None
  111. */
  112. void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac)
  113. {
  114. /*##-1- Reset peripherals ##################################################*/
  115. DACx_FORCE_RESET();
  116. DACx_RELEASE_RESET();
  117. /*##-2- Disable peripherals and GPIO Clocks ################################*/
  118. /* De-initialize the DAC Channel1 GPIO pin */
  119. HAL_GPIO_DeInit(DACx_CHANNEL_GPIO_PORT, DACx_CHANNEL_PIN);
  120. /*##-3- Disable the DMA Stream ############################################*/
  121. /* De-Initialize the DMA Stream associate to DAC_Channel1 */
  122. HAL_DMA_DeInit(hdac->DMA_Handle1);
  123. /*##-4- Disable the NVIC for DMA ###########################################*/
  124. HAL_NVIC_DisableIRQ(DACx_DMA_IRQn);
  125. }
  126. /**
  127. * @}
  128. */
  129. /**
  130. * @}
  131. */
  132. /**
  133. * @}
  134. */
  135. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/