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>© 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
25 /* USER CODE END 0 */
26 /**
27 * Initializes the Global MSP.
28 */
HAL_MspInit(void)29 void HAL_MspInit(void)
30 {
31 /* USER CODE BEGIN MspInit 0 */
32
33 /* USER CODE END MspInit 0 */
34
35 __HAL_RCC_SYSCFG_CLK_ENABLE();
36 __HAL_RCC_PWR_CLK_ENABLE();
37
38 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
39
40 /* System interrupt init*/
41 /* MemoryManagement_IRQn interrupt configuration */
42 HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
43 /* BusFault_IRQn interrupt configuration */
44 HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
45 /* UsageFault_IRQn interrupt configuration */
46 HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
47 /* SVCall_IRQn interrupt configuration */
48 HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
49 /* DebugMonitor_IRQn interrupt configuration */
50 HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
51 /* PendSV_IRQn interrupt configuration */
52 HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
53 /* SysTick_IRQn interrupt configuration */
54 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
55
56 /* USER CODE BEGIN MspInit 1 */
57
58 /* USER CODE END MspInit 1 */
59 }
60
HAL_RTC_MspInit(RTC_HandleTypeDef * hrtc)61 void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
62 {
63
64 if(hrtc->Instance==RTC)
65 {
66 /* USER CODE BEGIN RTC_MspInit 0 */
67
68 /* USER CODE END RTC_MspInit 0 */
69 /* Peripheral clock enable */
70 __HAL_RCC_RTC_ENABLE();
71 /* USER CODE BEGIN RTC_MspInit 1 */
72
73 /* USER CODE END RTC_MspInit 1 */
74 }
75
76 }
77
HAL_RTC_MspDeInit(RTC_HandleTypeDef * hrtc)78 void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
79 {
80
81 if(hrtc->Instance==RTC)
82 {
83 /* USER CODE BEGIN RTC_MspDeInit 0 */
84
85 /* USER CODE END RTC_MspDeInit 0 */
86 /* Peripheral clock disable */
87 __HAL_RCC_RTC_DISABLE();
88 /* USER CODE BEGIN RTC_MspDeInit 1 */
89
90 /* USER CODE END RTC_MspDeInit 1 */
91 }
92
93 }
94
HAL_UART_MspInit(UART_HandleTypeDef * huart)95 void HAL_UART_MspInit(UART_HandleTypeDef* huart)
96 {
97
98 GPIO_InitTypeDef GPIO_InitStruct;
99 if(huart->Instance==USART2)
100 {
101 /* USER CODE BEGIN USART2_MspInit 0 */
102
103 /* USER CODE END USART2_MspInit 0 */
104 /* Peripheral clock enable */
105 __HAL_RCC_USART2_CLK_ENABLE();
106
107 /**USART2 GPIO Configuration
108 PA2 ------> USART2_TX
109 PA15 (JTDI) ------> USART2_RX
110 */
111 GPIO_InitStruct.Pin = VCP_TX_Pin;
112 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
113 GPIO_InitStruct.Pull = GPIO_PULLUP;
114 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
115 GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
116 HAL_GPIO_Init(VCP_TX_GPIO_Port, &GPIO_InitStruct);
117
118 GPIO_InitStruct.Pin = VCP_RX_Pin;
119 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
120 GPIO_InitStruct.Pull = GPIO_PULLUP;
121 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
122 GPIO_InitStruct.Alternate = GPIO_AF3_USART2;
123 HAL_GPIO_Init(VCP_RX_GPIO_Port, &GPIO_InitStruct);
124
125 /* USER CODE BEGIN USART2_MspInit 1 */
126
127 /* USER CODE END USART2_MspInit 1 */
128 }
129
130 }
131
HAL_UART_MspDeInit(UART_HandleTypeDef * huart)132 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
133 {
134
135 if(huart->Instance==USART2)
136 {
137 /* USER CODE BEGIN USART2_MspDeInit 0 */
138
139 /* USER CODE END USART2_MspDeInit 0 */
140 /* Peripheral clock disable */
141 __HAL_RCC_USART2_CLK_DISABLE();
142
143 /**USART2 GPIO Configuration
144 PA2 ------> USART2_TX
145 PA15 (JTDI) ------> USART2_RX
146 */
147 HAL_GPIO_DeInit(GPIOA, VCP_TX_Pin|VCP_RX_Pin);
148
149 /* USER CODE BEGIN USART2_MspDeInit 1 */
150
151 /* USER CODE END USART2_MspDeInit 1 */
152 }
153
154 }
155
156 /* USER CODE BEGIN 1 */
157
158 /* USER CODE END 1 */
159
160 /**
161 * @}
162 */
163
164 /**
165 * @}
166 */
167
168 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
169