1 /* USER CODE BEGIN Header */
2 /**
3   ******************************************************************************
4   * File Name          : stm32f4xx_hal_msp.c
5   * Description        : This file provides code for the MSP Initialization
6   *                      and de-Initialization codes.
7   ******************************************************************************
8   ** This notice applies to any and all portions of this file
9   * that are not between comment pairs USER CODE BEGIN and
10   * USER CODE END. Other portions of this file, whether
11   * inserted by the user or by software development tools
12   * are owned by their respective copyright owners.
13   *
14   * COPYRIGHT(c) 2018 STMicroelectronics
15   *
16   * Redistribution and use in source and binary forms, with or without modification,
17   * are permitted provided that the following conditions are met:
18   *   1. Redistributions of source code must retain the above copyright notice,
19   *      this list of conditions and the following disclaimer.
20   *   2. Redistributions in binary form must reproduce the above copyright notice,
21   *      this list of conditions and the following disclaimer in the documentation
22   *      and/or other materials provided with the distribution.
23   *   3. Neither the name of STMicroelectronics nor the names of its contributors
24   *      may be used to endorse or promote products derived from this software
25   *      without specific prior written permission.
26   *
27   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37   *
38   ******************************************************************************
39   */
40 /* USER CODE END Header */
41 
42 /* Includes ------------------------------------------------------------------*/
43 #include "main.h"
44 /* USER CODE BEGIN Includes */
45 #include <drv_common.h>
46 /* USER CODE END Includes */
47 
48 /* Private typedef -----------------------------------------------------------*/
49 /* USER CODE BEGIN TD */
50 
51 /* USER CODE END TD */
52 
53 /* Private define ------------------------------------------------------------*/
54 /* USER CODE BEGIN Define */
55 
56 /* USER CODE END Define */
57 
58 /* Private macro -------------------------------------------------------------*/
59 /* USER CODE BEGIN Macro */
60 
61 /* USER CODE END Macro */
62 
63 /* Private variables ---------------------------------------------------------*/
64 /* USER CODE BEGIN PV */
65 
66 /* USER CODE END PV */
67 
68 /* Private function prototypes -----------------------------------------------*/
69 /* USER CODE BEGIN PFP */
70 
71 /* USER CODE END PFP */
72 
73 /* External functions --------------------------------------------------------*/
74 /* USER CODE BEGIN ExternalFunctions */
75 
76 /* USER CODE END ExternalFunctions */
77 
78 /* USER CODE BEGIN 0 */
79 
80 /* USER CODE END 0 */
81 
82 void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
83                     /**
84   * Initializes the Global MSP.
85   */
HAL_MspInit(void)86 void HAL_MspInit(void)
87 {
88   /* USER CODE BEGIN MspInit 0 */
89 
90   /* USER CODE END MspInit 0 */
91 
92   __HAL_RCC_SYSCFG_CLK_ENABLE();
93   __HAL_RCC_PWR_CLK_ENABLE();
94 
95   /* System interrupt init*/
96 
97   /* USER CODE BEGIN MspInit 1 */
98 
99   /* USER CODE END MspInit 1 */
100 }
101 
102 /**
103 * @brief ADC MSP Initialization
104 * This function configures the hardware resources used in this example
105 * @param hadc: ADC handle pointer
106 * @retval None
107 */
HAL_ADC_MspInit(ADC_HandleTypeDef * hadc)108 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
109 {
110   GPIO_InitTypeDef GPIO_InitStruct = {0};
111   if(hadc->Instance==ADC1)
112   {
113   /* USER CODE BEGIN ADC1_MspInit 0 */
114 
115   /* USER CODE END ADC1_MspInit 0 */
116     /* Peripheral clock enable */
117     __HAL_RCC_ADC1_CLK_ENABLE();
118 
119     __HAL_RCC_GPIOA_CLK_ENABLE();
120     /**ADC1 GPIO Configuration
121     PA5     ------> ADC1_IN5
122     */
123     GPIO_InitStruct.Pin = GPIO_PIN_5;
124     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
125     GPIO_InitStruct.Pull = GPIO_NOPULL;
126     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
127 
128   /* USER CODE BEGIN ADC1_MspInit 1 */
129 
130   /* USER CODE END ADC1_MspInit 1 */
131   }
132 
133 }
134 
135 /**
136 * @brief ADC MSP De-Initialization
137 * This function freeze the hardware resources used in this example
138 * @param hadc: ADC handle pointer
139 * @retval None
140 */
HAL_ADC_MspDeInit(ADC_HandleTypeDef * hadc)141 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
142 {
143   if(hadc->Instance==ADC1)
144   {
145   /* USER CODE BEGIN ADC1_MspDeInit 0 */
146 
147   /* USER CODE END ADC1_MspDeInit 0 */
148     /* Peripheral clock disable */
149     __HAL_RCC_ADC1_CLK_DISABLE();
150 
151     /**ADC1 GPIO Configuration
152     PA5     ------> ADC1_IN5
153     */
154     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5);
155 
156   /* USER CODE BEGIN ADC1_MspDeInit 1 */
157 
158   /* USER CODE END ADC1_MspDeInit 1 */
159   }
160 
161 }
162 
163 /**
164 * @brief I2C MSP Initialization
165 * This function configures the hardware resources used in this example
166 * @param hi2c: I2C handle pointer
167 * @retval None
168 */
HAL_I2C_MspInit(I2C_HandleTypeDef * hi2c)169 void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
170 {
171   GPIO_InitTypeDef GPIO_InitStruct = {0};
172   if(hi2c->Instance==I2C1)
173   {
174   /* USER CODE BEGIN I2C1_MspInit 0 */
175 
176   /* USER CODE END I2C1_MspInit 0 */
177 
178     __HAL_RCC_GPIOB_CLK_ENABLE();
179     /**I2C1 GPIO Configuration
180     PB6     ------> I2C1_SCL
181     PB9     ------> I2C1_SDA
182     */
183     GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9;
184     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
185     GPIO_InitStruct.Pull = GPIO_PULLUP;
186     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
187     GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
188     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
189 
190     /* Peripheral clock enable */
191     __HAL_RCC_I2C1_CLK_ENABLE();
192   /* USER CODE BEGIN I2C1_MspInit 1 */
193 
194   /* USER CODE END I2C1_MspInit 1 */
195   }
196 
197 }
198 
199 /**
200 * @brief I2C MSP De-Initialization
201 * This function freeze the hardware resources used in this example
202 * @param hi2c: I2C handle pointer
203 * @retval None
204 */
HAL_I2C_MspDeInit(I2C_HandleTypeDef * hi2c)205 void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
206 {
207   if(hi2c->Instance==I2C1)
208   {
209   /* USER CODE BEGIN I2C1_MspDeInit 0 */
210 
211   /* USER CODE END I2C1_MspDeInit 0 */
212     /* Peripheral clock disable */
213     __HAL_RCC_I2C1_CLK_DISABLE();
214 
215     /**I2C1 GPIO Configuration
216     PB6     ------> I2C1_SCL
217     PB9     ------> I2C1_SDA
218     */
219     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_9);
220 
221   /* USER CODE BEGIN I2C1_MspDeInit 1 */
222 
223   /* USER CODE END I2C1_MspDeInit 1 */
224   }
225 
226 }
227 
228 /**
229 * @brief RTC MSP Initialization
230 * This function configures the hardware resources used in this example
231 * @param hrtc: RTC handle pointer
232 * @retval None
233 */
HAL_RTC_MspInit(RTC_HandleTypeDef * hrtc)234 void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
235 {
236   if(hrtc->Instance==RTC)
237   {
238   /* USER CODE BEGIN RTC_MspInit 0 */
239 
240   /* USER CODE END RTC_MspInit 0 */
241     /* Peripheral clock enable */
242     __HAL_RCC_RTC_ENABLE();
243   /* USER CODE BEGIN RTC_MspInit 1 */
244 
245   /* USER CODE END RTC_MspInit 1 */
246   }
247 
248 }
249 
250 /**
251 * @brief RTC MSP De-Initialization
252 * This function freeze the hardware resources used in this example
253 * @param hrtc: RTC handle pointer
254 * @retval None
255 */
HAL_RTC_MspDeInit(RTC_HandleTypeDef * hrtc)256 void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
257 {
258   if(hrtc->Instance==RTC)
259   {
260   /* USER CODE BEGIN RTC_MspDeInit 0 */
261 
262   /* USER CODE END RTC_MspDeInit 0 */
263     /* Peripheral clock disable */
264     __HAL_RCC_RTC_DISABLE();
265   /* USER CODE BEGIN RTC_MspDeInit 1 */
266 
267   /* USER CODE END RTC_MspDeInit 1 */
268   }
269 
270 }
271 
272 /**
273 * @brief SPI MSP Initialization
274 * This function configures the hardware resources used in this example
275 * @param hspi: SPI handle pointer
276 * @retval None
277 */
HAL_SPI_MspInit(SPI_HandleTypeDef * hspi)278 void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
279 {
280   GPIO_InitTypeDef GPIO_InitStruct = {0};
281   if(hspi->Instance==SPI2)
282   {
283   /* USER CODE BEGIN SPI2_MspInit 0 */
284 
285   /* USER CODE END SPI2_MspInit 0 */
286     /* Peripheral clock enable */
287     __HAL_RCC_SPI2_CLK_ENABLE();
288 
289     __HAL_RCC_GPIOC_CLK_ENABLE();
290     __HAL_RCC_GPIOB_CLK_ENABLE();
291     /**SPI2 GPIO Configuration
292     PC2     ------> SPI2_MISO
293     PC3     ------> SPI2_MOSI
294     PB10     ------> SPI2_SCK
295     */
296     GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
297     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
298     GPIO_InitStruct.Pull = GPIO_NOPULL;
299     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
300     GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
301     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
302 
303     GPIO_InitStruct.Pin = GPIO_PIN_10;
304     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
305     GPIO_InitStruct.Pull = GPIO_NOPULL;
306     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
307     GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
308     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
309 
310   /* USER CODE BEGIN SPI2_MspInit 1 */
311 
312   /* USER CODE END SPI2_MspInit 1 */
313   }
314 
315 }
316 
317 /**
318 * @brief SPI MSP De-Initialization
319 * This function freeze the hardware resources used in this example
320 * @param hspi: SPI handle pointer
321 * @retval None
322 */
HAL_SPI_MspDeInit(SPI_HandleTypeDef * hspi)323 void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
324 {
325   if(hspi->Instance==SPI2)
326   {
327   /* USER CODE BEGIN SPI2_MspDeInit 0 */
328 
329   /* USER CODE END SPI2_MspDeInit 0 */
330     /* Peripheral clock disable */
331     __HAL_RCC_SPI2_CLK_DISABLE();
332 
333     /**SPI2 GPIO Configuration
334     PC2     ------> SPI2_MISO
335     PC3     ------> SPI2_MOSI
336     PB10     ------> SPI2_SCK
337     */
338     HAL_GPIO_DeInit(GPIOC, GPIO_PIN_2|GPIO_PIN_3);
339 
340     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
341 
342   /* USER CODE BEGIN SPI2_MspDeInit 1 */
343 
344   /* USER CODE END SPI2_MspDeInit 1 */
345   }
346 
347 }
348 
349 /**
350 * @brief TIM_Base MSP Initialization
351 * This function configures the hardware resources used in this example
352 * @param htim_base: TIM_Base handle pointer
353 * @retval None
354 */
HAL_TIM_Base_MspInit(TIM_HandleTypeDef * htim_base)355 void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
356 {
357   if(htim_base->Instance==TIM2)
358   {
359   /* USER CODE BEGIN TIM2_MspInit 0 */
360 
361   /* USER CODE END TIM2_MspInit 0 */
362     /* Peripheral clock enable */
363     __HAL_RCC_TIM2_CLK_ENABLE();
364   /* USER CODE BEGIN TIM2_MspInit 1 */
365 
366   /* USER CODE END TIM2_MspInit 1 */
367   }
368   else if(htim_base->Instance==TIM11)
369   {
370   /* USER CODE BEGIN TIM11_MspInit 0 */
371 
372   /* USER CODE END TIM11_MspInit 0 */
373     /* Peripheral clock enable */
374     __HAL_RCC_TIM11_CLK_ENABLE();
375   /* USER CODE BEGIN TIM11_MspInit 1 */
376 
377   /* USER CODE END TIM11_MspInit 1 */
378   }
379   else if(htim_base->Instance==TIM13)
380   {
381   /* USER CODE BEGIN TIM13_MspInit 0 */
382 
383   /* USER CODE END TIM13_MspInit 0 */
384     /* Peripheral clock enable */
385     __HAL_RCC_TIM13_CLK_ENABLE();
386   /* USER CODE BEGIN TIM13_MspInit 1 */
387 
388   /* USER CODE END TIM13_MspInit 1 */
389   }
390   else if(htim_base->Instance==TIM14)
391   {
392   /* USER CODE BEGIN TIM14_MspInit 0 */
393 
394   /* USER CODE END TIM14_MspInit 0 */
395     /* Peripheral clock enable */
396     __HAL_RCC_TIM14_CLK_ENABLE();
397   /* USER CODE BEGIN TIM14_MspInit 1 */
398 
399   /* USER CODE END TIM14_MspInit 1 */
400   }
401 
402 }
403 
HAL_TIM_MspPostInit(TIM_HandleTypeDef * htim)404 void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
405 {
406   GPIO_InitTypeDef GPIO_InitStruct = {0};
407   if(htim->Instance==TIM2)
408   {
409   /* USER CODE BEGIN TIM2_MspPostInit 0 */
410 
411   /* USER CODE END TIM2_MspPostInit 0 */
412 
413     __HAL_RCC_GPIOA_CLK_ENABLE();
414     /**TIM2 GPIO Configuration
415     PA3     ------> TIM2_CH4
416     */
417     GPIO_InitStruct.Pin = GPIO_PIN_3;
418     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
419     GPIO_InitStruct.Pull = GPIO_NOPULL;
420     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
421     GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
422     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
423 
424   /* USER CODE BEGIN TIM2_MspPostInit 1 */
425 
426   /* USER CODE END TIM2_MspPostInit 1 */
427   }
428 
429 }
430 /**
431 * @brief TIM_Base MSP De-Initialization
432 * This function freeze the hardware resources used in this example
433 * @param htim_base: TIM_Base handle pointer
434 * @retval None
435 */
HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef * htim_base)436 void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
437 {
438   if(htim_base->Instance==TIM2)
439   {
440   /* USER CODE BEGIN TIM2_MspDeInit 0 */
441 
442   /* USER CODE END TIM2_MspDeInit 0 */
443     /* Peripheral clock disable */
444     __HAL_RCC_TIM2_CLK_DISABLE();
445   /* USER CODE BEGIN TIM2_MspDeInit 1 */
446 
447   /* USER CODE END TIM2_MspDeInit 1 */
448   }
449   else if(htim_base->Instance==TIM11)
450   {
451   /* USER CODE BEGIN TIM11_MspDeInit 0 */
452 
453   /* USER CODE END TIM11_MspDeInit 0 */
454     /* Peripheral clock disable */
455     __HAL_RCC_TIM11_CLK_DISABLE();
456   /* USER CODE BEGIN TIM11_MspDeInit 1 */
457 
458   /* USER CODE END TIM11_MspDeInit 1 */
459   }
460   else if(htim_base->Instance==TIM13)
461   {
462   /* USER CODE BEGIN TIM13_MspDeInit 0 */
463 
464   /* USER CODE END TIM13_MspDeInit 0 */
465     /* Peripheral clock disable */
466     __HAL_RCC_TIM13_CLK_DISABLE();
467   /* USER CODE BEGIN TIM13_MspDeInit 1 */
468 
469   /* USER CODE END TIM13_MspDeInit 1 */
470   }
471   else if(htim_base->Instance==TIM14)
472   {
473   /* USER CODE BEGIN TIM14_MspDeInit 0 */
474 
475   /* USER CODE END TIM14_MspDeInit 0 */
476     /* Peripheral clock disable */
477     __HAL_RCC_TIM14_CLK_DISABLE();
478   /* USER CODE BEGIN TIM14_MspDeInit 1 */
479 
480   /* USER CODE END TIM14_MspDeInit 1 */
481   }
482 
483 }
484 
485 /**
486 * @brief UART MSP Initialization
487 * This function configures the hardware resources used in this example
488 * @param huart: UART handle pointer
489 * @retval None
490 */
HAL_UART_MspInit(UART_HandleTypeDef * huart)491 void HAL_UART_MspInit(UART_HandleTypeDef* huart)
492 {
493   GPIO_InitTypeDef GPIO_InitStruct = {0};
494   if(huart->Instance==USART2)
495   {
496   /* USER CODE BEGIN USART2_MspInit 0 */
497 
498   /* USER CODE END USART2_MspInit 0 */
499     /* Peripheral clock enable */
500     __HAL_RCC_USART2_CLK_ENABLE();
501 
502     __HAL_RCC_GPIOA_CLK_ENABLE();
503     __HAL_RCC_GPIOD_CLK_ENABLE();
504     /**USART2 GPIO Configuration
505     PA2     ------> USART2_TX
506     PD6     ------> USART2_RX
507     */
508     GPIO_InitStruct.Pin = GPIO_PIN_2;
509     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
510     GPIO_InitStruct.Pull = GPIO_PULLUP;
511     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
512     GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
513     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
514 
515     GPIO_InitStruct.Pin = GPIO_PIN_6;
516     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
517     GPIO_InitStruct.Pull = GPIO_PULLUP;
518     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
519     GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
520     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
521 
522   /* USER CODE BEGIN USART2_MspInit 1 */
523 
524   /* USER CODE END USART2_MspInit 1 */
525   }
526   else if(huart->Instance==USART3)
527   {
528   /* USER CODE BEGIN USART3_MspInit 0 */
529 
530   /* USER CODE END USART3_MspInit 0 */
531     /* Peripheral clock enable */
532     __HAL_RCC_USART3_CLK_ENABLE();
533 
534     __HAL_RCC_GPIOD_CLK_ENABLE();
535     /**USART3 GPIO Configuration
536     PD8     ------> USART3_TX
537     PD9     ------> USART3_RX
538     */
539     GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin;
540     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
541     GPIO_InitStruct.Pull = GPIO_PULLUP;
542     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
543     GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
544     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
545 
546   /* USER CODE BEGIN USART3_MspInit 1 */
547 
548   /* USER CODE END USART3_MspInit 1 */
549   }
550 
551 }
552 
553 /**
554 * @brief UART MSP De-Initialization
555 * This function freeze the hardware resources used in this example
556 * @param huart: UART handle pointer
557 * @retval None
558 */
HAL_UART_MspDeInit(UART_HandleTypeDef * huart)559 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
560 {
561   if(huart->Instance==USART2)
562   {
563   /* USER CODE BEGIN USART2_MspDeInit 0 */
564 
565   /* USER CODE END USART2_MspDeInit 0 */
566     /* Peripheral clock disable */
567     __HAL_RCC_USART2_CLK_DISABLE();
568 
569     /**USART2 GPIO Configuration
570     PA2     ------> USART2_TX
571     PD6     ------> USART2_RX
572     */
573     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2);
574 
575     HAL_GPIO_DeInit(GPIOD, GPIO_PIN_6);
576 
577   /* USER CODE BEGIN USART2_MspDeInit 1 */
578 
579   /* USER CODE END USART2_MspDeInit 1 */
580   }
581   else if(huart->Instance==USART3)
582   {
583   /* USER CODE BEGIN USART3_MspDeInit 0 */
584 
585   /* USER CODE END USART3_MspDeInit 0 */
586     /* Peripheral clock disable */
587     __HAL_RCC_USART3_CLK_DISABLE();
588 
589     /**USART3 GPIO Configuration
590     PD8     ------> USART3_TX
591     PD9     ------> USART3_RX
592     */
593     HAL_GPIO_DeInit(GPIOD, STLK_RX_Pin|STLK_TX_Pin);
594 
595   /* USER CODE BEGIN USART3_MspDeInit 1 */
596 
597   /* USER CODE END USART3_MspDeInit 1 */
598   }
599 
600 }
601 
602 /**
603 * @brief PCD MSP Initialization
604 * This function configures the hardware resources used in this example
605 * @param hpcd: PCD handle pointer
606 * @retval None
607 */
HAL_PCD_MspInit(PCD_HandleTypeDef * hpcd)608 void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
609 {
610   GPIO_InitTypeDef GPIO_InitStruct = {0};
611   if(hpcd->Instance==USB_OTG_FS)
612   {
613   /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
614 
615   /* USER CODE END USB_OTG_FS_MspInit 0 */
616 
617     __HAL_RCC_GPIOA_CLK_ENABLE();
618     /**USB_OTG_FS GPIO Configuration
619     PA8     ------> USB_OTG_FS_SOF
620     PA9     ------> USB_OTG_FS_VBUS
621     PA10     ------> USB_OTG_FS_ID
622     PA11     ------> USB_OTG_FS_DM
623     PA12     ------> USB_OTG_FS_DP
624     */
625     GPIO_InitStruct.Pin = USB_SOF_Pin|USB_ID_Pin|USB_DM_Pin|USB_DP_Pin;
626     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
627     GPIO_InitStruct.Pull = GPIO_NOPULL;
628     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
629     GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
630     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
631 
632     GPIO_InitStruct.Pin = USB_VBUS_Pin;
633     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
634     GPIO_InitStruct.Pull = GPIO_NOPULL;
635     HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);
636 
637     /* Peripheral clock enable */
638     __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
639   /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
640 
641   /* USER CODE END USB_OTG_FS_MspInit 1 */
642   }
643 
644 }
645 
646 /**
647 * @brief PCD MSP De-Initialization
648 * This function freeze the hardware resources used in this example
649 * @param hpcd: PCD handle pointer
650 * @retval None
651 */
HAL_PCD_MspDeInit(PCD_HandleTypeDef * hpcd)652 void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
653 {
654   if(hpcd->Instance==USB_OTG_FS)
655   {
656   /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
657 
658   /* USER CODE END USB_OTG_FS_MspDeInit 0 */
659     /* Peripheral clock disable */
660     __HAL_RCC_USB_OTG_FS_CLK_DISABLE();
661 
662     /**USB_OTG_FS GPIO Configuration
663     PA8     ------> USB_OTG_FS_SOF
664     PA9     ------> USB_OTG_FS_VBUS
665     PA10     ------> USB_OTG_FS_ID
666     PA11     ------> USB_OTG_FS_DM
667     PA12     ------> USB_OTG_FS_DP
668     */
669     HAL_GPIO_DeInit(GPIOA, USB_SOF_Pin|USB_VBUS_Pin|USB_ID_Pin|USB_DM_Pin
670                           |USB_DP_Pin);
671 
672   /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
673 
674   /* USER CODE END USB_OTG_FS_MspDeInit 1 */
675   }
676 
677 }
678 
679 /* USER CODE BEGIN 1 */
680 
681 /* USER CODE END 1 */
682 
683 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
684