1 | /* USER CODE BEGIN Header */ |
---|
2 | /** |
---|
3 | ****************************************************************************** |
---|
4 | * @file : main.c |
---|
5 | * @brief : Main program body |
---|
6 | ****************************************************************************** |
---|
7 | * @attention |
---|
8 | * |
---|
9 | * Copyright (c) 2025 STMicroelectronics. |
---|
10 | * All rights reserved. |
---|
11 | * |
---|
12 | * This software is licensed under terms that can be found in the LICENSE file |
---|
13 | * in the root directory of this software component. |
---|
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
---|
15 | * |
---|
16 | ****************************************************************************** |
---|
17 | */ |
---|
18 | /* USER CODE END Header */ |
---|
19 | /* Includes ------------------------------------------------------------------*/ |
---|
20 | #include "main.h" |
---|
21 | #include "adc.h" |
---|
22 | #include "crc.h" |
---|
23 | #include "dma.h" |
---|
24 | #include "fdcan.h" |
---|
25 | #include "i2c.h" |
---|
26 | #include "spi.h" |
---|
27 | #include "usart.h" |
---|
28 | #include "usb.h" |
---|
29 | #include "gpio.h" |
---|
30 | |
---|
31 | /* Private includes ----------------------------------------------------------*/ |
---|
32 | /* USER CODE BEGIN Includes */ |
---|
33 | |
---|
34 | /* USER CODE END Includes */ |
---|
35 | |
---|
36 | /* Private typedef -----------------------------------------------------------*/ |
---|
37 | /* USER CODE BEGIN PTD */ |
---|
38 | |
---|
39 | /* USER CODE END PTD */ |
---|
40 | |
---|
41 | /* Private define ------------------------------------------------------------*/ |
---|
42 | /* USER CODE BEGIN PD */ |
---|
43 | |
---|
44 | /* USER CODE END PD */ |
---|
45 | |
---|
46 | /* Private macro -------------------------------------------------------------*/ |
---|
47 | /* USER CODE BEGIN PM */ |
---|
48 | |
---|
49 | /* USER CODE END PM */ |
---|
50 | |
---|
51 | /* Private variables ---------------------------------------------------------*/ |
---|
52 | |
---|
53 | /* USER CODE BEGIN PV */ |
---|
54 | |
---|
55 | /* USER CODE END PV */ |
---|
56 | |
---|
57 | /* Private function prototypes -----------------------------------------------*/ |
---|
58 | void SystemClock_Config(void); |
---|
59 | /* USER CODE BEGIN PFP */ |
---|
60 | |
---|
61 | /* USER CODE END PFP */ |
---|
62 | |
---|
63 | /* Private user code ---------------------------------------------------------*/ |
---|
64 | /* USER CODE BEGIN 0 */ |
---|
65 | |
---|
66 | /* USER CODE END 0 */ |
---|
67 | |
---|
68 | /** |
---|
69 | * @brief The application entry point. |
---|
70 | * @retval int |
---|
71 | */ |
---|
72 | int main(void) |
---|
73 | { |
---|
74 | |
---|
75 | /* USER CODE BEGIN 1 */ |
---|
76 | |
---|
77 | /* USER CODE END 1 */ |
---|
78 | |
---|
79 | /* MCU Configuration--------------------------------------------------------*/ |
---|
80 | |
---|
81 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
---|
82 | HAL_Init(); |
---|
83 | |
---|
84 | /* USER CODE BEGIN Init */ |
---|
85 | |
---|
86 | /* USER CODE END Init */ |
---|
87 | |
---|
88 | /* Configure the system clock */ |
---|
89 | SystemClock_Config(); |
---|
90 | |
---|
91 | /* USER CODE BEGIN SysInit */ |
---|
92 | |
---|
93 | /* USER CODE END SysInit */ |
---|
94 | |
---|
95 | /* Initialize all configured peripherals */ |
---|
96 | MX_GPIO_Init(); |
---|
97 | MX_DMA_Init(); |
---|
98 | MX_ADC1_Init(); |
---|
99 | MX_ADC2_Init(); |
---|
100 | MX_ADC3_Init(); |
---|
101 | MX_ADC4_Init(); |
---|
102 | MX_ADC5_Init(); |
---|
103 | MX_FDCAN2_Init(); |
---|
104 | MX_FDCAN3_Init(); |
---|
105 | MX_I2C3_Init(); |
---|
106 | MX_I2C4_Init(); |
---|
107 | MX_SPI3_Init(); |
---|
108 | MX_USART1_UART_Init(); |
---|
109 | MX_USART2_UART_Init(); |
---|
110 | MX_USB_PCD_Init(); |
---|
111 | MX_CRC_Init(); |
---|
112 | /* USER CODE BEGIN 2 */ |
---|
113 | |
---|
114 | /* USER CODE END 2 */ |
---|
115 | |
---|
116 | /* Infinite loop */ |
---|
117 | /* USER CODE BEGIN WHILE */ |
---|
118 | while (1) |
---|
119 | { |
---|
120 | /* USER CODE END WHILE */ |
---|
121 | |
---|
122 | /* USER CODE BEGIN 3 */ |
---|
123 | } |
---|
124 | /* USER CODE END 3 */ |
---|
125 | } |
---|
126 | |
---|
127 | /** |
---|
128 | * @brief System Clock Configuration |
---|
129 | * @retval None |
---|
130 | */ |
---|
131 | void SystemClock_Config(void) |
---|
132 | { |
---|
133 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
---|
134 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
---|
135 | |
---|
136 | /** Configure the main internal regulator output voltage |
---|
137 | */ |
---|
138 | HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); |
---|
139 | |
---|
140 | /** Initializes the RCC Oscillators according to the specified parameters |
---|
141 | * in the RCC_OscInitTypeDef structure. |
---|
142 | */ |
---|
143 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE; |
---|
144 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
---|
145 | RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; |
---|
146 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
---|
147 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
---|
148 | RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2; |
---|
149 | RCC_OscInitStruct.PLL.PLLN = 16; |
---|
150 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; |
---|
151 | RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; |
---|
152 | RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; |
---|
153 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
---|
154 | { |
---|
155 | Error_Handler(); |
---|
156 | } |
---|
157 | |
---|
158 | /** Initializes the CPU, AHB and APB buses clocks |
---|
159 | */ |
---|
160 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
---|
161 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
---|
162 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
---|
163 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
---|
164 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
---|
165 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
---|
166 | |
---|
167 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) |
---|
168 | { |
---|
169 | Error_Handler(); |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | /* USER CODE BEGIN 4 */ |
---|
174 | |
---|
175 | /* USER CODE END 4 */ |
---|
176 | |
---|
177 | /** |
---|
178 | * @brief This function is executed in case of error occurrence. |
---|
179 | * @retval None |
---|
180 | */ |
---|
181 | void Error_Handler(void) |
---|
182 | { |
---|
183 | /* USER CODE BEGIN Error_Handler_Debug */ |
---|
184 | /* User can add his own implementation to report the HAL error return state */ |
---|
185 | __disable_irq(); |
---|
186 | while (1) |
---|
187 | { |
---|
188 | } |
---|
189 | /* USER CODE END Error_Handler_Debug */ |
---|
190 | } |
---|
191 | #ifdef USE_FULL_ASSERT |
---|
192 | /** |
---|
193 | * @brief Reports the name of the source file and the source line number |
---|
194 | * where the assert_param error has occurred. |
---|
195 | * @param file: pointer to the source file name |
---|
196 | * @param line: assert_param error line source number |
---|
197 | * @retval None |
---|
198 | */ |
---|
199 | void assert_failed(uint8_t *file, uint32_t line) |
---|
200 | { |
---|
201 | /* USER CODE BEGIN 6 */ |
---|
202 | /* User can add his own implementation to report the file name and line number, |
---|
203 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
---|
204 | /* USER CODE END 6 */ |
---|
205 | } |
---|
206 | #endif /* USE_FULL_ASSERT */ |
---|