1 /* USER CODE BEGIN Header */
3 ******************************************************************************
5 * @brief : Main program body
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2021 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under Ultimate Liberty license
13 * SLA0044, the "License"; You may not use this file except in compliance with
14 * the License. You may obtain a copy of the License at:
17 ******************************************************************************
19 /* USER CODE END Header */
21 /* Includes ------------------------------------------------------------------*/
28 #include "usb_device.h"
32 /* Private includes ----------------------------------------------------------*/
33 /* USER CODE BEGIN Includes */
35 /* USER CODE END Includes */
37 /* Private typedef -----------------------------------------------------------*/
38 /* USER CODE BEGIN PTD */
40 /* USER CODE END PTD */
42 /* Private define ------------------------------------------------------------*/
43 /* USER CODE BEGIN PD */
44 /* USER CODE END PD */
46 /* Private macro -------------------------------------------------------------*/
47 /* USER CODE BEGIN PM */
49 /* USER CODE END PM */
51 /* Private variables ---------------------------------------------------------*/
53 /* USER CODE BEGIN PV */
55 /* USER CODE END PV */
57 /* Private function prototypes -----------------------------------------------*/
58 void SystemClock_Config(void);
59 /* USER CODE BEGIN PFP */
60 /* Private function prototypes -----------------------------------------------*/
65 /* USER CODE END PFP */
67 /* Private user code ---------------------------------------------------------*/
68 /* USER CODE BEGIN 0 */
73 * @brief The application entry point.
78 /* USER CODE BEGIN 1 */
84 /* MCU Configuration--------------------------------------------------------*/
86 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
89 /* USER CODE BEGIN Init */
91 /* USER CODE END Init */
93 /* Configure the system clock */
96 /* USER CODE BEGIN SysInit */
98 /* USER CODE END SysInit */
100 /* Initialize all configured peripherals */
107 /* USER CODE BEGIN 2 */
109 /* USER CODE END 2 */
112 /* USER CODE BEGIN WHILE */
115 /* USER CODE END WHILE */
117 /* USER CODE BEGIN 3 */
120 /* USER CODE END 3 */
124 * @brief System Clock Configuration
127 void SystemClock_Config(void)
129 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
130 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
132 /** Initializes the CPU, AHB and APB busses clocks
134 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
135 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
136 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
137 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
138 RCC_OscInitStruct.PLL.PLLM = 12;
139 RCC_OscInitStruct.PLL.PLLN = 432;
140 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
141 RCC_OscInitStruct.PLL.PLLQ = 9;
142 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
146 /** Initializes the CPU, AHB and APB busses clocks
148 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
149 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
150 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
151 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
152 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
153 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
155 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
159 HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_PLLCLK, RCC_MCODIV_1);
162 /* USER CODE BEGIN 4 */
164 /* USER CODE END 4 */
167 * @brief This function is executed in case of error occurrence.
170 void Error_Handler(void)
172 /* USER CODE BEGIN Error_Handler_Debug */
173 /* User can add his own implementation to report the HAL error return state */
175 /* USER CODE END Error_Handler_Debug */
178 #ifdef USE_FULL_ASSERT
180 * @brief Reports the name of the source file and the source line number
181 * where the assert_param error has occurred.
182 * @param file: pointer to the source file name
183 * @param line: assert_param error line source number
186 void assert_failed(uint8_t *file, uint32_t line)
188 /* USER CODE BEGIN 6 */
189 /* User can add his own implementation to report the file name and line number,
190 tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
191 /* USER CODE END 6 */
193 #endif /* USE_FULL_ASSERT */
195 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/