#Include: "Main.h"
#Include: "Main.h"
#Include: "Main.h"
Page 1
main.c Thursday, March 21, 2024, 4:46 PM
65 int i;
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 /* Configure the peripherals common clocks */
92 PeriphCommonClock_Config();
93
94 /* USER CODE BEGIN SysInit */
95
96 /* USER CODE END SysInit */
97
98 /* Initialize all configured peripherals */
99 MX_GPIO_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 if(Opt_stat==1)
109 {
110 HAL_GPIO_TogglePin(GPIOB,LED1_Pin);
111 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
112 HAL_Delay(100);
113 }
114 if (SW1c_stat>=2)
115 {
116 SW1c_stat=0;
117 for(i = 0; i <= 7; i++)
118 {
119 HAL_GPIO_TogglePin(GPIOB,LED3_Pin);
120 HAL_Delay(100);
121 }
122 }
123 if (SW2c_stat>=2)
124 {
125 SW2c_stat=0;
126 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
127 HAL_Delay(100);
128 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
Page 2
main.c Thursday, March 21, 2024, 4:46 PM
129 HAL_Delay(100);
130 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
131 HAL_Delay(100);
132 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
133 HAL_Delay(100);
134 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
135 HAL_Delay(100);
136 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
137 HAL_Delay(100);
138
139 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
140 HAL_Delay(200);
141 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
142 HAL_Delay(200);
143 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
144 HAL_Delay(200);
145 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
146 HAL_Delay(200);
147 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
148 HAL_Delay(200);
149 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
150 HAL_Delay(200);
151
152 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
153 HAL_Delay(100);
154 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
155 HAL_Delay(100);
156 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
157 HAL_Delay(100);
158 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
159 HAL_Delay(100);
160 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
161 HAL_Delay(100);
162 HAL_GPIO_TogglePin(GPIOB,LED2_Pin);
163 HAL_Delay(100);
164 }
165 /* USER CODE END WHILE */
166
167 /* USER CODE BEGIN 3 */
168 }
169 /* USER CODE END 3 */
170 }
171
172 /**
173 * @brief System Clock Configuration
174 * @retval None
175 */
176 void SystemClock_Config(void)
177 {
178 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
179 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
180
181 /** Configure the main internal regulator output voltage
182 */
183 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
184
185 /** Initializes the RCC Oscillators according to the specified parameters
186 * in the RCC_OscInitTypeDef structure.
187 */
188 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_MSI;
189 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
190 RCC_OscInitStruct.MSIState = RCC_MSI_ON;
191 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
192 RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
Page 3
main.c Thursday, March 21, 2024, 4:46 PM
Page 4
main.c Thursday, March 21, 2024, 4:46 PM
Page 5
main.c Thursday, March 21, 2024, 4:46 PM
Page 6