source: trunk/firmware_v5/CubeMX/Core/Src/main.c

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