1 | /**
|
2 | ******************************************************************************
|
3 | * @file : main.c
|
4 | * @brief : Main program body
|
5 | ******************************************************************************
|
6 | ** This notice applies to any and all portions of this file
|
7 | * that are not between comment pairs USER CODE BEGIN and
|
8 | * USER CODE END. Other portions of this file, whether
|
9 | * inserted by the user or by software development tools
|
10 | * are owned by their respective copyright owners.
|
11 | *
|
12 | * COPYRIGHT(c) 2018 STMicroelectronics
|
13 | *
|
14 | * Redistribution and use in source and binary forms, with or without modification,
|
15 | * are permitted provided that the following conditions are met:
|
16 | * 1. Redistributions of source code must retain the above copyright notice,
|
17 | * this list of conditions and the following disclaimer.
|
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
19 | * this list of conditions and the following disclaimer in the documentation
|
20 | * and/or other materials provided with the distribution.
|
21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
|
22 | * may be used to endorse or promote products derived from this software
|
23 | * without specific prior written permission.
|
24 | *
|
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 | *
|
36 | ******************************************************************************
|
37 | */
|
38 | /* Includes ------------------------------------------------------------------*/
|
39 | #include "main.h"
|
40 | #include "stm32f7xx_hal.h"
|
41 |
|
42 | /* USER CODE BEGIN Includes */
|
43 | #include "stm32746g_discovery_lcd.h"
|
44 | #include "GameOfLife.h"
|
45 | /* USER CODE END Includes */
|
46 |
|
47 | /* Private variables ---------------------------------------------------------*/
|
48 |
|
49 | DMA2D_HandleTypeDef hdma2d;
|
50 |
|
51 | I2C_HandleTypeDef hi2c1;
|
52 | I2C_HandleTypeDef hi2c3;
|
53 |
|
54 | LTDC_HandleTypeDef hltdc;
|
55 |
|
56 | RNG_HandleTypeDef hrng;
|
57 |
|
58 | RTC_HandleTypeDef hrtc;
|
59 |
|
60 | SPI_HandleTypeDef hspi2;
|
61 |
|
62 | TIM_HandleTypeDef htim1;
|
63 | TIM_HandleTypeDef htim2;
|
64 | TIM_HandleTypeDef htim3;
|
65 | TIM_HandleTypeDef htim5;
|
66 | TIM_HandleTypeDef htim8;
|
67 | TIM_HandleTypeDef htim12;
|
68 |
|
69 | UART_HandleTypeDef huart1;
|
70 | UART_HandleTypeDef huart6;
|
71 |
|
72 | SDRAM_HandleTypeDef hsdram1;
|
73 |
|
74 | /* USER CODE BEGIN PV */
|
75 | /* Private variables ---------------------------------------------------------*/
|
76 |
|
77 | /* USER CODE END PV */
|
78 |
|
79 | /* Private function prototypes -----------------------------------------------*/
|
80 | void SystemClock_Config(void);
|
81 | static void MX_GPIO_Init(void);
|
82 | static void MX_FMC_Init(void);
|
83 | static void MX_I2C1_Init(void);
|
84 | static void MX_I2C3_Init(void);
|
85 | static void MX_LTDC_Init(void);
|
86 | static void MX_RTC_Init(void);
|
87 | static void MX_SPI2_Init(void);
|
88 | static void MX_TIM1_Init(void);
|
89 | static void MX_TIM2_Init(void);
|
90 | static void MX_TIM3_Init(void);
|
91 | static void MX_TIM5_Init(void);
|
92 | static void MX_TIM8_Init(void);
|
93 | static void MX_TIM12_Init(void);
|
94 | static void MX_USART1_UART_Init(void);
|
95 | static void MX_USART6_UART_Init(void);
|
96 | static void MX_DMA2D_Init(void);
|
97 | static void MX_RNG_Init(void);
|
98 |
|
99 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | /* USER CODE BEGIN PFP */
|
106 | /* Private function prototypes -----------------------------------------------*/
|
107 |
|
108 | /* USER CODE END PFP */
|
109 |
|
110 | /* USER CODE BEGIN 0 */
|
111 |
|
112 | /* USER CODE END 0 */
|
113 |
|
114 | /**
|
115 | * @brief The application entry point.
|
116 | *
|
117 | * @retval None
|
118 | */
|
119 | int main(void)
|
120 | {
|
121 | /* USER CODE BEGIN 1 */
|
122 |
|
123 | /* USER CODE END 1 */
|
124 |
|
125 | /* MCU Configuration----------------------------------------------------------*/
|
126 |
|
127 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
128 | HAL_Init();
|
129 |
|
130 | /* USER CODE BEGIN Init */
|
131 |
|
132 | /* USER CODE END Init */
|
133 |
|
134 | /* Configure the system clock */
|
135 | SystemClock_Config();
|
136 |
|
137 | /* USER CODE BEGIN SysInit */
|
138 |
|
139 | /* USER CODE END SysInit */
|
140 |
|
141 | /* Initialize all configured peripherals */
|
142 | MX_GPIO_Init();
|
143 | MX_FMC_Init();
|
144 | MX_I2C1_Init();
|
145 | MX_I2C3_Init();
|
146 | MX_LTDC_Init();
|
147 | MX_RTC_Init();
|
148 | MX_SPI2_Init();
|
149 | MX_TIM1_Init();
|
150 | MX_TIM2_Init();
|
151 | MX_TIM3_Init();
|
152 | MX_TIM5_Init();
|
153 | MX_TIM8_Init();
|
154 | MX_TIM12_Init();
|
155 | MX_USART1_UART_Init();
|
156 | MX_USART6_UART_Init();
|
157 | MX_DMA2D_Init();
|
158 | MX_RNG_Init();
|
159 | /* USER CODE BEGIN 2 */
|
160 | HAL_RNG_Init(&hrng);
|
161 |
|
162 | BSP_LCD_Init();
|
163 | BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS);
|
164 | BSP_LCD_LayerDefaultInit(0, (LCD_FB_START_ADDRESS+(4*8*272*480)) );
|
165 | BSP_LCD_SelectLayer(1);
|
166 | BSP_LCD_SetLayerVisible(1, ENABLE);
|
167 | BSP_LCD_SetLayerVisible(0, DISABLE);
|
168 | BSP_LCD_Clear(0xFFFFFFFF);
|
169 | /* USER CODE END 2 */
|
170 |
|
171 | /* Infinite loop */
|
172 | /* USER CODE BEGIN WHILE */
|
173 | while (1)
|
174 | {
|
175 | GameOfLife();
|
176 | /* USER CODE END WHILE */
|
177 |
|
178 | /* USER CODE BEGIN 3 */
|
179 |
|
180 | }
|
181 |
|
182 |
|
183 | }
|
184 |
|
185 |
|
186 | uint32_t Zufall(uint8_t Prozent)
|
187 | {
|
188 | uint32_t Z = HAL_RNG_GetRandomNumber(&hrng)%100;
|
189 |
|
190 | if( Z >= (100-Prozent) )
|
191 | {
|
192 | Z = 1;
|
193 | }
|
194 | else
|
195 | {
|
196 | Z = 0;
|
197 | }
|
198 | return Z;
|
199 | }
|
200 |
|
201 | void DrawPixel(uint16_t X, uint16_t Y, uint32_t Color)
|
202 | {
|
203 | BSP_LCD_DrawPixel(X, Y, Color);
|
204 | }
|
205 |
|
206 | void DrawLine(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2)
|
207 | {
|
208 | BSP_LCD_DrawLine(X1, Y1, X2, Y2);
|
209 | }
|
210 |
|
211 | void DrawString(uint16_t X, uint16_t Y, uint8_t *TextPt)
|
212 | {
|
213 | BSP_LCD_DisplayStringAt(X, Y, TextPt, LEFT_MODE);
|
214 | }
|
215 |
|
216 | void Layer1_schreiben__Layer2_zeigen(void)
|
217 | {
|
218 | BSP_LCD_SelectLayer(0);
|
219 | BSP_LCD_Clear(LCD_COLOR_WHITE);
|
220 | BSP_LCD_SetLayerVisible(1, ENABLE);
|
221 | BSP_LCD_SetLayerVisible(0, DISABLE);
|
222 | }
|
223 |
|
224 | void Layer2_schreiben__Layer1_zeigen(void)
|
225 | {
|
226 | BSP_LCD_SelectLayer(1);
|
227 | BSP_LCD_Clear(LCD_COLOR_WHITE);
|
228 | BSP_LCD_SetLayerVisible(0, ENABLE);
|
229 | BSP_LCD_SetLayerVisible(1, DISABLE);
|
230 | }
|
231 |
|
232 |
|
233 | /* USER CODE END 3 */
|
234 |
|
235 |
|
236 |
|
237 | /**
|
238 | * @brief System Clock Configuration
|
239 | * @retval None
|
240 | */
|
241 | void SystemClock_Config(void)
|
242 | {
|
243 |
|
244 | RCC_OscInitTypeDef RCC_OscInitStruct;
|
245 | RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
246 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
|
247 |
|
248 | /**Configure LSE Drive Capability
|
249 | */
|
250 | __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
|
251 |
|
252 | /**Configure the main internal regulator output voltage
|
253 | */
|
254 | __HAL_RCC_PWR_CLK_ENABLE();
|
255 |
|
256 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
257 |
|
258 | /**Initializes the CPU, AHB and APB busses clocks
|
259 | */
|
260 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
|
261 | RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
262 | RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
263 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
264 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
265 | RCC_OscInitStruct.PLL.PLLM = 25;
|
266 | RCC_OscInitStruct.PLL.PLLN = 432;
|
267 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
268 | RCC_OscInitStruct.PLL.PLLQ = 9;
|
269 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
270 | {
|
271 | _Error_Handler(__FILE__, __LINE__);
|
272 | }
|
273 |
|
274 | /**Activate the Over-Drive mode
|
275 | */
|
276 | if (HAL_PWREx_EnableOverDrive() != HAL_OK)
|
277 | {
|
278 | _Error_Handler(__FILE__, __LINE__);
|
279 | }
|
280 |
|
281 | /**Initializes the CPU, AHB and APB busses clocks
|
282 | */
|
283 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
284 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
285 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
286 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
287 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
288 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
289 |
|
290 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK)
|
291 | {
|
292 | _Error_Handler(__FILE__, __LINE__);
|
293 | }
|
294 |
|
295 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_RTC
|
296 | |RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART6
|
297 | |RCC_PERIPHCLK_I2C1|RCC_PERIPHCLK_I2C3
|
298 | |RCC_PERIPHCLK_CLK48;
|
299 | PeriphClkInitStruct.PLLSAI.PLLSAIN = 432;
|
300 | PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
|
301 | PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;
|
302 | PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV8;
|
303 | PeriphClkInitStruct.PLLSAIDivQ = 1;
|
304 | PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
|
305 | PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
306 | PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_SYSCLK;
|
307 | PeriphClkInitStruct.Usart6ClockSelection = RCC_USART6CLKSOURCE_SYSCLK;
|
308 | PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_SYSCLK;
|
309 | PeriphClkInitStruct.I2c3ClockSelection = RCC_I2C3CLKSOURCE_SYSCLK;
|
310 | PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLL;
|
311 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
312 | {
|
313 | _Error_Handler(__FILE__, __LINE__);
|
314 | }
|
315 |
|
316 | /**Configure the Systick interrupt time
|
317 | */
|
318 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
|
319 |
|
320 | /**Configure the Systick
|
321 | */
|
322 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
|
323 |
|
324 | /* SysTick_IRQn interrupt configuration */
|
325 | HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
326 | }
|
327 |
|
328 | /* DMA2D init function */
|
329 | static void MX_DMA2D_Init(void)
|
330 | {
|
331 |
|
332 | hdma2d.Instance = DMA2D;
|
333 | hdma2d.Init.Mode = DMA2D_M2M;
|
334 | hdma2d.Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
|
335 | hdma2d.Init.OutputOffset = 0;
|
336 | hdma2d.LayerCfg[1].InputOffset = 0;
|
337 | hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
|
338 | hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
|
339 | hdma2d.LayerCfg[1].InputAlpha = 0;
|
340 | if (HAL_DMA2D_Init(&hdma2d) != HAL_OK)
|
341 | {
|
342 | _Error_Handler(__FILE__, __LINE__);
|
343 | }
|
344 |
|
345 | if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK)
|
346 | {
|
347 | _Error_Handler(__FILE__, __LINE__);
|
348 | }
|
349 |
|
350 | }
|
351 |
|
352 | /* I2C1 init function */
|
353 | static void MX_I2C1_Init(void)
|
354 | {
|
355 |
|
356 | hi2c1.Instance = I2C1;
|
357 | hi2c1.Init.Timing = 0xA0404E72;
|
358 | hi2c1.Init.OwnAddress1 = 0;
|
359 | hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
360 | hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
361 | hi2c1.Init.OwnAddress2 = 0;
|
362 | hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
|
363 | hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
364 | hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
365 | if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
366 | {
|
367 | _Error_Handler(__FILE__, __LINE__);
|
368 | }
|
369 |
|
370 | /**Configure Analogue filter
|
371 | */
|
372 | if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
373 | {
|
374 | _Error_Handler(__FILE__, __LINE__);
|
375 | }
|
376 |
|
377 | /**Configure Digital filter
|
378 | */
|
379 | if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
380 | {
|
381 | _Error_Handler(__FILE__, __LINE__);
|
382 | }
|
383 |
|
384 | }
|
385 |
|
386 | /* I2C3 init function */
|
387 | static void MX_I2C3_Init(void)
|
388 | {
|
389 |
|
390 | hi2c3.Instance = I2C3;
|
391 | hi2c3.Init.Timing = 0xA0404E72;
|
392 | hi2c3.Init.OwnAddress1 = 0;
|
393 | hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
394 | hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
395 | hi2c3.Init.OwnAddress2 = 0;
|
396 | hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
|
397 | hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
398 | hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
399 | if (HAL_I2C_Init(&hi2c3) != HAL_OK)
|
400 | {
|
401 | _Error_Handler(__FILE__, __LINE__);
|
402 | }
|
403 |
|
404 | /**Configure Analogue filter
|
405 | */
|
406 | if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
407 | {
|
408 | _Error_Handler(__FILE__, __LINE__);
|
409 | }
|
410 |
|
411 | /**Configure Digital filter
|
412 | */
|
413 | if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
|
414 | {
|
415 | _Error_Handler(__FILE__, __LINE__);
|
416 | }
|
417 |
|
418 | }
|
419 |
|
420 | /* LTDC init function */
|
421 | static void MX_LTDC_Init(void)
|
422 | {
|
423 |
|
424 | LTDC_LayerCfgTypeDef pLayerCfg;
|
425 | LTDC_LayerCfgTypeDef pLayerCfg1;
|
426 |
|
427 | hltdc.Instance = LTDC;
|
428 | hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
|
429 | hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
|
430 | hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
|
431 | hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
|
432 | hltdc.Init.HorizontalSync = 7;
|
433 | hltdc.Init.VerticalSync = 3;
|
434 | hltdc.Init.AccumulatedHBP = 14;
|
435 | hltdc.Init.AccumulatedVBP = 5;
|
436 | hltdc.Init.AccumulatedActiveW = 494;
|
437 | hltdc.Init.AccumulatedActiveH = 277;
|
438 | hltdc.Init.TotalWidth = 500;
|
439 | hltdc.Init.TotalHeigh = 279;
|
440 | hltdc.Init.Backcolor.Blue = 0;
|
441 | hltdc.Init.Backcolor.Green = 0;
|
442 | hltdc.Init.Backcolor.Red = 0;
|
443 | if (HAL_LTDC_Init(&hltdc) != HAL_OK)
|
444 | {
|
445 | _Error_Handler(__FILE__, __LINE__);
|
446 | }
|
447 |
|
448 | pLayerCfg.WindowX0 = 0;
|
449 | pLayerCfg.WindowX1 = 0;
|
450 | pLayerCfg.WindowY0 = 0;
|
451 | pLayerCfg.WindowY1 = 0;
|
452 | pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
|
453 | pLayerCfg.Alpha = 0;
|
454 | pLayerCfg.Alpha0 = 0x0;
|
455 | pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
|
456 | pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
|
457 | pLayerCfg.FBStartAdress = 0;
|
458 | pLayerCfg.ImageWidth = 0;
|
459 | pLayerCfg.ImageHeight = 0;
|
460 | pLayerCfg.Backcolor.Blue = 0;
|
461 | pLayerCfg.Backcolor.Green = 0;
|
462 | pLayerCfg.Backcolor.Red = 0;
|
463 | if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
|
464 | {
|
465 | _Error_Handler(__FILE__, __LINE__);
|
466 | }
|
467 |
|
468 | pLayerCfg1.WindowX0 = 0;
|
469 | pLayerCfg1.WindowX1 = 0;
|
470 | pLayerCfg1.WindowY0 = 0;
|
471 | pLayerCfg1.WindowY1 = 0;
|
472 | pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
|
473 | pLayerCfg1.Alpha = 0;
|
474 | pLayerCfg1.Alpha0 = 0;
|
475 | pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
|
476 | pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
|
477 | pLayerCfg1.FBStartAdress = 0;
|
478 | pLayerCfg1.ImageWidth = 0;
|
479 | pLayerCfg1.ImageHeight = 0;
|
480 | pLayerCfg1.Backcolor.Blue = 0;
|
481 | pLayerCfg1.Backcolor.Green = 0;
|
482 | pLayerCfg1.Backcolor.Red = 0;
|
483 | if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1) != HAL_OK)
|
484 | {
|
485 | _Error_Handler(__FILE__, __LINE__);
|
486 | }
|
487 |
|
488 | }
|
489 |
|
490 | /* RNG init function */
|
491 | static void MX_RNG_Init(void)
|
492 | {
|
493 |
|
494 | hrng.Instance = RNG;
|
495 | if (HAL_RNG_Init(&hrng) != HAL_OK)
|
496 | {
|
497 | _Error_Handler(__FILE__, __LINE__);
|
498 | }
|
499 |
|
500 | }
|
501 |
|
502 | /* RTC init function */
|
503 | static void MX_RTC_Init(void)
|
504 | {
|
505 |
|
506 | RTC_TimeTypeDef sTime;
|
507 | RTC_DateTypeDef sDate;
|
508 | RTC_AlarmTypeDef sAlarm;
|
509 |
|
510 | /**Initialize RTC Only
|
511 | */
|
512 | hrtc.Instance = RTC;
|
513 | if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) != 0x32F2){
|
514 | hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
|
515 | hrtc.Init.AsynchPrediv = 127;
|
516 | hrtc.Init.SynchPrediv = 255;
|
517 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
|
518 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
|
519 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
|
520 | if (HAL_RTC_Init(&hrtc) != HAL_OK)
|
521 | {
|
522 | _Error_Handler(__FILE__, __LINE__);
|
523 | }
|
524 |
|
525 | /**Initialize RTC and set the Time and Date
|
526 | */
|
527 | sTime.Hours = 0x0;
|
528 | sTime.Minutes = 0x0;
|
529 | sTime.Seconds = 0x0;
|
530 | sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
531 | sTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
532 | if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
|
533 | {
|
534 | _Error_Handler(__FILE__, __LINE__);
|
535 | }
|
536 |
|
537 | sDate.WeekDay = RTC_WEEKDAY_MONDAY;
|
538 | sDate.Month = RTC_MONTH_JANUARY;
|
539 | sDate.Date = 0x1;
|
540 | sDate.Year = 0x0;
|
541 |
|
542 | if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
|
543 | {
|
544 | _Error_Handler(__FILE__, __LINE__);
|
545 | }
|
546 |
|
547 | /**Enable the Alarm A
|
548 | */
|
549 | sAlarm.AlarmTime.Hours = 0x0;
|
550 | sAlarm.AlarmTime.Minutes = 0x0;
|
551 | sAlarm.AlarmTime.Seconds = 0x0;
|
552 | sAlarm.AlarmTime.SubSeconds = 0x0;
|
553 | sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
554 | sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
555 | sAlarm.AlarmMask = RTC_ALARMMASK_NONE;
|
556 | sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
|
557 | sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
|
558 | sAlarm.AlarmDateWeekDay = 0x1;
|
559 | sAlarm.Alarm = RTC_ALARM_A;
|
560 | if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
|
561 | {
|
562 | _Error_Handler(__FILE__, __LINE__);
|
563 | }
|
564 |
|
565 | /**Enable the Alarm B
|
566 | */
|
567 | sAlarm.AlarmDateWeekDay = 0x1;
|
568 | sAlarm.Alarm = RTC_ALARM_B;
|
569 | if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
|
570 | {
|
571 | _Error_Handler(__FILE__, __LINE__);
|
572 | }
|
573 |
|
574 | /**Enable the TimeStamp
|
575 | */
|
576 | if (HAL_RTCEx_SetTimeStamp(&hrtc, RTC_TIMESTAMPEDGE_RISING, RTC_TIMESTAMPPIN_POS1) != HAL_OK)
|
577 | {
|
578 | _Error_Handler(__FILE__, __LINE__);
|
579 | }
|
580 |
|
581 | HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR0,0x32F2);
|
582 | }
|
583 |
|
584 | }
|
585 |
|
586 | /* SPI2 init function */
|
587 | static void MX_SPI2_Init(void)
|
588 | {
|
589 |
|
590 | /* SPI2 parameter configuration*/
|
591 | hspi2.Instance = SPI2;
|
592 | hspi2.Init.Mode = SPI_MODE_MASTER;
|
593 | hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
594 | hspi2.Init.DataSize = SPI_DATASIZE_4BIT;
|
595 | hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
596 | hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
597 | hspi2.Init.NSS = SPI_NSS_SOFT;
|
598 | hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
599 | hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
600 | hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
601 | hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
602 | hspi2.Init.CRCPolynomial = 7;
|
603 | hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
|
604 | hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
|
605 | if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
606 | {
|
607 | _Error_Handler(__FILE__, __LINE__);
|
608 | }
|
609 |
|
610 | }
|
611 |
|
612 | /* TIM1 init function */
|
613 | static void MX_TIM1_Init(void)
|
614 | {
|
615 |
|
616 | TIM_ClockConfigTypeDef sClockSourceConfig;
|
617 | TIM_MasterConfigTypeDef sMasterConfig;
|
618 | TIM_OC_InitTypeDef sConfigOC;
|
619 | TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig;
|
620 |
|
621 | htim1.Instance = TIM1;
|
622 | htim1.Init.Prescaler = 0;
|
623 | htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
624 | htim1.Init.Period = 0;
|
625 | htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
626 | htim1.Init.RepetitionCounter = 0;
|
627 | htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
628 | if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
|
629 | {
|
630 | _Error_Handler(__FILE__, __LINE__);
|
631 | }
|
632 |
|
633 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
634 | if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
|
635 | {
|
636 | _Error_Handler(__FILE__, __LINE__);
|
637 | }
|
638 |
|
639 | if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
|
640 | {
|
641 | _Error_Handler(__FILE__, __LINE__);
|
642 | }
|
643 |
|
644 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
645 | sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
|
646 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
647 | if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
648 | {
|
649 | _Error_Handler(__FILE__, __LINE__);
|
650 | }
|
651 |
|
652 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
653 | sConfigOC.Pulse = 0;
|
654 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
655 | sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
|
656 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
657 | sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
658 | sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
659 | if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
660 | {
|
661 | _Error_Handler(__FILE__, __LINE__);
|
662 | }
|
663 |
|
664 | sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
|
665 | sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
|
666 | sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
|
667 | sBreakDeadTimeConfig.DeadTime = 0;
|
668 | sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
669 | sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
670 | sBreakDeadTimeConfig.BreakFilter = 0;
|
671 | sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
|
672 | sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
|
673 | sBreakDeadTimeConfig.Break2Filter = 0;
|
674 | sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
675 | if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
|
676 | {
|
677 | _Error_Handler(__FILE__, __LINE__);
|
678 | }
|
679 |
|
680 | HAL_TIM_MspPostInit(&htim1);
|
681 |
|
682 | }
|
683 |
|
684 | /* TIM2 init function */
|
685 | static void MX_TIM2_Init(void)
|
686 | {
|
687 |
|
688 | TIM_ClockConfigTypeDef sClockSourceConfig;
|
689 | TIM_MasterConfigTypeDef sMasterConfig;
|
690 | TIM_OC_InitTypeDef sConfigOC;
|
691 |
|
692 | htim2.Instance = TIM2;
|
693 | htim2.Init.Prescaler = 0;
|
694 | htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
695 | htim2.Init.Period = 0;
|
696 | htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
697 | htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
698 | if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
699 | {
|
700 | _Error_Handler(__FILE__, __LINE__);
|
701 | }
|
702 |
|
703 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
704 | if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
|
705 | {
|
706 | _Error_Handler(__FILE__, __LINE__);
|
707 | }
|
708 |
|
709 | if (HAL_TIM_PWM_Init(&htim2) != HAL_OK)
|
710 | {
|
711 | _Error_Handler(__FILE__, __LINE__);
|
712 | }
|
713 |
|
714 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
715 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
716 | if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
|
717 | {
|
718 | _Error_Handler(__FILE__, __LINE__);
|
719 | }
|
720 |
|
721 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
722 | sConfigOC.Pulse = 0;
|
723 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
724 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
725 | if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
726 | {
|
727 | _Error_Handler(__FILE__, __LINE__);
|
728 | }
|
729 |
|
730 | HAL_TIM_MspPostInit(&htim2);
|
731 |
|
732 | }
|
733 |
|
734 | /* TIM3 init function */
|
735 | static void MX_TIM3_Init(void)
|
736 | {
|
737 |
|
738 | TIM_ClockConfigTypeDef sClockSourceConfig;
|
739 | TIM_MasterConfigTypeDef sMasterConfig;
|
740 | TIM_OC_InitTypeDef sConfigOC;
|
741 |
|
742 | htim3.Instance = TIM3;
|
743 | htim3.Init.Prescaler = 0;
|
744 | htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
745 | htim3.Init.Period = 0;
|
746 | htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
747 | htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
748 | if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
|
749 | {
|
750 | _Error_Handler(__FILE__, __LINE__);
|
751 | }
|
752 |
|
753 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
754 | if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
|
755 | {
|
756 | _Error_Handler(__FILE__, __LINE__);
|
757 | }
|
758 |
|
759 | if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
|
760 | {
|
761 | _Error_Handler(__FILE__, __LINE__);
|
762 | }
|
763 |
|
764 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
765 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
766 | if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
|
767 | {
|
768 | _Error_Handler(__FILE__, __LINE__);
|
769 | }
|
770 |
|
771 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
772 | sConfigOC.Pulse = 0;
|
773 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
774 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
775 | if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
776 | {
|
777 | _Error_Handler(__FILE__, __LINE__);
|
778 | }
|
779 |
|
780 | HAL_TIM_MspPostInit(&htim3);
|
781 |
|
782 | }
|
783 |
|
784 | /* TIM5 init function */
|
785 | static void MX_TIM5_Init(void)
|
786 | {
|
787 |
|
788 | TIM_ClockConfigTypeDef sClockSourceConfig;
|
789 | TIM_MasterConfigTypeDef sMasterConfig;
|
790 | TIM_OC_InitTypeDef sConfigOC;
|
791 |
|
792 | htim5.Instance = TIM5;
|
793 | htim5.Init.Prescaler = 0;
|
794 | htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
|
795 | htim5.Init.Period = 0;
|
796 | htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
797 | htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
798 | if (HAL_TIM_Base_Init(&htim5) != HAL_OK)
|
799 | {
|
800 | _Error_Handler(__FILE__, __LINE__);
|
801 | }
|
802 |
|
803 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
804 | if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK)
|
805 | {
|
806 | _Error_Handler(__FILE__, __LINE__);
|
807 | }
|
808 |
|
809 | if (HAL_TIM_PWM_Init(&htim5) != HAL_OK)
|
810 | {
|
811 | _Error_Handler(__FILE__, __LINE__);
|
812 | }
|
813 |
|
814 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
815 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
816 | if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
|
817 | {
|
818 | _Error_Handler(__FILE__, __LINE__);
|
819 | }
|
820 |
|
821 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
822 | sConfigOC.Pulse = 0;
|
823 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
824 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
825 | if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
|
826 | {
|
827 | _Error_Handler(__FILE__, __LINE__);
|
828 | }
|
829 |
|
830 | HAL_TIM_MspPostInit(&htim5);
|
831 |
|
832 | }
|
833 |
|
834 | /* TIM8 init function */
|
835 | static void MX_TIM8_Init(void)
|
836 | {
|
837 |
|
838 | TIM_ClockConfigTypeDef sClockSourceConfig;
|
839 | TIM_MasterConfigTypeDef sMasterConfig;
|
840 |
|
841 | htim8.Instance = TIM8;
|
842 | htim8.Init.Prescaler = 0;
|
843 | htim8.Init.CounterMode = TIM_COUNTERMODE_UP;
|
844 | htim8.Init.Period = 0;
|
845 | htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
846 | htim8.Init.RepetitionCounter = 0;
|
847 | htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
848 | if (HAL_TIM_Base_Init(&htim8) != HAL_OK)
|
849 | {
|
850 | _Error_Handler(__FILE__, __LINE__);
|
851 | }
|
852 |
|
853 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
854 | if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK)
|
855 | {
|
856 | _Error_Handler(__FILE__, __LINE__);
|
857 | }
|
858 |
|
859 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
860 | sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
|
861 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
862 | if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK)
|
863 | {
|
864 | _Error_Handler(__FILE__, __LINE__);
|
865 | }
|
866 |
|
867 | }
|
868 |
|
869 | /* TIM12 init function */
|
870 | static void MX_TIM12_Init(void)
|
871 | {
|
872 |
|
873 | TIM_OC_InitTypeDef sConfigOC;
|
874 |
|
875 | htim12.Instance = TIM12;
|
876 | htim12.Init.Prescaler = 0;
|
877 | htim12.Init.CounterMode = TIM_COUNTERMODE_UP;
|
878 | htim12.Init.Period = 0;
|
879 | htim12.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
880 | htim12.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
881 | if (HAL_TIM_PWM_Init(&htim12) != HAL_OK)
|
882 | {
|
883 | _Error_Handler(__FILE__, __LINE__);
|
884 | }
|
885 |
|
886 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
887 | sConfigOC.Pulse = 0;
|
888 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
889 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
890 | if (HAL_TIM_PWM_ConfigChannel(&htim12, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
891 | {
|
892 | _Error_Handler(__FILE__, __LINE__);
|
893 | }
|
894 |
|
895 | HAL_TIM_MspPostInit(&htim12);
|
896 |
|
897 | }
|
898 |
|
899 | /* USART1 init function */
|
900 | static void MX_USART1_UART_Init(void)
|
901 | {
|
902 |
|
903 | huart1.Instance = USART1;
|
904 | huart1.Init.BaudRate = 115200;
|
905 | huart1.Init.WordLength = UART_WORDLENGTH_7B;
|
906 | huart1.Init.StopBits = UART_STOPBITS_1;
|
907 | huart1.Init.Parity = UART_PARITY_NONE;
|
908 | huart1.Init.Mode = UART_MODE_TX_RX;
|
909 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
910 | huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
911 | huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
912 | huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
913 | if (HAL_UART_Init(&huart1) != HAL_OK)
|
914 | {
|
915 | _Error_Handler(__FILE__, __LINE__);
|
916 | }
|
917 |
|
918 | }
|
919 |
|
920 | /* USART6 init function */
|
921 | static void MX_USART6_UART_Init(void)
|
922 | {
|
923 |
|
924 | huart6.Instance = USART6;
|
925 | huart6.Init.BaudRate = 115200;
|
926 | huart6.Init.WordLength = UART_WORDLENGTH_7B;
|
927 | huart6.Init.StopBits = UART_STOPBITS_1;
|
928 | huart6.Init.Parity = UART_PARITY_NONE;
|
929 | huart6.Init.Mode = UART_MODE_TX_RX;
|
930 | huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
931 | huart6.Init.OverSampling = UART_OVERSAMPLING_16;
|
932 | huart6.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
933 | huart6.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
934 | if (HAL_UART_Init(&huart6) != HAL_OK)
|
935 | {
|
936 | _Error_Handler(__FILE__, __LINE__);
|
937 | }
|
938 |
|
939 | }
|
940 |
|
941 | /* FMC initialization function */
|
942 | static void MX_FMC_Init(void)
|
943 | {
|
944 | FMC_SDRAM_TimingTypeDef SdramTiming;
|
945 |
|
946 | /** Perform the SDRAM1 memory initialization sequence
|
947 | */
|
948 | hsdram1.Instance = FMC_SDRAM_DEVICE;
|
949 | /* hsdram1.Init */
|
950 | hsdram1.Init.SDBank = FMC_SDRAM_BANK1;
|
951 | hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
|
952 | hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
|
953 | hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;
|
954 | hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
|
955 | hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1;
|
956 | hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
|
957 | hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE;
|
958 | hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE;
|
959 | hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
|
960 | /* SdramTiming */
|
961 | SdramTiming.LoadToActiveDelay = 16;
|
962 | SdramTiming.ExitSelfRefreshDelay = 16;
|
963 | SdramTiming.SelfRefreshTime = 16;
|
964 | SdramTiming.RowCycleDelay = 16;
|
965 | SdramTiming.WriteRecoveryTime = 16;
|
966 | SdramTiming.RPDelay = 16;
|
967 | SdramTiming.RCDDelay = 16;
|
968 |
|
969 | if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
|
970 | {
|
971 | _Error_Handler(__FILE__, __LINE__);
|
972 | }
|
973 |
|
974 | }
|
975 |
|
976 | /** Configure pins as
|
977 | * Analog
|
978 | * Input
|
979 | * Output
|
980 | * EVENT_OUT
|
981 | * EXTI
|
982 | PE2 ------> QUADSPI_BK1_IO2
|
983 | PG14 ------> ETH_TXD1
|
984 | PB5 ------> USB_OTG_HS_ULPI_D7
|
985 | PD7 ------> SPDIFRX_IN0
|
986 | PC12 ------> SDMMC1_CK
|
987 | PE5 ------> DCMI_D6
|
988 | PE6 ------> DCMI_D7
|
989 | PG13 ------> ETH_TXD0
|
990 | PB6 ------> QUADSPI_BK1_NCS
|
991 | PG11 ------> ETH_TX_EN
|
992 | PC11 ------> SDMMC1_D3
|
993 | PC10 ------> SDMMC1_D2
|
994 | PA12 ------> USB_OTG_FS_DP
|
995 | PI4 ------> SAI2_MCLK_A
|
996 | PG10 ------> SAI2_SD_B
|
997 | PD3 ------> DCMI_D5
|
998 | PA11 ------> USB_OTG_FS_DM
|
999 | PI5 ------> SAI2_SCK_A
|
1000 | PI7 ------> SAI2_FS_A
|
1001 | PI6 ------> SAI2_SD_A
|
1002 | PG9 ------> DCMI_VSYNC
|
1003 | PD2 ------> SDMMC1_CMD
|
1004 | PA10 ------> USB_OTG_FS_ID
|
1005 | PH14 ------> DCMI_D4
|
1006 | PC9 ------> SDMMC1_D1
|
1007 | PC8 ------> SDMMC1_D0
|
1008 | PH4 ------> USB_OTG_HS_ULPI_NXT
|
1009 | PF7 ------> ADC3_IN5
|
1010 | PF6 ------> ADC3_IN4
|
1011 | PB13 ------> USB_OTG_HS_ULPI_D6
|
1012 | PF10 ------> ADC3_IN8
|
1013 | PF9 ------> ADC3_IN7
|
1014 | PF8 ------> ADC3_IN6
|
1015 | PB12 ------> USB_OTG_HS_ULPI_D5
|
1016 | PC0 ------> USB_OTG_HS_ULPI_STP
|
1017 | PC1 ------> ETH_MDC
|
1018 | PC2 ------> USB_OTG_HS_ULPI_DIR
|
1019 | PB2 ------> QUADSPI_CLK
|
1020 | PD12 ------> QUADSPI_BK1_IO1
|
1021 | PD13 ------> QUADSPI_BK1_IO3
|
1022 | PH12 ------> DCMI_D3
|
1023 | PA1 ------> ETH_REF_CLK
|
1024 | PA0/WKUP ------> ADCx_IN0
|
1025 | PA4 ------> DCMI_HSYNC
|
1026 | PC4 ------> ETH_RXD0
|
1027 | PD11 ------> QUADSPI_BK1_IO0
|
1028 | PH9 ------> DCMI_D0
|
1029 | PH11 ------> DCMI_D2
|
1030 | PA2 ------> ETH_MDIO
|
1031 | PA6 ------> DCMI_PIXCLK
|
1032 | PA5 ------> USB_OTG_HS_ULPI_CK
|
1033 | PC5 ------> ETH_RXD1
|
1034 | PB10 ------> USB_OTG_HS_ULPI_D3
|
1035 | PH10 ------> DCMI_D1
|
1036 | PA3 ------> USB_OTG_HS_ULPI_D0
|
1037 | PA7 ------> ETH_CRS_DV
|
1038 | PB1 ------> USB_OTG_HS_ULPI_D2
|
1039 | PB0 ------> USB_OTG_HS_ULPI_D1
|
1040 | PB11 ------> USB_OTG_HS_ULPI_D4
|
1041 | */
|
1042 | static void MX_GPIO_Init(void)
|
1043 | {
|
1044 |
|
1045 | GPIO_InitTypeDef GPIO_InitStruct;
|
1046 |
|
1047 | /* GPIO Ports Clock Enable */
|
1048 | __HAL_RCC_GPIOE_CLK_ENABLE();
|
1049 | __HAL_RCC_GPIOG_CLK_ENABLE();
|
1050 | __HAL_RCC_GPIOB_CLK_ENABLE();
|
1051 | __HAL_RCC_GPIOD_CLK_ENABLE();
|
1052 | __HAL_RCC_GPIOC_CLK_ENABLE();
|
1053 | __HAL_RCC_GPIOA_CLK_ENABLE();
|
1054 | __HAL_RCC_GPIOJ_CLK_ENABLE();
|
1055 | __HAL_RCC_GPIOI_CLK_ENABLE();
|
1056 | __HAL_RCC_GPIOK_CLK_ENABLE();
|
1057 | __HAL_RCC_GPIOF_CLK_ENABLE();
|
1058 | __HAL_RCC_GPIOH_CLK_ENABLE();
|
1059 |
|
1060 | /*Configure GPIO pin Output Level */
|
1061 | HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_RESET);
|
1062 |
|
1063 | /*Configure GPIO pin Output Level */
|
1064 | HAL_GPIO_WritePin(GPIOI, ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin, GPIO_PIN_RESET);
|
1065 |
|
1066 | /*Configure GPIO pin Output Level */
|
1067 | HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_RESET);
|
1068 |
|
1069 | /*Configure GPIO pin Output Level */
|
1070 | HAL_GPIO_WritePin(DCMI_PWR_EN_GPIO_Port, DCMI_PWR_EN_Pin, GPIO_PIN_RESET);
|
1071 |
|
1072 | /*Configure GPIO pin Output Level */
|
1073 | HAL_GPIO_WritePin(GPIOG, ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin, GPIO_PIN_RESET);
|
1074 |
|
1075 | /*Configure GPIO pin : OTG_HS_OverCurrent_Pin */
|
1076 | GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin;
|
1077 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
1078 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1079 | HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
|
1080 |
|
1081 | /*Configure GPIO pin : QSPI_D2_Pin */
|
1082 | GPIO_InitStruct.Pin = QSPI_D2_Pin;
|
1083 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1084 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1085 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1086 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
1087 | HAL_GPIO_Init(QSPI_D2_GPIO_Port, &GPIO_InitStruct);
|
1088 |
|
1089 | /*Configure GPIO pins : RMII_TXD1_Pin RMII_TXD0_Pin RMII_TX_EN_Pin */
|
1090 | GPIO_InitStruct.Pin = RMII_TXD1_Pin|RMII_TXD0_Pin|RMII_TX_EN_Pin;
|
1091 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1092 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1093 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1094 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
|
1095 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
1096 |
|
1097 | /*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D3_Pin
|
1098 | ULPI_D2_Pin ULPI_D1_Pin ULPI_D4_Pin */
|
1099 | GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D3_Pin
|
1100 | |ULPI_D2_Pin|ULPI_D1_Pin|ULPI_D4_Pin;
|
1101 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1102 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1103 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1104 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
|
1105 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
1106 |
|
1107 | /*Configure GPIO pin : SPDIF_RX0_Pin */
|
1108 | GPIO_InitStruct.Pin = SPDIF_RX0_Pin;
|
1109 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1110 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1111 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1112 | GPIO_InitStruct.Alternate = GPIO_AF8_SPDIFRX;
|
1113 | HAL_GPIO_Init(SPDIF_RX0_GPIO_Port, &GPIO_InitStruct);
|
1114 |
|
1115 | /*Configure GPIO pins : SDMMC_CK_Pin SDMMC_D3_Pin SDMMC_D2_Pin PC9
|
1116 | PC8 */
|
1117 | GPIO_InitStruct.Pin = SDMMC_CK_Pin|SDMMC_D3_Pin|SDMMC_D2_Pin|GPIO_PIN_9
|
1118 | |GPIO_PIN_8;
|
1119 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1120 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1121 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1122 | GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
|
1123 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
1124 |
|
1125 | /*Configure GPIO pins : DCMI_D6_Pin DCMI_D7_Pin */
|
1126 | GPIO_InitStruct.Pin = DCMI_D6_Pin|DCMI_D7_Pin;
|
1127 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1128 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1129 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1130 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
|
1131 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
1132 |
|
1133 | /*Configure GPIO pin : QSPI_NCS_Pin */
|
1134 | GPIO_InitStruct.Pin = QSPI_NCS_Pin;
|
1135 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1136 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1137 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1138 | GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
|
1139 | HAL_GPIO_Init(QSPI_NCS_GPIO_Port, &GPIO_InitStruct);
|
1140 |
|
1141 | /*Configure GPIO pin : OTG_FS_VBUS_Pin */
|
1142 | GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin;
|
1143 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
1144 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1145 | HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct);
|
1146 |
|
1147 | /*Configure GPIO pin : Audio_INT_Pin */
|
1148 | GPIO_InitStruct.Pin = Audio_INT_Pin;
|
1149 | GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
|
1150 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1151 | HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct);
|
1152 |
|
1153 | /*Configure GPIO pins : OTG_FS_P_Pin OTG_FS_N_Pin OTG_FS_ID_Pin */
|
1154 | GPIO_InitStruct.Pin = OTG_FS_P_Pin|OTG_FS_N_Pin|OTG_FS_ID_Pin;
|
1155 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1156 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1157 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1158 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
1159 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
1160 |
|
1161 | /*Configure GPIO pins : SAI2_MCLKA_Pin SAI2_SCKA_Pin SAI2_FSA_Pin SAI2_SDA_Pin */
|
1162 | GPIO_InitStruct.Pin = SAI2_MCLKA_Pin|SAI2_SCKA_Pin|SAI2_FSA_Pin|SAI2_SDA_Pin;
|
1163 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1164 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1165 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1166 | GPIO_InitStruct.Alternate = GPIO_AF10_SAI2;
|
1167 | HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
|
1168 |
|
1169 | /*Configure GPIO pin : SAI2_SDB_Pin */
|
1170 | GPIO_InitStruct.Pin = SAI2_SDB_Pin;
|
1171 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1172 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1173 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1174 | GPIO_InitStruct.Alternate = GPIO_AF10_SAI2;
|
1175 | HAL_GPIO_Init(SAI2_SDB_GPIO_Port, &GPIO_InitStruct);
|
1176 |
|
1177 | /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */
|
1178 | GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin;
|
1179 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
1180 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1181 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1182 | HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
|
1183 |
|
1184 | /*Configure GPIO pin : DCMI_D5_Pin */
|
1185 | GPIO_InitStruct.Pin = DCMI_D5_Pin;
|
1186 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1187 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1188 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1189 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
|
1190 | HAL_GPIO_Init(DCMI_D5_GPIO_Port, &GPIO_InitStruct);
|
1191 |
|
1192 | /*Configure GPIO pins : ARDUINO_D7_Pin ARDUINO_D8_Pin LCD_DISP_Pin */
|
1193 | GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin;
|
1194 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
1195 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1196 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1197 | HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
|
1198 |
|
1199 | /*Configure GPIO pin : uSD_Detect_Pin */
|
1200 | GPIO_InitStruct.Pin = uSD_Detect_Pin;
|
1201 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
1202 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1203 | HAL_GPIO_Init(uSD_Detect_GPIO_Port, &GPIO_InitStruct);
|
1204 |
|
1205 | /*Configure GPIO pin : LCD_BL_CTRL_Pin */
|
1206 | GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
|
1207 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
1208 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1209 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1210 | HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);
|
1211 |
|
1212 | /*Configure GPIO pin : DCMI_VSYNC_Pin */
|
1213 | GPIO_InitStruct.Pin = DCMI_VSYNC_Pin;
|
1214 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1215 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1216 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1217 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
|
1218 | HAL_GPIO_Init(DCMI_VSYNC_GPIO_Port, &GPIO_InitStruct);
|
1219 |
|
1220 | /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */
|
1221 | GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin;
|
1222 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
1223 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1224 | HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
|
1225 |
|
1226 | /*Configure GPIO pin : SDMMC_CMD_Pin */
|
1227 | GPIO_InitStruct.Pin = SDMMC_CMD_Pin;
|
1228 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1229 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1230 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1231 | GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
|
1232 | HAL_GPIO_Init(SDMMC_CMD_GPIO_Port, &GPIO_InitStruct);
|
1233 |
|
1234 | /*Configure GPIO pins : TP3_Pin NC2_Pin */
|
1235 | GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin;
|
1236 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
1237 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1238 | HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
1239 |
|
1240 | /*Configure GPIO pin : DCMI_PWR_EN_Pin */
|
1241 | GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin;
|
1242 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
1243 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1244 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1245 | HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct);
|
1246 |
|
1247 | /*Configure GPIO pins : DCMI_D4_Pin DCMI_D3_Pin DCMI_D0_Pin DCMI_D2_Pin
|
1248 | DCMI_D1_Pin */
|
1249 | GPIO_InitStruct.Pin = DCMI_D4_Pin|DCMI_D3_Pin|DCMI_D0_Pin|DCMI_D2_Pin
|
1250 | |DCMI_D1_Pin;
|
1251 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1252 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1253 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1254 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
|
1255 | HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
1256 |
|
1257 | /*Configure GPIO pin : LCD_INT_Pin */
|
1258 | GPIO_InitStruct.Pin = LCD_INT_Pin;
|
1259 | GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
|
1260 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1261 | HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
|
1262 |
|
1263 | /*Configure GPIO pin : ULPI_NXT_Pin */
|
1264 | GPIO_InitStruct.Pin = ULPI_NXT_Pin;
|
1265 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1266 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1267 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1268 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
|
1269 | HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct);
|
1270 |
|
1271 | /*Configure GPIO pins : ARDUINO_D4_Pin ARDUINO_D2_Pin EXT_RST_Pin */
|
1272 | GPIO_InitStruct.Pin = ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin;
|
1273 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
1274 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1275 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1276 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
1277 |
|
1278 | /*Configure GPIO pins : ARDUINO_A4_Pin ARDUINO_A5_Pin ARDUINO_A1_Pin ARDUINO_A2_Pin
|
1279 | ARDUINO_A3_Pin */
|
1280 | GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin
|
1281 | |ARDUINO_A3_Pin;
|
1282 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
1283 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1284 | HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
1285 |
|
1286 | /*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */
|
1287 | GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin;
|
1288 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1289 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1290 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1291 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
|
1292 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
1293 |
|
1294 | /*Configure GPIO pins : RMII_MDC_Pin RMII_RXD0_Pin RMII_RXD1_Pin */
|
1295 | GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin;
|
1296 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1297 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1298 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1299 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
|
1300 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
1301 |
|
1302 | /*Configure GPIO pin : PB2 */
|
1303 | GPIO_InitStruct.Pin = GPIO_PIN_2;
|
1304 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1305 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1306 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1307 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
1308 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
1309 |
|
1310 | /*Configure GPIO pins : QSPI_D1_Pin QSPI_D3_Pin QSPI_D0_Pin */
|
1311 | GPIO_InitStruct.Pin = QSPI_D1_Pin|QSPI_D3_Pin|QSPI_D0_Pin;
|
1312 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1313 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1314 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1315 | GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
|
1316 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
1317 |
|
1318 | /*Configure GPIO pin : RMII_RXER_Pin */
|
1319 | GPIO_InitStruct.Pin = RMII_RXER_Pin;
|
1320 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
1321 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1322 | HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct);
|
1323 |
|
1324 | /*Configure GPIO pins : RMII_REF_CLK_Pin RMII_MDIO_Pin RMII_CRS_DV_Pin */
|
1325 | GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin;
|
1326 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1327 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1328 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1329 | GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
|
1330 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
1331 |
|
1332 | /*Configure GPIO pin : ARDUINO_A0_Pin */
|
1333 | GPIO_InitStruct.Pin = ARDUINO_A0_Pin;
|
1334 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
1335 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1336 | HAL_GPIO_Init(ARDUINO_A0_GPIO_Port, &GPIO_InitStruct);
|
1337 |
|
1338 | /*Configure GPIO pins : DCMI_HSYNC_Pin PA6 */
|
1339 | GPIO_InitStruct.Pin = DCMI_HSYNC_Pin|GPIO_PIN_6;
|
1340 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1341 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1342 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
1343 | GPIO_InitStruct.Alternate = GPIO_AF13_DCMI;
|
1344 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
1345 |
|
1346 | /*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */
|
1347 | GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin;
|
1348 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
1349 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
1350 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
1351 | GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;
|
1352 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
1353 |
|
1354 | }
|
1355 |
|
1356 | /* USER CODE BEGIN 4 */
|
1357 |
|
1358 | /* USER CODE END 4 */
|
1359 |
|
1360 | /**
|
1361 | * @brief This function is executed in case of error occurrence.
|
1362 | * @param file: The file name as string.
|
1363 | * @param line: The line in file as a number.
|
1364 | * @retval None
|
1365 | */
|
1366 | void _Error_Handler(char *file, int line)
|
1367 | {
|
1368 | /* USER CODE BEGIN Error_Handler_Debug */
|
1369 | /* User can add his own implementation to report the HAL error return state */
|
1370 | while(1)
|
1371 | {
|
1372 | }
|
1373 | /* USER CODE END Error_Handler_Debug */
|
1374 | }
|
1375 |
|
1376 | #ifdef USE_FULL_ASSERT
|
1377 | /**
|
1378 | * @brief Reports the name of the source file and the source line number
|
1379 | * where the assert_param error has occurred.
|
1380 | * @param file: pointer to the source file name
|
1381 | * @param line: assert_param error line source number
|
1382 | * @retval None
|
1383 | */
|
1384 | void assert_failed(uint8_t* file, uint32_t line)
|
1385 | {
|
1386 | /* USER CODE BEGIN 6 */
|
1387 | /* User can add his own implementation to report the file name and line number,
|
1388 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
1389 | /* USER CODE END 6 */
|
1390 | }
|
1391 | #endif /* USE_FULL_ASSERT */
|
1392 |
|
1393 | /**
|
1394 | * @}
|
1395 | */
|
1396 |
|
1397 | /**
|
1398 | * @}
|
1399 | */
|
1400 |
|
1401 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|