stm32g4xx_hal_msp.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file stm32g4xx_hal_msp.c
  5. * @brief This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2025 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. /* USER CODE BEGIN Includes */
  23. /* USER CODE END Includes */
  24. /* Private typedef -----------------------------------------------------------*/
  25. /* USER CODE BEGIN TD */
  26. /* USER CODE END TD */
  27. /* Private define ------------------------------------------------------------*/
  28. /* USER CODE BEGIN Define */
  29. /* USER CODE END Define */
  30. /* Private macro -------------------------------------------------------------*/
  31. /* USER CODE BEGIN Macro */
  32. /* USER CODE END Macro */
  33. /* Private variables ---------------------------------------------------------*/
  34. /* USER CODE BEGIN PV */
  35. /* USER CODE END PV */
  36. /* Private function prototypes -----------------------------------------------*/
  37. /* USER CODE BEGIN PFP */
  38. /* USER CODE END PFP */
  39. /* External functions --------------------------------------------------------*/
  40. /* USER CODE BEGIN ExternalFunctions */
  41. /* USER CODE END ExternalFunctions */
  42. /* USER CODE BEGIN 0 */
  43. /* USER CODE END 0 */
  44. /**
  45. * Initializes the Global MSP.
  46. */
  47. void HAL_MspInit(void)
  48. {
  49. /* USER CODE BEGIN MspInit 0 */
  50. /* USER CODE END MspInit 0 */
  51. __HAL_RCC_SYSCFG_CLK_ENABLE();
  52. __HAL_RCC_PWR_CLK_ENABLE();
  53. /* System interrupt init*/
  54. /* PendSV_IRQn interrupt configuration */
  55. HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
  56. /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral
  57. */
  58. HAL_PWREx_DisableUCPDDeadBattery();
  59. /* USER CODE BEGIN MspInit 1 */
  60. /* USER CODE END MspInit 1 */
  61. }
  62. /**
  63. * @brief RTC MSP Initialization
  64. * This function configures the hardware resources used in this example
  65. * @param hrtc: RTC handle pointer
  66. * @retval None
  67. */
  68. void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
  69. {
  70. RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  71. if(hrtc->Instance==RTC)
  72. {
  73. /* USER CODE BEGIN RTC_MspInit 0 */
  74. /* USER CODE END RTC_MspInit 0 */
  75. /** Initializes the peripherals clocks
  76. */
  77. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
  78. PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
  79. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  80. {
  81. Error_Handler();
  82. }
  83. /* Peripheral clock enable */
  84. __HAL_RCC_RTC_ENABLE();
  85. __HAL_RCC_RTCAPB_CLK_ENABLE();
  86. /* USER CODE BEGIN RTC_MspInit 1 */
  87. /* USER CODE END RTC_MspInit 1 */
  88. }
  89. }
  90. /**
  91. * @brief RTC MSP De-Initialization
  92. * This function freeze the hardware resources used in this example
  93. * @param hrtc: RTC handle pointer
  94. * @retval None
  95. */
  96. void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
  97. {
  98. if(hrtc->Instance==RTC)
  99. {
  100. /* USER CODE BEGIN RTC_MspDeInit 0 */
  101. /* USER CODE END RTC_MspDeInit 0 */
  102. /* Peripheral clock disable */
  103. __HAL_RCC_RTC_DISABLE();
  104. __HAL_RCC_RTCAPB_CLK_DISABLE();
  105. /* USER CODE BEGIN RTC_MspDeInit 1 */
  106. /* USER CODE END RTC_MspDeInit 1 */
  107. }
  108. }
  109. /* USER CODE BEGIN 1 */
  110. /* USER CODE END 1 */