1 /* USER CODE BEGIN Header */ 2 /** 3 ****************************************************************************** 4 * @file stm32wlxx_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>© 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 /* USER CODE END Header */ 21 22 /* Includes ------------------------------------------------------------------*/ 23 #include "main.h" 24 /* USER CODE BEGIN Includes */ 25 #include <drv_common.h> 26 /* USER CODE END Includes */ 27 28 /* Private typedef -----------------------------------------------------------*/ 29 /* USER CODE BEGIN TD */ 30 /* USER CODE END TD */ 31 32 /* Private define ------------------------------------------------------------*/ 33 /* USER CODE BEGIN Define */ 34 /* USER CODE END Define */ 35 36 /* Private macro -------------------------------------------------------------*/ 37 /* USER CODE BEGIN Macro */ 38 /* USER CODE END Macro */ 39 40 /* Private variables ---------------------------------------------------------*/ 41 /* USER CODE BEGIN PV */ 42 /* USER CODE END PV */ 43 44 /* Private function prototypes -----------------------------------------------*/ 45 /* USER CODE BEGIN PFP */ 46 47 /* USER CODE END PFP */ 48 49 /* External functions --------------------------------------------------------*/ 50 /* USER CODE BEGIN ExternalFunctions */ 51 52 /* USER CODE END ExternalFunctions */ 53 54 /* USER CODE END 0 */ 55 /** 56 * Initializes the Global MSP. 57 */ HAL_MspInit(void)58void HAL_MspInit(void) 59 { 60 /* USER CODE BEGIN MspInit 0 */ 61 62 /* USER CODE END MspInit 0 */ 63 64 /* System interrupt init*/ 65 66 /* USER CODE BEGIN MspInit 1 */ 67 68 /* USER CODE END MspInit 1 */ 69 } 70 71 /** 72 * @brief UART MSP Initialization 73 * This function configures the hardware resources used in this example 74 * @param huart: UART handle pointer 75 * @retval None 76 */ HAL_UART_MspInit(UART_HandleTypeDef * huart)77void HAL_UART_MspInit(UART_HandleTypeDef* huart) 78 { 79 GPIO_InitTypeDef GPIO_InitStruct = {0}; 80 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 81 if(huart->Instance==LPUART1) 82 { 83 /* USER CODE BEGIN LPUART1_MspInit 0 */ 84 85 /* USER CODE END LPUART1_MspInit 0 */ 86 /** Initializes the peripherals clocks 87 */ 88 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1; 89 PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1; 90 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 91 { 92 Error_Handler(); 93 } 94 95 /* Peripheral clock enable */ 96 __HAL_RCC_LPUART1_CLK_ENABLE(); 97 98 __HAL_RCC_GPIOA_CLK_ENABLE(); 99 /**LPUART1 GPIO Configuration 100 PA3 ------> LPUART1_RX 101 PA2 ------> LPUART1_TX 102 */ 103 GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_2; 104 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; 105 GPIO_InitStruct.Pull = GPIO_PULLUP; 106 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 107 GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1; 108 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 109 110 /* USER CODE BEGIN LPUART1_MspInit 1 */ 111 112 /* USER CODE END LPUART1_MspInit 1 */ 113 } 114 115 } 116 117 /** 118 * @brief UART MSP De-Initialization 119 * This function freeze the hardware resources used in this example 120 * @param huart: UART handle pointer 121 * @retval None 122 */ HAL_UART_MspDeInit(UART_HandleTypeDef * huart)123void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) 124 { 125 if(huart->Instance==LPUART1) 126 { 127 /* USER CODE BEGIN LPUART1_MspDeInit 0 */ 128 129 /* USER CODE END LPUART1_MspDeInit 0 */ 130 /* Peripheral clock disable */ 131 __HAL_RCC_LPUART1_CLK_DISABLE(); 132 133 /**LPUART1 GPIO Configuration 134 PA3 ------> LPUART1_RX 135 PA2 ------> LPUART1_TX 136 */ 137 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_3|GPIO_PIN_2); 138 139 /* USER CODE BEGIN LPUART1_MspDeInit 1 */ 140 141 /* USER CODE END LPUART1_MspDeInit 1 */ 142 } 143 144 } 145 146 /* USER CODE BEGIN 1 */ 147 148 /* USER CODE END 1 */ 149 150 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 151