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