source: trunk/fw_g473rct/Core/Src/usb.c

Last change on this file was 20, checked in by f.jahn, 4 months ago

adc dma funktioniert und modbus funktioniert

File size: 2.6 KB
Line 
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file usb.c
5 * @brief This file provides code for the configuration
6 * of the USB instances.
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2025 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19/* USER CODE END Header */
20/* Includes ------------------------------------------------------------------*/
21#include "usb.h"
22
23/* USER CODE BEGIN 0 */
24
25/* USER CODE END 0 */
26
27PCD_HandleTypeDef hpcd_USB_FS;
28
29/* USB init function */
30
31void MX_USB_PCD_Init(void)
32{
33
34 /* USER CODE BEGIN USB_Init 0 */
35
36 /* USER CODE END USB_Init 0 */
37
38 /* USER CODE BEGIN USB_Init 1 */
39
40 /* USER CODE END USB_Init 1 */
41 hpcd_USB_FS.Instance = USB;
42 hpcd_USB_FS.Init.dev_endpoints = 8;
43 hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
44 hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
45 hpcd_USB_FS.Init.Sof_enable = DISABLE;
46 hpcd_USB_FS.Init.low_power_enable = DISABLE;
47 hpcd_USB_FS.Init.lpm_enable = DISABLE;
48 hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
49 if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
50 {
51 Error_Handler();
52 }
53 /* USER CODE BEGIN USB_Init 2 */
54
55 /* USER CODE END USB_Init 2 */
56
57}
58
59void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
60{
61
62 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
63 if(pcdHandle->Instance==USB)
64 {
65 /* USER CODE BEGIN USB_MspInit 0 */
66
67 /* USER CODE END USB_MspInit 0 */
68
69 /** Initializes the peripherals clocks
70 */
71 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
72 PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
73 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
74 {
75 Error_Handler();
76 }
77
78 /* USB clock enable */
79 __HAL_RCC_USB_CLK_ENABLE();
80 /* USER CODE BEGIN USB_MspInit 1 */
81
82 /* USER CODE END USB_MspInit 1 */
83 }
84}
85
86void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
87{
88
89 if(pcdHandle->Instance==USB)
90 {
91 /* USER CODE BEGIN USB_MspDeInit 0 */
92
93 /* USER CODE END USB_MspDeInit 0 */
94 /* Peripheral clock disable */
95 __HAL_RCC_USB_CLK_DISABLE();
96 /* USER CODE BEGIN USB_MspDeInit 1 */
97
98 /* USER CODE END USB_MspDeInit 1 */
99 }
100}
101
102/* USER CODE BEGIN 1 */
103
104/* USER CODE END 1 */
Note: See TracBrowser for help on using the repository browser.