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 "dma.h" |
---|
23 | #include "tim.h" |
---|
24 | #include "usart.h" |
---|
25 | #include "gpio.h" |
---|
26 | |
---|
27 | /* Private includes ----------------------------------------------------------*/ |
---|
28 | /* USER CODE BEGIN Includes */ |
---|
29 | |
---|
30 | /* USER CODE END Includes */ |
---|
31 | |
---|
32 | /* Private typedef -----------------------------------------------------------*/ |
---|
33 | /* USER CODE BEGIN PTD */ |
---|
34 | |
---|
35 | /* USER CODE END PTD */ |
---|
36 | |
---|
37 | /* Private define ------------------------------------------------------------*/ |
---|
38 | /* USER CODE BEGIN PD */ |
---|
39 | |
---|
40 | /* USER CODE END PD */ |
---|
41 | |
---|
42 | /* Private macro -------------------------------------------------------------*/ |
---|
43 | /* USER CODE BEGIN PM */ |
---|
44 | |
---|
45 | /* USER CODE END PM */ |
---|
46 | |
---|
47 | /* Private variables ---------------------------------------------------------*/ |
---|
48 | |
---|
49 | /* USER CODE BEGIN PV */ |
---|
50 | |
---|
51 | /* USER CODE END PV */ |
---|
52 | |
---|
53 | /* Private function prototypes -----------------------------------------------*/ |
---|
54 | void SystemClock_Config(void); |
---|
55 | /* USER CODE BEGIN PFP */ |
---|
56 | |
---|
57 | /* USER CODE END PFP */ |
---|
58 | |
---|
59 | /* Private user code ---------------------------------------------------------*/ |
---|
60 | /* USER CODE BEGIN 0 */ |
---|
61 | |
---|
62 | /* USER CODE END 0 */ |
---|
63 | |
---|
64 | /** |
---|
65 | * @brief The application entry point. |
---|
66 | * @retval int |
---|
67 | */ |
---|
68 | int main(void) |
---|
69 | { |
---|
70 | |
---|
71 | /* USER CODE BEGIN 1 */ |
---|
72 | |
---|
73 | /* USER CODE END 1 */ |
---|
74 | |
---|
75 | /* MCU Configuration--------------------------------------------------------*/ |
---|
76 | |
---|
77 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ |
---|
78 | HAL_Init(); |
---|
79 | |
---|
80 | /* USER CODE BEGIN Init */ |
---|
81 | |
---|
82 | /* USER CODE END Init */ |
---|
83 | |
---|
84 | /* Configure the system clock */ |
---|
85 | SystemClock_Config(); |
---|
86 | |
---|
87 | /* USER CODE BEGIN SysInit */ |
---|
88 | |
---|
89 | /* USER CODE END SysInit */ |
---|
90 | |
---|
91 | /* Initialize all configured peripherals */ |
---|
92 | MX_GPIO_Init(); |
---|
93 | MX_DMA_Init(); |
---|
94 | MX_ADC1_Init(); |
---|
95 | MX_TIM17_Init(); |
---|
96 | MX_USART1_UART_Init(); |
---|
97 | MX_TIM16_Init(); |
---|
98 | /* USER CODE BEGIN 2 */ |
---|
99 | |
---|
100 | /* USER CODE END 2 */ |
---|
101 | |
---|
102 | /* Infinite loop */ |
---|
103 | /* USER CODE BEGIN WHILE */ |
---|
104 | while (1) |
---|
105 | { |
---|
106 | /* USER CODE END WHILE */ |
---|
107 | |
---|
108 | /* USER CODE BEGIN 3 */ |
---|
109 | } |
---|
110 | /* USER CODE END 3 */ |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * @brief System Clock Configuration |
---|
115 | * @retval None |
---|
116 | */ |
---|
117 | void SystemClock_Config(void) |
---|
118 | { |
---|
119 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
---|
120 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
---|
121 | |
---|
122 | __HAL_FLASH_SET_LATENCY(FLASH_LATENCY_0); |
---|
123 | |
---|
124 | /** Initializes the RCC Oscillators according to the specified parameters |
---|
125 | * in the RCC_OscInitTypeDef structure. |
---|
126 | */ |
---|
127 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; |
---|
128 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
---|
129 | RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV4; |
---|
130 | RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
---|
131 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) |
---|
132 | { |
---|
133 | Error_Handler(); |
---|
134 | } |
---|
135 | |
---|
136 | /** Initializes the CPU, AHB and APB buses clocks |
---|
137 | */ |
---|
138 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
---|
139 | |RCC_CLOCKTYPE_PCLK1; |
---|
140 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; |
---|
141 | RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; |
---|
142 | RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; |
---|
143 | RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1; |
---|
144 | |
---|
145 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) |
---|
146 | { |
---|
147 | Error_Handler(); |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | /* USER CODE BEGIN 4 */ |
---|
152 | |
---|
153 | /* USER CODE END 4 */ |
---|
154 | |
---|
155 | /** |
---|
156 | * @brief This function is executed in case of error occurrence. |
---|
157 | * @retval None |
---|
158 | */ |
---|
159 | void Error_Handler(void) |
---|
160 | { |
---|
161 | /* USER CODE BEGIN Error_Handler_Debug */ |
---|
162 | /* User can add his own implementation to report the HAL error return state */ |
---|
163 | __disable_irq(); |
---|
164 | while (1) |
---|
165 | { |
---|
166 | } |
---|
167 | /* USER CODE END Error_Handler_Debug */ |
---|
168 | } |
---|
169 | #ifdef USE_FULL_ASSERT |
---|
170 | /** |
---|
171 | * @brief Reports the name of the source file and the source line number |
---|
172 | * where the assert_param error has occurred. |
---|
173 | * @param file: pointer to the source file name |
---|
174 | * @param line: assert_param error line source number |
---|
175 | * @retval None |
---|
176 | */ |
---|
177 | void assert_failed(uint8_t *file, uint32_t line) |
---|
178 | { |
---|
179 | /* USER CODE BEGIN 6 */ |
---|
180 | /* User can add his own implementation to report the file name and line number, |
---|
181 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
---|
182 | /* USER CODE END 6 */ |
---|
183 | } |
---|
184 | #endif /* USE_FULL_ASSERT */ |
---|