stm32l4xx_hal_msp.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file stm32l4xx_hal_msp.c
  5. * @brief This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "stm32l4xx_hal.h"
  22. extern void _Error_Handler(char *, int);
  23. /* USER CODE BEGIN 0 */
  24. /* USER CODE END 0 */
  25. /**
  26. * Initializes the Global MSP.
  27. */
  28. void HAL_MspInit(void)
  29. {
  30. /* USER CODE BEGIN MspInit 0 */
  31. /* USER CODE END MspInit 0 */
  32. __HAL_RCC_SYSCFG_CLK_ENABLE();
  33. __HAL_RCC_PWR_CLK_ENABLE();
  34. HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  35. /* System interrupt init*/
  36. /* MemoryManagement_IRQn interrupt configuration */
  37. HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
  38. /* BusFault_IRQn interrupt configuration */
  39. HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
  40. /* UsageFault_IRQn interrupt configuration */
  41. HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
  42. /* SVCall_IRQn interrupt configuration */
  43. HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
  44. /* DebugMonitor_IRQn interrupt configuration */
  45. HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
  46. /* PendSV_IRQn interrupt configuration */
  47. HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
  48. /* SysTick_IRQn interrupt configuration */
  49. HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  50. /* USER CODE BEGIN MspInit 1 */
  51. /* USER CODE END MspInit 1 */
  52. }
  53. void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
  54. {
  55. if(hrtc->Instance==RTC)
  56. {
  57. /* USER CODE BEGIN RTC_MspInit 0 */
  58. /* USER CODE END RTC_MspInit 0 */
  59. /* Peripheral clock enable */
  60. __HAL_RCC_RTC_ENABLE();
  61. /* USER CODE BEGIN RTC_MspInit 1 */
  62. /* USER CODE END RTC_MspInit 1 */
  63. }
  64. }
  65. void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
  66. {
  67. if(hrtc->Instance==RTC)
  68. {
  69. /* USER CODE BEGIN RTC_MspDeInit 0 */
  70. /* USER CODE END RTC_MspDeInit 0 */
  71. /* Peripheral clock disable */
  72. __HAL_RCC_RTC_DISABLE();
  73. /* USER CODE BEGIN RTC_MspDeInit 1 */
  74. /* USER CODE END RTC_MspDeInit 1 */
  75. }
  76. }
  77. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  78. {
  79. GPIO_InitTypeDef GPIO_InitStruct;
  80. if(huart->Instance==USART2)
  81. {
  82. /* USER CODE BEGIN USART2_MspInit 0 */
  83. /* USER CODE END USART2_MspInit 0 */
  84. /* Peripheral clock enable */
  85. __HAL_RCC_USART2_CLK_ENABLE();
  86. /**USART2 GPIO Configuration
  87. PA2 ------> USART2_TX
  88. PA15 (JTDI) ------> USART2_RX
  89. */
  90. GPIO_InitStruct.Pin = VCP_TX_Pin;
  91. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  92. GPIO_InitStruct.Pull = GPIO_PULLUP;
  93. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
  94. GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
  95. HAL_GPIO_Init(VCP_TX_GPIO_Port, &GPIO_InitStruct);
  96. GPIO_InitStruct.Pin = VCP_RX_Pin;
  97. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  98. GPIO_InitStruct.Pull = GPIO_PULLUP;
  99. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
  100. GPIO_InitStruct.Alternate = GPIO_AF3_USART2;
  101. HAL_GPIO_Init(VCP_RX_GPIO_Port, &GPIO_InitStruct);
  102. /* USER CODE BEGIN USART2_MspInit 1 */
  103. /* USER CODE END USART2_MspInit 1 */
  104. }
  105. }
  106. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  107. {
  108. if(huart->Instance==USART2)
  109. {
  110. /* USER CODE BEGIN USART2_MspDeInit 0 */
  111. /* USER CODE END USART2_MspDeInit 0 */
  112. /* Peripheral clock disable */
  113. __HAL_RCC_USART2_CLK_DISABLE();
  114. /**USART2 GPIO Configuration
  115. PA2 ------> USART2_TX
  116. PA15 (JTDI) ------> USART2_RX
  117. */
  118. HAL_GPIO_DeInit(GPIOA, VCP_TX_Pin|VCP_RX_Pin);
  119. /* USER CODE BEGIN USART2_MspDeInit 1 */
  120. /* USER CODE END USART2_MspDeInit 1 */
  121. }
  122. }
  123. /* USER CODE BEGIN 1 */
  124. /* USER CODE END 1 */
  125. /**
  126. * @}
  127. */
  128. /**
  129. * @}
  130. */
  131. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/