1 /* USER CODE BEGIN Header */
2 /**
3   ******************************************************************************
4   * File Name          : stm32wbxx_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) 2020 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 
31 /* USER CODE END TD */
32 
33 /* Private define ------------------------------------------------------------*/
34 /* USER CODE BEGIN Define */
35 
36 /* USER CODE END Define */
37 
38 /* Private macro -------------------------------------------------------------*/
39 /* USER CODE BEGIN Macro */
40 
41 /* USER CODE END Macro */
42 
43 /* Private variables ---------------------------------------------------------*/
44 /* USER CODE BEGIN PV */
45 
46 /* USER CODE END PV */
47 
48 /* Private function prototypes -----------------------------------------------*/
49 /* USER CODE BEGIN PFP */
50 
51 /* USER CODE END PFP */
52 
53 /* External functions --------------------------------------------------------*/
54 /* USER CODE BEGIN ExternalFunctions */
55 
56 /* USER CODE END ExternalFunctions */
57 
58 /* USER CODE BEGIN 0 */
59 
60 /* USER CODE END 0 */
61 /**
62   * Initializes the Global MSP.
63   */
HAL_MspInit(void)64 void HAL_MspInit(void)
65 {
66   /* USER CODE BEGIN MspInit 0 */
67 
68   /* USER CODE END MspInit 0 */
69 
70   /* System interrupt init*/
71 
72   /* USER CODE BEGIN MspInit 1 */
73 
74   /* USER CODE END MspInit 1 */
75 }
76 
77 /**
78 * @brief UART MSP Initialization
79 * This function configures the hardware resources used in this example
80 * @param huart: UART handle pointer
81 * @retval None
82 */
HAL_UART_MspInit(UART_HandleTypeDef * huart)83 void HAL_UART_MspInit(UART_HandleTypeDef* huart)
84 {
85   GPIO_InitTypeDef GPIO_InitStruct = {0};
86   if(huart->Instance==USART1)
87   {
88   /* USER CODE BEGIN USART1_MspInit 0 */
89 
90   /* USER CODE END USART1_MspInit 0 */
91     /* Peripheral clock enable */
92     __HAL_RCC_USART1_CLK_ENABLE();
93 
94     __HAL_RCC_GPIOB_CLK_ENABLE();
95     /**USART1 GPIO Configuration
96     PB6     ------> USART1_TX
97     PB7     ------> USART1_RX
98     */
99     GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
100     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
101     GPIO_InitStruct.Pull = GPIO_PULLUP;
102     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
103     GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
104     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
105 
106   /* USER CODE BEGIN USART1_MspInit 1 */
107 
108   /* USER CODE END USART1_MspInit 1 */
109   }
110 
111 }
112 
113 /**
114 * @brief UART MSP De-Initialization
115 * This function freeze the hardware resources used in this example
116 * @param huart: UART handle pointer
117 * @retval None
118 */
HAL_UART_MspDeInit(UART_HandleTypeDef * huart)119 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
120 {
121   if(huart->Instance==USART1)
122   {
123   /* USER CODE BEGIN USART1_MspDeInit 0 */
124 
125   /* USER CODE END USART1_MspDeInit 0 */
126     /* Peripheral clock disable */
127     __HAL_RCC_USART1_CLK_DISABLE();
128 
129     /**USART1 GPIO Configuration
130     PB6     ------> USART1_TX
131     PB7     ------> USART1_RX
132     */
133     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
134 
135   /* USER CODE BEGIN USART1_MspDeInit 1 */
136 
137   /* USER CODE END USART1_MspDeInit 1 */
138   }
139 
140 }
141 
142 /* USER CODE BEGIN 1 */
143 
144 /* USER CODE END 1 */
145 
146 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
147