stm32h7xx_hal_msp.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : stm32h7xx_hal_msp.c
  5. * Description : This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2019 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. /* USER CODE END Header */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE END Includes */
  25. /* Private typedef -----------------------------------------------------------*/
  26. /* USER CODE BEGIN TD */
  27. /* USER CODE END TD */
  28. /* Private define ------------------------------------------------------------*/
  29. /* USER CODE BEGIN Define */
  30. /* USER CODE END Define */
  31. /* Private macro -------------------------------------------------------------*/
  32. /* USER CODE BEGIN Macro */
  33. /* USER CODE END Macro */
  34. /* Private variables ---------------------------------------------------------*/
  35. /* USER CODE BEGIN PV */
  36. /* USER CODE END PV */
  37. /* Private function prototypes -----------------------------------------------*/
  38. /* USER CODE BEGIN PFP */
  39. /* USER CODE END PFP */
  40. /* External functions --------------------------------------------------------*/
  41. /* USER CODE BEGIN ExternalFunctions */
  42. /* USER CODE END ExternalFunctions */
  43. /* USER CODE BEGIN 0 */
  44. /* USER CODE END 0 */
  45. /**
  46. * Initializes the Global MSP.
  47. */
  48. void HAL_MspInit(void)
  49. {
  50. /* USER CODE BEGIN MspInit 0 */
  51. /* USER CODE END MspInit 0 */
  52. __HAL_RCC_SYSCFG_CLK_ENABLE();
  53. /* System interrupt init*/
  54. /* USER CODE BEGIN MspInit 1 */
  55. /* USER CODE END MspInit 1 */
  56. }
  57. /**
  58. * @brief UART MSP Initialization
  59. * This function configures the hardware resources used in this example
  60. * @param huart: UART handle pointer
  61. * @retval None
  62. */
  63. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  64. {
  65. GPIO_InitTypeDef GPIO_InitStruct = {0};
  66. if(huart->Instance==USART3)
  67. {
  68. /* USER CODE BEGIN USART3_MspInit 0 */
  69. /* USER CODE END USART3_MspInit 0 */
  70. /* Peripheral clock enable */
  71. __HAL_RCC_USART3_CLK_ENABLE();
  72. __HAL_RCC_GPIOD_CLK_ENABLE();
  73. /**USART3 GPIO Configuration
  74. PD8 ------> USART3_TX
  75. PD9 ------> USART3_RX
  76. */
  77. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
  78. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  79. GPIO_InitStruct.Pull = GPIO_PULLUP;
  80. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  81. GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  82. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  83. /* USER CODE BEGIN USART3_MspInit 1 */
  84. /* USER CODE END USART3_MspInit 1 */
  85. }
  86. }
  87. /**
  88. * @brief UART MSP De-Initialization
  89. * This function freeze the hardware resources used in this example
  90. * @param huart: UART handle pointer
  91. * @retval None
  92. */
  93. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  94. {
  95. if(huart->Instance==USART3)
  96. {
  97. /* USER CODE BEGIN USART3_MspDeInit 0 */
  98. /* USER CODE END USART3_MspDeInit 0 */
  99. /* Peripheral clock disable */
  100. __HAL_RCC_USART3_CLK_DISABLE();
  101. /**USART3 GPIO Configuration
  102. PD8 ------> USART3_TX
  103. PD9 ------> USART3_RX
  104. */
  105. HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9);
  106. /* USER CODE BEGIN USART3_MspDeInit 1 */
  107. /* USER CODE END USART3_MspDeInit 1 */
  108. }
  109. }
  110. /* USER CODE BEGIN 1 */
  111. /* USER CODE END 1 */
  112. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/