OLD | NEW |
| (Empty) |
1 /** | |
2 ****************************************************************************** | |
3 * File Name : main.c | |
4 * Description : Main program body | |
5 ****************************************************************************** | |
6 * | |
7 * COPYRIGHT(c) 2016 STMicroelectronics | |
8 * | |
9 * Redistribution and use in source and binary forms, with or without modificat
ion, | |
10 * are permitted provided that the following conditions are met: | |
11 * 1. Redistributions of source code must retain the above copyright notice, | |
12 * this list of conditions and the following disclaimer. | |
13 * 2. Redistributions in binary form must reproduce the above copyright notic
e, | |
14 * this list of conditions and the following disclaimer in the documentati
on | |
15 * and/or other materials provided with the distribution. | |
16 * 3. Neither the name of STMicroelectronics nor the names of its contributor
s | |
17 * may be used to endorse or promote products derived from this software | |
18 * without specific prior written permission. | |
19 * | |
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE A
RE | |
23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
27 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY
, | |
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE US
E | |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 * | |
31 ****************************************************************************** | |
32 */ | |
33 /* Includes ------------------------------------------------------------------*/ | |
34 #include "stm32f7xx_hal.h" | |
35 #include "cmsis_os.h" | |
36 | |
37 /* USER CODE BEGIN Includes */ | |
38 #include "fletch_entry.h" | |
39 /* USER CODE END Includes */ | |
40 | |
41 /* Private variables ---------------------------------------------------------*/ | |
42 | |
43 DCMI_HandleTypeDef hdcmi; | |
44 | |
45 DMA2D_HandleTypeDef hdma2d; | |
46 | |
47 ETH_HandleTypeDef heth; | |
48 | |
49 I2C_HandleTypeDef hi2c1; | |
50 | |
51 LTDC_HandleTypeDef hltdc; | |
52 | |
53 QSPI_HandleTypeDef hqspi; | |
54 | |
55 SD_HandleTypeDef hsd1; | |
56 HAL_SD_CardInfoTypedef SDCardInfo1; | |
57 | |
58 SPDIFRX_HandleTypeDef hspdif; | |
59 | |
60 UART_HandleTypeDef huart1; | |
61 | |
62 SDRAM_HandleTypeDef hsdram1; | |
63 osThreadId defaultTaskHandle; | |
64 | |
65 /* USER CODE BEGIN PV */ | |
66 /* Private variables ---------------------------------------------------------*/ | |
67 | |
68 /* USER CODE END PV */ | |
69 | |
70 /* Private function prototypes -----------------------------------------------*/ | |
71 void SystemClock_Config(void); | |
72 void MX_GPIO_Init(void); | |
73 void MX_DCMI_Init(void); | |
74 void MX_DMA2D_Init(void); | |
75 void MX_ETH_Init(void); | |
76 void MX_FMC_Init(void); | |
77 void MX_I2C1_Init(void); | |
78 void MX_LTDC_Init(void); | |
79 void MX_QUADSPI_Init(void); | |
80 void MX_SDMMC1_SD_Init(void); | |
81 void MX_SPDIFRX_Init(void); | |
82 void MX_USART1_UART_Init(void); | |
83 void StartDefaultTask(void const * argument); | |
84 | |
85 /* USER CODE BEGIN PFP */ | |
86 /* Private function prototypes -----------------------------------------------*/ | |
87 | |
88 /* USER CODE END PFP */ | |
89 | |
90 /* USER CODE BEGIN 0 */ | |
91 | |
92 /* USER CODE END 0 */ | |
93 | |
94 int _not_using_this_main(void) | |
95 { | |
96 | |
97 /* USER CODE BEGIN 1 */ | |
98 | |
99 /* USER CODE END 1 */ | |
100 | |
101 /* MCU Configuration----------------------------------------------------------
*/ | |
102 | |
103 /* Reset of all peripherals, Initializes the Flash interface and the Systick.
*/ | |
104 HAL_Init(); | |
105 | |
106 /* Configure the system clock */ | |
107 SystemClock_Config(); | |
108 | |
109 /* Initialize all configured peripherals */ | |
110 MX_GPIO_Init(); | |
111 MX_DCMI_Init(); | |
112 MX_DMA2D_Init(); | |
113 MX_ETH_Init(); | |
114 MX_FMC_Init(); | |
115 MX_I2C1_Init(); | |
116 MX_LTDC_Init(); | |
117 MX_QUADSPI_Init(); | |
118 MX_SDMMC1_SD_Init(); | |
119 MX_SPDIFRX_Init(); | |
120 MX_USART1_UART_Init(); | |
121 | |
122 /* USER CODE BEGIN 2 */ | |
123 | |
124 /* USER CODE END 2 */ | |
125 | |
126 /* USER CODE BEGIN RTOS_MUTEX */ | |
127 /* add mutexes, ... */ | |
128 /* USER CODE END RTOS_MUTEX */ | |
129 | |
130 /* USER CODE BEGIN RTOS_SEMAPHORES */ | |
131 /* add semaphores, ... */ | |
132 /* USER CODE END RTOS_SEMAPHORES */ | |
133 | |
134 /* USER CODE BEGIN RTOS_TIMERS */ | |
135 /* start timers, add new ones, ... */ | |
136 /* USER CODE END RTOS_TIMERS */ | |
137 | |
138 /* Create the thread(s) */ | |
139 /* definition and creation of defaultTask */ | |
140 osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); | |
141 defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); | |
142 | |
143 /* USER CODE BEGIN RTOS_THREADS */ | |
144 /* add threads, ... */ | |
145 /* USER CODE END RTOS_THREADS */ | |
146 | |
147 /* USER CODE BEGIN RTOS_QUEUES */ | |
148 /* add queues, ... */ | |
149 /* USER CODE END RTOS_QUEUES */ | |
150 | |
151 | |
152 /* Start scheduler */ | |
153 osKernelStart(); | |
154 | |
155 /* We should never get here as control is now taken by the scheduler */ | |
156 | |
157 /* Infinite loop */ | |
158 /* USER CODE BEGIN WHILE */ | |
159 while (1) | |
160 { | |
161 /* USER CODE END WHILE */ | |
162 | |
163 /* USER CODE BEGIN 3 */ | |
164 | |
165 } | |
166 /* USER CODE END 3 */ | |
167 | |
168 } | |
169 | |
170 /** System Clock Configuration | |
171 */ | |
172 void SystemClock_Config(void) | |
173 { | |
174 | |
175 RCC_OscInitTypeDef RCC_OscInitStruct; | |
176 RCC_ClkInitTypeDef RCC_ClkInitStruct; | |
177 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; | |
178 | |
179 __PWR_CLK_ENABLE(); | |
180 | |
181 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); | |
182 | |
183 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; | |
184 RCC_OscInitStruct.HSEState = RCC_HSE_ON; | |
185 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | |
186 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; | |
187 RCC_OscInitStruct.PLL.PLLM = 25; | |
188 RCC_OscInitStruct.PLL.PLLN = 400; | |
189 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; | |
190 RCC_OscInitStruct.PLL.PLLQ = 2; | |
191 HAL_RCC_OscConfig(&RCC_OscInitStruct); | |
192 | |
193 HAL_PWREx_ActivateOverDrive(); | |
194 | |
195 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK | |
196 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; | |
197 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | |
198 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | |
199 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; | |
200 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; | |
201 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6); | |
202 | |
203 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPDIFRX|RCC_PERIPHCLK
_LTDC | |
204 |RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_I2C1 | |
205 |RCC_PERIPHCLK_SDMMC1; | |
206 PeriphClkInitStruct.PLLI2S.PLLI2SN = 100; | |
207 PeriphClkInitStruct.PLLI2S.PLLI2SP = 0; | |
208 PeriphClkInitStruct.PLLI2S.PLLI2SR = 2; | |
209 PeriphClkInitStruct.PLLI2S.PLLI2SQ = 2; | |
210 PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; | |
211 PeriphClkInitStruct.PLLSAI.PLLSAIR = 2; | |
212 PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2; | |
213 PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV8; | |
214 PeriphClkInitStruct.PLLI2SDivQ = 1; | |
215 PeriphClkInitStruct.PLLSAIDivQ = 1; | |
216 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; | |
217 PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; | |
218 PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; | |
219 PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_SYSCLK; | |
220 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
221 | |
222 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); | |
223 | |
224 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); | |
225 | |
226 /* SysTick_IRQn interrupt configuration */ | |
227 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); | |
228 } | |
229 | |
230 /* DCMI init function */ | |
231 void MX_DCMI_Init(void) | |
232 { | |
233 | |
234 hdcmi.Instance = DCMI; | |
235 hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; | |
236 hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING; | |
237 hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW; | |
238 hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW; | |
239 hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME; | |
240 hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; | |
241 hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE; | |
242 hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL; | |
243 hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD; | |
244 hdcmi.Init.LineSelectMode = DCMI_LSM_ALL; | |
245 hdcmi.Init.LineSelectStart = DCMI_OELS_ODD; | |
246 HAL_DCMI_Init(&hdcmi); | |
247 | |
248 } | |
249 | |
250 /* DMA2D init function */ | |
251 void MX_DMA2D_Init(void) | |
252 { | |
253 | |
254 hdma2d.Instance = DMA2D; | |
255 hdma2d.Init.Mode = DMA2D_M2M; | |
256 hdma2d.Init.ColorMode = DMA2D_ARGB8888; | |
257 hdma2d.Init.OutputOffset = 0; | |
258 hdma2d.LayerCfg[1].InputOffset = 0; | |
259 hdma2d.LayerCfg[1].InputColorMode = CM_ARGB8888; | |
260 hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; | |
261 hdma2d.LayerCfg[1].InputAlpha = 0; | |
262 HAL_DMA2D_Init(&hdma2d); | |
263 | |
264 HAL_DMA2D_ConfigLayer(&hdma2d, 1); | |
265 | |
266 } | |
267 | |
268 /* ETH init function */ | |
269 void MX_ETH_Init(void) | |
270 { | |
271 | |
272 uint8_t MACAddr[6] ; | |
273 | |
274 heth.Instance = ETH; | |
275 heth.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE; | |
276 heth.Init.PhyAddress = 1; | |
277 MACAddr[0] = 0x00; | |
278 MACAddr[1] = 0x80; | |
279 MACAddr[2] = 0xE1; | |
280 MACAddr[3] = 0x00; | |
281 MACAddr[4] = 0x00; | |
282 MACAddr[5] = 0x00; | |
283 heth.Init.MACAddr = &MACAddr[0]; | |
284 heth.Init.RxMode = ETH_RXPOLLING_MODE; | |
285 heth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; | |
286 heth.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; | |
287 HAL_ETH_Init(&heth); | |
288 | |
289 } | |
290 | |
291 /* I2C1 init function */ | |
292 void MX_I2C1_Init(void) | |
293 { | |
294 | |
295 hi2c1.Instance = I2C1; | |
296 hi2c1.Init.Timing = 0x00C0EFFF; | |
297 hi2c1.Init.OwnAddress1 = 0; | |
298 hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; | |
299 hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; | |
300 hi2c1.Init.OwnAddress2 = 0; | |
301 hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; | |
302 hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; | |
303 hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; | |
304 HAL_I2C_Init(&hi2c1); | |
305 | |
306 /**Configure Analogue filter | |
307 */ | |
308 HAL_I2CEx_AnalogFilter_Config(&hi2c1, I2C_ANALOGFILTER_ENABLE); | |
309 | |
310 } | |
311 | |
312 /* LTDC init function */ | |
313 void MX_LTDC_Init(void) | |
314 { | |
315 | |
316 LTDC_LayerCfgTypeDef pLayerCfg; | |
317 LTDC_LayerCfgTypeDef pLayerCfg1; | |
318 | |
319 hltdc.Instance = LTDC; | |
320 hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
321 hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL; | |
322 hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
323 hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; | |
324 hltdc.Init.HorizontalSync = 7; | |
325 hltdc.Init.VerticalSync = 3; | |
326 hltdc.Init.AccumulatedHBP = 14; | |
327 hltdc.Init.AccumulatedVBP = 5; | |
328 hltdc.Init.AccumulatedActiveW = 654; | |
329 hltdc.Init.AccumulatedActiveH = 485; | |
330 hltdc.Init.TotalWidth = 660; | |
331 hltdc.Init.TotalHeigh = 487; | |
332 hltdc.Init.Backcolor.Blue = 0; | |
333 hltdc.Init.Backcolor.Green = 0; | |
334 hltdc.Init.Backcolor.Red = 0; | |
335 HAL_LTDC_Init(&hltdc); | |
336 | |
337 pLayerCfg.WindowX0 = 0; | |
338 pLayerCfg.WindowX1 = 0; | |
339 pLayerCfg.WindowY0 = 0; | |
340 pLayerCfg.WindowY1 = 0; | |
341 pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; | |
342 pLayerCfg.Alpha = 0; | |
343 pLayerCfg.Alpha0 = 0; | |
344 pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; | |
345 pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; | |
346 pLayerCfg.FBStartAdress = 0; | |
347 pLayerCfg.ImageWidth = 0; | |
348 pLayerCfg.ImageHeight = 0; | |
349 pLayerCfg.Backcolor.Blue = 0; | |
350 pLayerCfg.Backcolor.Green = 0; | |
351 pLayerCfg.Backcolor.Red = 0; | |
352 HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0); | |
353 | |
354 pLayerCfg1.WindowX0 = 0; | |
355 pLayerCfg1.WindowX1 = 0; | |
356 pLayerCfg1.WindowY0 = 0; | |
357 pLayerCfg1.WindowY1 = 0; | |
358 pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; | |
359 pLayerCfg1.Alpha = 0; | |
360 pLayerCfg1.Alpha0 = 0; | |
361 pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; | |
362 pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; | |
363 pLayerCfg1.FBStartAdress = 0; | |
364 pLayerCfg1.ImageWidth = 0; | |
365 pLayerCfg1.ImageHeight = 0; | |
366 pLayerCfg1.Backcolor.Blue = 0; | |
367 pLayerCfg1.Backcolor.Green = 0; | |
368 pLayerCfg1.Backcolor.Red = 0; | |
369 HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1); | |
370 | |
371 } | |
372 | |
373 /* QUADSPI init function */ | |
374 void MX_QUADSPI_Init(void) | |
375 { | |
376 | |
377 hqspi.Instance = QUADSPI; | |
378 hqspi.Init.ClockPrescaler = 255; | |
379 hqspi.Init.FifoThreshold = 1; | |
380 hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; | |
381 hqspi.Init.FlashSize = 1; | |
382 hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; | |
383 hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; | |
384 HAL_QSPI_Init(&hqspi); | |
385 | |
386 } | |
387 | |
388 /* SDMMC1 init function */ | |
389 void MX_SDMMC1_SD_Init(void) | |
390 { | |
391 | |
392 hsd1.Instance = SDMMC1; | |
393 hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; | |
394 hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE; | |
395 hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; | |
396 hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; | |
397 hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE; | |
398 hsd1.Init.ClockDiv = 0; | |
399 HAL_SD_Init(&hsd1, &SDCardInfo1); | |
400 | |
401 HAL_SD_WideBusOperation_Config(&hsd1, SDMMC_BUS_WIDE_4B); | |
402 | |
403 } | |
404 | |
405 /* SPDIFRX init function */ | |
406 void MX_SPDIFRX_Init(void) | |
407 { | |
408 | |
409 hspdif.Instance = SPDIFRX; | |
410 hspdif.Init.InputSelection = SPDIFRX_INPUT_IN0; | |
411 hspdif.Init.Retries = SPDIFRX_MAXRETRIES_NONE; | |
412 hspdif.Init.WaitForActivity = SPDIFRX_WAITFORACTIVITY_OFF; | |
413 hspdif.Init.ChannelSelection = SPDIFRX_CHANNEL_A; | |
414 hspdif.Init.DataFormat = SPDIFRX_DATAFORMAT_LSB; | |
415 hspdif.Init.StereoMode = SPDIFRX_STEREOMODE_DISABLE; | |
416 hspdif.Init.PreambleTypeMask = SPDIFRX_PREAMBLETYPEMASK_OFF; | |
417 hspdif.Init.ChannelStatusMask = SPDIFRX_CHANNELSTATUS_OFF; | |
418 hspdif.Init.ValidityBitMask = SPDIFRX_VALIDITYMASK_OFF; | |
419 hspdif.Init.ParityErrorMask = SPDIFRX_PARITYERRORMASK_OFF; | |
420 HAL_SPDIFRX_Init(&hspdif); | |
421 | |
422 } | |
423 | |
424 /* USART1 init function */ | |
425 void MX_USART1_UART_Init(void) | |
426 { | |
427 | |
428 huart1.Instance = USART1; | |
429 huart1.Init.BaudRate = 115200; | |
430 huart1.Init.WordLength = UART_WORDLENGTH_8B; | |
431 huart1.Init.StopBits = UART_STOPBITS_1; | |
432 huart1.Init.Parity = UART_PARITY_NONE; | |
433 huart1.Init.Mode = UART_MODE_TX_RX; | |
434 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
435 huart1.Init.OverSampling = UART_OVERSAMPLING_16; | |
436 huart1.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED; | |
437 huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; | |
438 HAL_UART_Init(&huart1); | |
439 | |
440 } | |
441 /* FMC initialization function */ | |
442 void MX_FMC_Init(void) | |
443 { | |
444 FMC_SDRAM_TimingTypeDef SdramTiming; | |
445 | |
446 /** Perform the SDRAM1 memory initialization sequence | |
447 */ | |
448 hsdram1.Instance = FMC_SDRAM_DEVICE; | |
449 /* hsdram1.Init */ | |
450 hsdram1.Init.SDBank = FMC_SDRAM_BANK1; | |
451 hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; | |
452 hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; | |
453 hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_8; | |
454 hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; | |
455 hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2; | |
456 hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; | |
457 hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; | |
458 hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; | |
459 hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; | |
460 /* SdramTiming */ | |
461 SdramTiming.LoadToActiveDelay = 16; | |
462 SdramTiming.ExitSelfRefreshDelay = 16; | |
463 SdramTiming.SelfRefreshTime = 16; | |
464 SdramTiming.RowCycleDelay = 16; | |
465 SdramTiming.WriteRecoveryTime = 16; | |
466 SdramTiming.RPDelay = 16; | |
467 SdramTiming.RCDDelay = 16; | |
468 | |
469 HAL_SDRAM_Init(&hsdram1, &SdramTiming); | |
470 | |
471 } | |
472 | |
473 /** Configure pins as | |
474 * Analog | |
475 * Input | |
476 * Output | |
477 * EVENT_OUT | |
478 * EXTI | |
479 PB5 ------> USB_OTG_HS_ULPI_D7 | |
480 PB4 ------> S_TIM3_CH1 | |
481 PA15 ------> S_TIM2_CH1_ETR | |
482 PA12 ------> USB_OTG_FS_DP | |
483 PI4 ------> SAI2_MCLK_A | |
484 PG10 ------> SAI2_SD_B | |
485 PA11 ------> USB_OTG_FS_DM | |
486 PI5 ------> SAI2_SCK_A | |
487 PI7 ------> SAI2_FS_A | |
488 PI6 ------> SAI2_SD_A | |
489 PI1 ------> SPI2_SCK | |
490 PA10 ------> USB_OTG_FS_ID | |
491 PI0 ------> S_TIM5_CH4 | |
492 PA8 ------> S_TIM1_CH1 | |
493 PC7 ------> USART6_RX | |
494 PH4 ------> USB_OTG_HS_ULPI_NXT | |
495 PC6 ------> USART6_TX | |
496 PF7 ------> ADC3_IN5 | |
497 PF6 ------> ADC3_IN4 | |
498 PB13 ------> USB_OTG_HS_ULPI_D6 | |
499 PF10 ------> ADC3_IN8 | |
500 PF9 ------> ADC3_IN7 | |
501 PF8 ------> ADC3_IN6 | |
502 PB12 ------> USB_OTG_HS_ULPI_D5 | |
503 PC0 ------> USB_OTG_HS_ULPI_STP | |
504 PC2 ------> USB_OTG_HS_ULPI_DIR | |
505 PA0/WKUP ------> ADCx_IN0 | |
506 PH7 ------> I2C3_SCL | |
507 PA5 ------> USB_OTG_HS_ULPI_CK | |
508 PB10 ------> USB_OTG_HS_ULPI_D3 | |
509 PH6 ------> S_TIM12_CH1 | |
510 PH8 ------> I2C3_SDA | |
511 PA3 ------> USB_OTG_HS_ULPI_D0 | |
512 PB1 ------> USB_OTG_HS_ULPI_D2 | |
513 PB0 ------> USB_OTG_HS_ULPI_D1 | |
514 PB11 ------> USB_OTG_HS_ULPI_D4 | |
515 PB14 ------> SPI2_MISO | |
516 PB15 ------> SPI2_MOSI | |
517 */ | |
518 void MX_GPIO_Init(void) | |
519 { | |
520 | |
521 GPIO_InitTypeDef GPIO_InitStruct; | |
522 | |
523 /* GPIO Ports Clock Enable */ | |
524 __GPIOE_CLK_ENABLE(); | |
525 __GPIOG_CLK_ENABLE(); | |
526 __GPIOB_CLK_ENABLE(); | |
527 __GPIOD_CLK_ENABLE(); | |
528 __GPIOC_CLK_ENABLE(); | |
529 __GPIOA_CLK_ENABLE(); | |
530 __GPIOJ_CLK_ENABLE(); | |
531 __GPIOI_CLK_ENABLE(); | |
532 __GPIOK_CLK_ENABLE(); | |
533 __GPIOF_CLK_ENABLE(); | |
534 __GPIOH_CLK_ENABLE(); | |
535 | |
536 /*Configure GPIO pin : OTG_HS_OverCurrent_Pin */ | |
537 GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin; | |
538 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
539 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
540 HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct); | |
541 | |
542 /*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D3_Pin | |
543 ULPI_D2_Pin ULPI_D1_Pin ULPI_D4_Pin */ | |
544 GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D3_Pin | |
545 |ULPI_D2_Pin|ULPI_D1_Pin|ULPI_D4_Pin; | |
546 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
547 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
548 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
549 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; | |
550 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | |
551 | |
552 /*Configure GPIO pin : ARDUINO_PWM_D3_Pin */ | |
553 GPIO_InitStruct.Pin = ARDUINO_PWM_D3_Pin; | |
554 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
555 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
556 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
557 GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; | |
558 HAL_GPIO_Init(ARDUINO_PWM_D3_GPIO_Port, &GPIO_InitStruct); | |
559 | |
560 /*Configure GPIO pin : ARDUINO_PWM_D9_Pin */ | |
561 GPIO_InitStruct.Pin = ARDUINO_PWM_D9_Pin; | |
562 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
563 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
564 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
565 GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; | |
566 HAL_GPIO_Init(ARDUINO_PWM_D9_GPIO_Port, &GPIO_InitStruct); | |
567 | |
568 /*Configure GPIO pin : OTG_FS_VBUS_Pin */ | |
569 GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin; | |
570 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
571 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
572 HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct); | |
573 | |
574 /*Configure GPIO pin : Audio_INT_Pin */ | |
575 GPIO_InitStruct.Pin = Audio_INT_Pin; | |
576 GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; | |
577 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
578 HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct); | |
579 | |
580 /*Configure GPIO pins : OTG_FS_P_Pin OTG_FS_N_Pin OTG_FS_ID_Pin */ | |
581 GPIO_InitStruct.Pin = OTG_FS_P_Pin|OTG_FS_N_Pin|OTG_FS_ID_Pin; | |
582 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
583 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
584 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
585 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; | |
586 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | |
587 | |
588 /*Configure GPIO pins : SAI2_MCLKA_Pin SAI2_SCKA_Pin SAI2_FSA_Pin SAI2_SDA_Pin
*/ | |
589 GPIO_InitStruct.Pin = SAI2_MCLKA_Pin|SAI2_SCKA_Pin|SAI2_FSA_Pin|SAI2_SDA_Pin; | |
590 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
591 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
592 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
593 GPIO_InitStruct.Alternate = GPIO_AF10_SAI2; | |
594 HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); | |
595 | |
596 /*Configure GPIO pin : SAI2_SDB_Pin */ | |
597 GPIO_InitStruct.Pin = SAI2_SDB_Pin; | |
598 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
599 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
600 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
601 GPIO_InitStruct.Alternate = GPIO_AF10_SAI2; | |
602 HAL_GPIO_Init(SAI2_SDB_GPIO_Port, &GPIO_InitStruct); | |
603 | |
604 /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */ | |
605 GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; | |
606 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
607 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
608 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
609 HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); | |
610 | |
611 /*Configure GPIO pins : ARDUINO_D7_Pin ARDUINO_D8_Pin LCD_DISP_Pin */ | |
612 GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin; | |
613 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
614 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
615 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
616 HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); | |
617 | |
618 /*Configure GPIO pin : uSD_Detect_Pin */ | |
619 GPIO_InitStruct.Pin = uSD_Detect_Pin; | |
620 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
621 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
622 HAL_GPIO_Init(uSD_Detect_GPIO_Port, &GPIO_InitStruct); | |
623 | |
624 /*Configure GPIO pin : LCD_BL_CTRL_Pin */ | |
625 GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin; | |
626 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
627 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
628 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
629 HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct); | |
630 | |
631 /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */ | |
632 GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; | |
633 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
634 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
635 HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); | |
636 | |
637 /*Configure GPIO pins : TP3_Pin NC2_Pin */ | |
638 GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin; | |
639 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
640 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
641 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); | |
642 | |
643 /*Configure GPIO pin : ARDUINO_SCK_D13_Pin */ | |
644 GPIO_InitStruct.Pin = ARDUINO_SCK_D13_Pin; | |
645 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
646 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
647 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
648 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; | |
649 HAL_GPIO_Init(ARDUINO_SCK_D13_GPIO_Port, &GPIO_InitStruct); | |
650 | |
651 /*Configure GPIO pin : DCMI_PWR_EN_Pin */ | |
652 GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin; | |
653 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
654 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
655 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
656 HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct); | |
657 | |
658 /*Configure GPIO pin : ARDUINO_PWM_CS_D10_Pin */ | |
659 GPIO_InitStruct.Pin = ARDUINO_PWM_CS_D10_Pin; | |
660 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
661 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
662 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
663 GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; | |
664 HAL_GPIO_Init(ARDUINO_PWM_CS_D10_GPIO_Port, &GPIO_InitStruct); | |
665 | |
666 /*Configure GPIO pin : ARDUINO_PWM_D5_Pin */ | |
667 GPIO_InitStruct.Pin = ARDUINO_PWM_D5_Pin; | |
668 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
669 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
670 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
671 GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; | |
672 HAL_GPIO_Init(ARDUINO_PWM_D5_GPIO_Port, &GPIO_InitStruct); | |
673 | |
674 /*Configure GPIO pin : LCD_INT_Pin */ | |
675 GPIO_InitStruct.Pin = LCD_INT_Pin; | |
676 GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; | |
677 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
678 HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); | |
679 | |
680 /*Configure GPIO pins : ARDUINO_RX_D0_Pin ARDUINO_TX_D1_Pin */ | |
681 GPIO_InitStruct.Pin = ARDUINO_RX_D0_Pin|ARDUINO_TX_D1_Pin; | |
682 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
683 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
684 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
685 GPIO_InitStruct.Alternate = GPIO_AF8_USART6; | |
686 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | |
687 | |
688 /*Configure GPIO pin : ULPI_NXT_Pin */ | |
689 GPIO_InitStruct.Pin = ULPI_NXT_Pin; | |
690 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
691 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
692 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
693 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; | |
694 HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct); | |
695 | |
696 /*Configure GPIO pins : ARDUINO_D4_Pin ARDUINO_D2_Pin EXT_RST_Pin */ | |
697 GPIO_InitStruct.Pin = ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin; | |
698 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
699 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
700 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
701 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); | |
702 | |
703 /*Configure GPIO pins : ARDUINO_A4_Pin ARDUINO_A5_Pin ARDUINO_A1_Pin ARDUINO_A
2_Pin | |
704 ARDUINO_A3_Pin */ | |
705 GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_
Pin | |
706 |ARDUINO_A3_Pin; | |
707 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | |
708 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
709 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); | |
710 | |
711 /*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */ | |
712 GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin; | |
713 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
714 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
715 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
716 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; | |
717 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | |
718 | |
719 /*Configure GPIO pin : RMII_RXER_Pin */ | |
720 GPIO_InitStruct.Pin = RMII_RXER_Pin; | |
721 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
722 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
723 HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct); | |
724 | |
725 /*Configure GPIO pin : ARDUINO_A0_Pin */ | |
726 GPIO_InitStruct.Pin = ARDUINO_A0_Pin; | |
727 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; | |
728 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
729 HAL_GPIO_Init(ARDUINO_A0_GPIO_Port, &GPIO_InitStruct); | |
730 | |
731 /*Configure GPIO pins : LCD_SCL_Pin LCD_SDA_Pin */ | |
732 GPIO_InitStruct.Pin = LCD_SCL_Pin|LCD_SDA_Pin; | |
733 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; | |
734 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
735 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
736 GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; | |
737 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); | |
738 | |
739 /*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */ | |
740 GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin; | |
741 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
742 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
743 GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; | |
744 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; | |
745 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | |
746 | |
747 /*Configure GPIO pin : ARDUINO_PWM_D6_Pin */ | |
748 GPIO_InitStruct.Pin = ARDUINO_PWM_D6_Pin; | |
749 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
750 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
751 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
752 GPIO_InitStruct.Alternate = GPIO_AF9_TIM12; | |
753 HAL_GPIO_Init(ARDUINO_PWM_D6_GPIO_Port, &GPIO_InitStruct); | |
754 | |
755 /*Configure GPIO pins : ARDUINO_MISO_D12_Pin ARDUINO_MOSI_PWM_D11_Pin */ | |
756 GPIO_InitStruct.Pin = ARDUINO_MISO_D12_Pin|ARDUINO_MOSI_PWM_D11_Pin; | |
757 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
758 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
759 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
760 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; | |
761 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | |
762 | |
763 } | |
764 | |
765 /* USER CODE BEGIN 4 */ | |
766 | |
767 /* USER CODE END 4 */ | |
768 | |
769 /* StartDefaultTask function */ | |
770 void StartDefaultTask(void const * argument) | |
771 { | |
772 | |
773 /* USER CODE BEGIN 5 */ | |
774 FletchEntry(argument); | |
775 /* Infinite loop */ | |
776 for(;;) | |
777 { | |
778 osDelay(1); | |
779 } | |
780 /* USER CODE END 5 */ | |
781 } | |
782 | |
783 #ifdef USE_FULL_ASSERT | |
784 | |
785 /** | |
786 * @brief Reports the name of the source file and the source line number | |
787 * where the assert_param error has occurred. | |
788 * @param file: pointer to the source file name | |
789 * @param line: assert_param error line source number | |
790 * @retval None | |
791 */ | |
792 void assert_failed(uint8_t* file, uint32_t line) | |
793 { | |
794 /* USER CODE BEGIN 6 */ | |
795 /* User can add his own implementation to report the file name and line number
, | |
796 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ | |
797 /* USER CODE END 6 */ | |
798 | |
799 } | |
800 | |
801 #endif | |
802 | |
803 /** | |
804 * @} | |
805 */ | |
806 | |
807 /** | |
808 * @} | |
809 */ | |
810 | |
811 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
OLD | NEW |