comparison OtherSources/stm32f4xx_hal_msp_hw1.c @ 7:2de06b1abed3

CLEAN retrieve original startup code. reset linker script.
author jDG
date Mon, 18 Dec 2017 14:03:55 +0100
parents
children 7801c5d8a562
comparison
equal deleted inserted replaced
6:b355f462c952 7:2de06b1abed3
1 /**
2 ******************************************************************************
3 * File Name : stm32f4xx_hal_msp.c
4 * Date : 04/12/2014 15:39:26
5 * Description : This file provides code for the MSP Initialization
6 * and de-Initialization codes.
7 ******************************************************************************
8 *
9 * COPYRIGHT(c) 2014 STMicroelectronics
10 *
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 ******************************************************************************
34 */
35 /* Includes ------------------------------------------------------------------*/
36 #include "stm32f4xx_hal.h"
37 #include "ostc.h"
38
39
40 DMA_HandleTypeDef hdma_spi1_tx;
41
42 DMA_HandleTypeDef hdma_spi1_rx;
43
44 /* USER CODE BEGIN 0 */
45
46 /* USER CODE END 0 */
47
48 /**
49 * Initializes the Global MSP.
50 */
51 void HAL_MspInit(void)
52 {
53 /* USER CODE BEGIN MspInit 0 */
54 /* USER CODE END MspInit 0 */
55
56 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2);
57
58 /* System interrupt init*/
59 /** SysTick_IRQn interrupt configuration
60 * use 1 by Christian
61 */
62 HAL_NVIC_SetPriority(SysTick_IRQn, 1, 0);
63
64 /* USER CODE BEGIN MspInit 1 */
65 /* always set priority right */
66 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2);
67 /* USER CODE END MspInit 1 */
68 }
69
70 void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d)
71 {
72
73 if(hdma2d->Instance==DMA2D)
74 {
75 /* USER CODE BEGIN DMA2D_MspInit 0 */
76
77 /* USER CODE END DMA2D_MspInit 0 */
78 /* Peripheral clock enable */
79 __DMA2D_CLK_ENABLE();
80 /* USER CODE BEGIN DMA2D_MspInit 1 */
81 HAL_NVIC_SetPriority(DMA2D_IRQn, 1, 2);
82 HAL_NVIC_EnableIRQ(DMA2D_IRQn);
83 /* USER CODE END DMA2D_MspInit 1 */
84 }
85
86 }
87
88 void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d)
89 {
90
91 if(hdma2d->Instance==DMA2D)
92 {
93 /* USER CODE BEGIN DMA2D_MspDeInit 0 */
94
95 /* USER CODE END DMA2D_MspDeInit 0 */
96 /* Peripheral clock disable */
97 __DMA2D_CLK_DISABLE();
98 /* USER CODE BEGIN DMA2D_MspDeInit 1 */
99 __DMA2D_RELEASE_RESET();
100 /* USER CODE END DMA2D_MspDeInit 1 */
101 }
102
103 }
104
105 void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
106 {
107
108 GPIO_InitTypeDef GPIO_InitStruct;
109 if(hltdc->Instance==LTDC)
110 {
111 /* USER CODE BEGIN LTDC_MspInit 0 */
112 __GPIOE_CLK_ENABLE();
113 __GPIOF_CLK_ENABLE();
114 __GPIOG_CLK_ENABLE();
115 __GPIOH_CLK_ENABLE();
116 __GPIOI_CLK_ENABLE();
117
118 /* USER CODE END LTDC_MspInit 0 */
119 /* Peripheral clock enable */
120 __LTDC_CLK_ENABLE();
121
122 /**LTDC GPIO Configuration
123 PE4 ------> LTDC_B0
124 PE5 ------> LTDC_G0
125 PE6 ------> LTDC_G1
126 PI9 ------> LTDC_VSYNC
127 PI10 ------> LTDC_HSYNC
128 PF10 ------> LTDC_DE
129 PH2 ------> LTDC_R0
130 PH3 ------> LTDC_R1
131 PH8 ------> LTDC_R2
132 PH9 ------> LTDC_R3
133 PH10 ------> LTDC_R4
134 PH11 ------> LTDC_R5
135 PH12 ------> LTDC_R6
136 PG6 ------> LTDC_R7
137 PG7 ------> LTDC_CLK
138 PH13 ------> LTDC_G2
139 PH14 ------> LTDC_G3
140 PH15 ------> LTDC_G4
141 PI0 ------> LTDC_G5
142 PI1 ------> LTDC_G6
143 PI2 ------> LTDC_G7
144 PG10 ------> LTDC_B2
145 PG11 ------> LTDC_B3
146 PG12 ------> LTDC_B1
147 PI4 ------> LTDC_B4
148 PI5 ------> LTDC_B5
149 PI6 ------> LTDC_B6
150 PI7 ------> LTDC_B7
151 */
152 GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
153 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
154 GPIO_InitStruct.Pull = GPIO_NOPULL;
155 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
156 GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
157 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
158
159 GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_0|GPIO_PIN_1
160 |GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
161 |GPIO_PIN_7;
162 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
163 GPIO_InitStruct.Pull = GPIO_NOPULL;
164 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
165 GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
166 HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
167
168 GPIO_InitStruct.Pin = GPIO_PIN_10;
169 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
170 GPIO_InitStruct.Pull = GPIO_NOPULL;
171 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
172 GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
173 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
174
175 GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_8|GPIO_PIN_9
176 |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
177 |GPIO_PIN_14|GPIO_PIN_15;
178 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
179 GPIO_InitStruct.Pull = GPIO_NOPULL;
180 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
181 GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
182 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
183
184 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_11
185 |GPIO_PIN_12;
186 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
187 GPIO_InitStruct.Pull = GPIO_NOPULL;
188 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
189 GPIO_InitStruct.Alternate = GPIO_AF14_LTDC;
190 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
191
192 /* USER CODE BEGIN LTDC_MspInit 1 */
193
194 /* USER CODE END LTDC_MspInit 1 */
195 }
196
197 }
198
199 void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
200 {
201
202 if(hltdc->Instance==LTDC)
203 {
204 /* USER CODE BEGIN LTDC_MspDeInit 0 */
205
206 /* USER CODE END LTDC_MspDeInit 0 */
207 /* Peripheral clock disable */
208 __LTDC_CLK_DISABLE();
209
210 /**LTDC GPIO Configuration
211 PE4 ------> LTDC_B0
212 PE5 ------> LTDC_G0
213 PE6 ------> LTDC_G1
214 PI9 ------> LTDC_VSYNC
215 PI10 ------> LTDC_HSYNC
216 PF10 ------> LTDC_DE
217 PH2 ------> LTDC_R0
218 PH3 ------> LTDC_R1
219 PH8 ------> LTDC_R2
220 PH9 ------> LTDC_R3
221 PH10 ------> LTDC_R4
222 PH11 ------> LTDC_R5
223 PH12 ------> LTDC_R6
224 PG6 ------> LTDC_R7
225 PG7 ------> LTDC_CLK
226 PH13 ------> LTDC_G2
227 PH14 ------> LTDC_G3
228 PH15 ------> LTDC_G4
229 PI0 ------> LTDC_G5
230 PI1 ------> LTDC_G6
231 PI2 ------> LTDC_G7
232 PG10 ------> LTDC_B2
233 PG11 ------> LTDC_B3
234 PG12 ------> LTDC_B1
235 PI4 ------> LTDC_B4
236 PI5 ------> LTDC_B5
237 PI6 ------> LTDC_B6
238 PI7 ------> LTDC_B7
239 */
240 HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6);
241
242 HAL_GPIO_DeInit(GPIOI, GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_0|GPIO_PIN_1
243 |GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
244 |GPIO_PIN_7);
245
246 HAL_GPIO_DeInit(GPIOF, GPIO_PIN_10);
247
248 HAL_GPIO_DeInit(GPIOH, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_8|GPIO_PIN_9
249 |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
250 |GPIO_PIN_14|GPIO_PIN_15);
251
252 HAL_GPIO_DeInit(GPIOG, GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_11
253 |GPIO_PIN_12);
254
255 /* USER CODE BEGIN LTDC_MspDeInit 1 */
256 __LTDC_RELEASE_RESET();
257
258 /* USER CODE END LTDC_MspDeInit 1 */
259 }
260
261 }
262
263 void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
264 {
265
266 GPIO_InitTypeDef GPIO_InitStruct;
267 if(hspi->Instance==SPI1)
268 {
269 /* USER CODE BEGIN SPI1_MspInit 0 */
270 __GPIOA_CLK_ENABLE();
271 __GPIOB_CLK_ENABLE();
272 __DMA2_CLK_ENABLE();
273
274 /* USER CODE END SPI1_MspInit 0 */
275 /* Peripheral clock enable */
276 __SPI1_CLK_ENABLE();
277
278 /**SPI1 GPIO Configuration
279 alt: PA4 ------> SPI1_NSS, jetzt soft
280 PA5 ------> SPI1_SCK
281 alt: PA6 ------> SPI1_MISO
282 neu: PB4 ------> SPI1_MISO
283 PA7 ------> SPI1_MOSI
284 */
285 // GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
286 GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
287 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
288 GPIO_InitStruct.Pull = GPIO_NOPULL;
289 GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;//GPIO_SPEED_LOW;
290 GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
291 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
292 GPIO_InitStruct.Pin = GPIO_PIN_4;
293 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
294
295 /* Peripheral DMA init*/
296
297 hdma_spi1_tx.Instance = DMA2_Stream3;
298 hdma_spi1_tx.Init.Channel = DMA_CHANNEL_3;
299 hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
300 hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
301 hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE;
302 hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
303 hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
304 hdma_spi1_tx.Init.Mode = DMA_NORMAL;
305 hdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW;
306 hdma_spi1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
307 /* by christian */
308 hdma_spi1_tx.Init.MemBurst = DMA_MBURST_INC4;
309 hdma_spi1_tx.Init.PeriphBurst = DMA_PBURST_INC4;
310 HAL_DMA_Init(&hdma_spi1_tx);
311
312 __HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx);
313
314 hdma_spi1_rx.Instance = DMA2_Stream0;
315 hdma_spi1_rx.Init.Channel = DMA_CHANNEL_3;
316 hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
317 hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
318 hdma_spi1_rx.Init.MemInc = DMA_MINC_ENABLE;
319 hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
320 hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
321 hdma_spi1_rx.Init.Mode = DMA_NORMAL;
322 hdma_spi1_rx.Init.Priority = DMA_PRIORITY_HIGH;
323 hdma_spi1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
324 /* by christian */
325 hdma_spi1_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
326
327 hdma_spi1_rx.Init.MemBurst = DMA_MBURST_INC4;
328 hdma_spi1_rx.Init.PeriphBurst = DMA_PBURST_INC4;
329 HAL_DMA_Init(&hdma_spi1_rx);
330
331 __HAL_LINKDMA(hspi, hdmarx, hdma_spi1_rx);
332
333 /*##-4- Configure the NVIC for DMA #########################################*/
334 /* NVIC configuration for DMA transfer complete interrupt (SPI1_TX) */
335 HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 0, 1);
336 HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn);
337
338
339 /* NVIC configuration for DMA transfer complete interrupt (SPI1_RX) */
340 HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0);
341 HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
342
343 }
344 else if(hspi->Instance==SPI2)
345 {
346 /* USER CODE BEGIN SPI2_MspInit 0 */
347 __GPIOB_CLK_ENABLE();
348
349 /* USER CODE END SPI2_MspInit 0 */
350 /* Peripheral clock enable */
351 __SPI2_CLK_ENABLE();
352
353 /**SPI2 GPIO Configuration
354 PB13 ------> SPI2_SCK
355 PB14 ------> SPI2_MISO
356 PB15 ------> SPI2_MOSI
357 */
358 GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
359 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
360 GPIO_InitStruct.Pull = GPIO_NOPULL;
361 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
362 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
363 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
364
365 /* USER CODE BEGIN SPI2_MspInit 1 */
366
367 /* USER CODE END SPI2_MspInit 1 */
368 }
369 else if(hspi->Instance==SPI5)
370 {
371 /* USER CODE BEGIN SPI5_MspInit 0 */
372 __GPIOF_CLK_ENABLE();
373
374 /* USER CODE END SPI5_MspInit 0 */
375 /* Peripheral clock enable */
376 __SPI5_CLK_ENABLE();
377
378 /**SPI5 GPIO Configuration
379 PF7 ------> SPI5_SCK
380 PF8 ------> SPI5_MISO
381 PF9 ------> SPI5_MOSI
382 */
383 GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
384 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
385 GPIO_InitStruct.Pull = GPIO_NOPULL;
386 GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;//GPIO_SPEED_LOW;
387 GPIO_InitStruct.Alternate = GPIO_AF5_SPI5;
388 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
389
390 /* USER CODE BEGIN SPI5_MspInit 1 */
391
392 /* USER CODE END SPI5_MspInit 1 */
393 }
394
395 }
396
397 void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
398 {
399
400 if(hspi->Instance==SPI1)
401 {
402 /* USER CODE BEGIN SPI1_MspDeInit 0 */
403 __SPI1_FORCE_RESET();
404 __SPI1_RELEASE_RESET();
405
406 /* USER CODE END SPI1_MspDeInit 0 */
407 /* Peripheral clock disable */
408 __SPI1_CLK_DISABLE();
409
410 /**SPI1 GPIO Configuration
411 PA4 ------> SPI1_NSS
412 PA5 ------> SPI1_SCK
413 PA6 ------> SPI1_MISO
414 PA7 ------> SPI1_MOSI
415 */
416 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
417
418 /* Peripheral DMA DeInit*/
419 HAL_DMA_DeInit(hspi->hdmatx);
420 HAL_DMA_DeInit(hspi->hdmarx);
421 /* USER CODE BEGIN SPI1_MspDeInit 1 */
422
423 /* USER CODE END SPI1_MspDeInit 1 */
424 }
425 else if(hspi->Instance==SPI2)
426 {
427 /* USER CODE BEGIN SPI2_MspDeInit 0 */
428
429 /* USER CODE END SPI2_MspDeInit 0 */
430 /* Peripheral clock disable */
431 __SPI2_CLK_DISABLE();
432
433 /**SPI2 GPIO Configuration
434 PB13 ------> SPI2_SCK
435 PB14 ------> SPI2_MISO
436 PB15 ------> SPI2_MOSI
437 */
438 HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
439
440 /* USER CODE BEGIN SPI2_MspDeInit 1 */
441
442 /* USER CODE END SPI2_MspDeInit 1 */
443 }
444 else if(hspi->Instance==SPI5)
445 {
446 /* USER CODE BEGIN SPI5_MspDeInit 0 */
447 __SPI5_FORCE_RESET();
448 __SPI5_RELEASE_RESET();
449
450 /* USER CODE END SPI5_MspDeInit 0 */
451 /* Peripheral clock disable */
452 __SPI5_CLK_DISABLE();
453
454 /**SPI5 GPIO Configuration
455 PF7 ------> SPI5_SCK
456 PF8 ------> SPI5_MISO
457 PF9 ------> SPI5_MOSI
458 */
459 HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9);
460
461 /* USER CODE BEGIN SPI5_MspDeInit 1 */
462
463 /* USER CODE END SPI5_MspDeInit 1 */
464 }
465
466 }
467
468 void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
469 {
470 GPIO_InitTypeDef GPIO_InitStruct;
471 if(htim_pwm->Instance==TIM_BACKLIGHT)
472 {
473 TIM_BACKLIGHT_GPIO_ENABLE();
474 TIM_BACKLIGHT_CLK_ENABLE();
475
476 GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN;
477 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
478 GPIO_InitStruct.Pull = GPIO_NOPULL;
479 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
480 GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
481 HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct);
482 }
483
484 }
485
486 void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
487 {
488 if(htim_base->Instance==TIMx)
489 {
490 TIMx_CLK_ENABLE();
491
492 HAL_NVIC_SetPriority(TIMx_IRQn, 2, 1);
493 HAL_NVIC_EnableIRQ(TIMx_IRQn);
494
495 }
496 }
497
498 void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm)
499 {
500
501 if(htim_pwm->Instance==TIM2)
502 {
503 /* USER CODE BEGIN TIM2_MspDeInit 0 */
504
505 /* USER CODE END TIM2_MspDeInit 0 */
506 /* Peripheral clock disable */
507 __TIM2_CLK_DISABLE();
508
509 /**TIM2 GPIO Configuration
510 PA15 ------> TIM2_CH1
511 */
512 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15);
513
514 /* USER CODE BEGIN TIM2_MspDeInit 1 */
515
516 /* USER CODE END TIM2_MspDeInit 1 */
517 }
518
519 }
520
521 void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
522 {
523
524 if(htim_base->Instance==TIM3)
525 {
526 /* USER CODE BEGIN TIM3_MspDeInit 0 */
527
528 /* USER CODE END TIM3_MspDeInit 0 */
529 /* Peripheral clock disable */
530 __TIM3_CLK_DISABLE();
531
532 /**TIM3 GPIO Configuration
533 PC7 ------> TIM3_CH2
534 */
535 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7);
536
537 /* USER CODE BEGIN TIM3_MspDeInit 1 */
538
539 /* USER CODE END TIM3_MspDeInit 1 */
540 }
541
542 }
543
544 void HAL_UART_MspInit(UART_HandleTypeDef* huart)
545 {
546
547 GPIO_InitTypeDef GPIO_InitStruct;
548 if(huart->Instance==USART1)
549 {
550 /* USER CODE BEGIN USART1_MspInit 0 */
551 __GPIOA_CLK_ENABLE();
552
553 /* USER CODE END USART1_MspInit 0 */
554 /* Peripheral clock enable */
555 __USART1_CLK_ENABLE();
556
557 /**USART1 GPIO Configuration
558 PA9 ------> USART1_TX
559 PA10 ------> USART1_RX
560 */
561 GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
562 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
563 GPIO_InitStruct.Pull = GPIO_PULLUP;
564 GPIO_InitStruct.Speed = GPIO_SPEED_FAST;//GPIO_SPEED_LOW;
565 GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
566 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
567
568 HAL_NVIC_SetPriority(USART1_IRQn, 0, 1);
569 HAL_NVIC_EnableIRQ(USART1_IRQn);
570 }
571 else if(huart->Instance==USART_IR_HUD) /* USART2 */
572 {
573 USART_IR_HUD_CLK_ENABLE();
574 USART_IR_HUD_TX_GPIO_CLK_ENABLE();
575 USART_IR_HUD_RX_GPIO_CLK_ENABLE();
576
577 /**USART2 GPIO Configuration
578 PD5 ------> USART2_TX
579 PD6 ------> USART2_RX
580 */
581
582 GPIO_InitStruct.Pin = USART_IR_HUD_TX_PIN;
583 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
584 GPIO_InitStruct.Pull = GPIO_PULLUP;
585 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
586 GPIO_InitStruct.Alternate = USART_IR_HUD_TX_AF;
587 HAL_GPIO_Init(USART_IR_HUD_TX_GPIO_PORT, &GPIO_InitStruct);
588
589 GPIO_InitStruct.Pin = USART_IR_HUD_RX_PIN;
590 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
591 GPIO_InitStruct.Pull = GPIO_PULLUP;
592 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
593 GPIO_InitStruct.Alternate = USART_IR_HUD_RX_AF;
594 HAL_GPIO_Init(USART_IR_HUD_RX_GPIO_PORT, &GPIO_InitStruct);
595
596 HAL_NVIC_SetPriority(USART_IR_HUD_IRQn, 0, 1);
597 HAL_NVIC_EnableIRQ(USART_IR_HUD_IRQn);
598 }
599 else if(huart->Instance==USART3)
600 {
601 /* USER CODE BEGIN USART3_MspInit 0 */
602
603 /* USER CODE END USART3_MspInit 0 */
604 /* Peripheral clock enable */
605 __USART3_CLK_ENABLE();
606
607 /**USART3 GPIO Configuration
608 PC10 ------> USART3_TX
609 PC11 ------> USART3_RX
610 */
611 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
612 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
613 GPIO_InitStruct.Pull = GPIO_PULLUP;
614 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
615 GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
616 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
617
618 /* USER CODE BEGIN USART3_MspInit 1 */
619
620 /* USER CODE END USART3_MspInit 1 */
621 }
622
623 }
624
625 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
626 {
627
628 if(huart->Instance==USART1)
629 {
630 /* USER CODE BEGIN USART1_MspDeInit 0 */
631
632 /* USER CODE END USART1_MspDeInit 0 */
633 /* Peripheral clock disable */
634 __USART1_CLK_DISABLE();
635
636 /**USART1 GPIO Configuration
637 PA9 ------> USART1_TX
638 PA10 ------> USART1_RX
639 */
640 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
641
642 /* USER CODE BEGIN USART1_MspDeInit 1 */
643
644 /* USER CODE END USART1_MspDeInit 1 */
645 }
646 else if(huart->Instance==USART2)
647 {
648 /* USER CODE BEGIN USART2_MspDeInit 0 */
649
650 /* USER CODE END USART2_MspDeInit 0 */
651 /* Peripheral clock disable */
652 __USART2_CLK_DISABLE();
653
654 /**USART2 GPIO Configuration
655 PD5 ------> USART2_TX
656 PD6 ------> USART2_RX
657 */
658 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_5|GPIO_PIN_6);
659
660 /* USER CODE BEGIN USART2_MspDeInit 1 */
661
662 /* USER CODE END USART2_MspDeInit 1 */
663 }
664 else if(huart->Instance==USART3)
665 {
666 /* USER CODE BEGIN USART3_MspDeInit 0 */
667
668 /* USER CODE END USART3_MspDeInit 0 */
669 /* Peripheral clock disable */
670 __USART3_CLK_DISABLE();
671
672 /**USART3 GPIO Configuration
673 PC10 ------> USART3_TX
674 PC11 ------> USART3_RX
675 */
676 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
677
678 /* USER CODE BEGIN USART3_MspDeInit 1 */
679
680 /* USER CODE END USART3_MspDeInit 1 */
681 }
682
683 }
684
685 static int FMC_Initialized = 0;
686
687 static void HAL_FMC_MspInit(void){
688 GPIO_InitTypeDef GPIO_InitStruct;
689 if (FMC_Initialized) {
690 return;
691 }
692 FMC_Initialized = 1;
693 /* Peripheral clock enable */
694 /* by christian */
695 __GPIOC_CLK_ENABLE();
696 __GPIOD_CLK_ENABLE();
697 __GPIOE_CLK_ENABLE();
698 __GPIOF_CLK_ENABLE();
699 __GPIOG_CLK_ENABLE();
700 __GPIOH_CLK_ENABLE();
701
702 __FMC_CLK_ENABLE();
703
704 /** FMC GPIO Configuration
705 PF0 ------> FMC_A0
706 PF1 ------> FMC_A1
707 PF2 ------> FMC_A2
708 PF3 ------> FMC_A3
709 PF4 ------> FMC_A4
710 PF5 ------> FMC_A5
711 PC0 ------> FMC_SDNWE
712 PF11 ------> FMC_SDNRAS
713 PF12 ------> FMC_A6
714 PF13 ------> FMC_A7
715 PF14 ------> FMC_A8
716 PF15 ------> FMC_A9
717 PG0 ------> FMC_A10
718 PG1 ------> FMC_A11
719 PE7 ------> FMC_D4
720 PE8 ------> FMC_D5
721 PE9 ------> FMC_D6
722 PE10 ------> FMC_D7
723 PE11 ------> FMC_D8
724 PE12 ------> FMC_D9
725 PE13 ------> FMC_D10
726 PE14 ------> FMC_D11
727 PE15 ------> FMC_D12
728 PH6 ------> FMC_SDNE1 neu
729 PH7 ------> FMC_SDCKE1 neu
730 PD8 ------> FMC_D13
731 PD9 ------> FMC_D14
732 PD10 ------> FMC_D15
733 PD14 ------> FMC_D0
734 PD15 ------> FMC_D1
735 PG2 ------> FMC_A12
736 PG4 ------> FMC_BA0
737 PG5 ------> FMC_BA1
738 PG8 ------> FMC_SDCLK
739 PD0 ------> FMC_D2
740 PD1 ------> FMC_D3
741 PG15 ------> FMC_SDNCAS
742 PE0 ------> FMC_NBL0
743 PE1 ------> FMC_NBL1
744 */
745
746 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
747 GPIO_InitStruct.Pull = GPIO_NOPULL;
748 GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
749 GPIO_InitStruct.Alternate = GPIO_AF12_FMC;
750
751
752 GPIO_InitStruct.Pin = GPIO_PIN_0;
753 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
754
755 GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
756 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
757 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
758
759 GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
760 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
761 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
762 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
763
764 GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
765 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
766 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
767 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
768
769 GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4
770 |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15;
771 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
772
773 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
774 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
775
776
777 }
778
779 void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){
780 HAL_FMC_MspInit();
781 }
782
783 static int FMC_DeInitialized = 0;
784
785 static void HAL_FMC_MspDeInit(void){
786 if (FMC_DeInitialized) {
787 return;
788 }
789 FMC_DeInitialized = 1;
790 /* Peripheral clock enable */
791 __FMC_CLK_DISABLE();
792
793 /** FMC GPIO Configuration
794 PF0 ------> FMC_A0
795 PF1 ------> FMC_A1
796 PF2 ------> FMC_A2
797 PF3 ------> FMC_A3
798 PF4 ------> FMC_A4
799 PF5 ------> FMC_A5
800 PC0 ------> FMC_SDNWE
801 PF11 ------> FMC_SDNRAS
802 PF12 ------> FMC_A6
803 PF13 ------> FMC_A7
804 PF14 ------> FMC_A8
805 PF15 ------> FMC_A9
806 PG0 ------> FMC_A10
807 PG1 ------> FMC_A11
808 PE7 ------> FMC_D4
809 PE8 ------> FMC_D5
810 PE9 ------> FMC_D6
811 PE10 ------> FMC_D7
812 PE11 ------> FMC_D8
813 PE12 ------> FMC_D9
814 PE13 ------> FMC_D10
815 PE14 ------> FMC_D11
816 PE15 ------> FMC_D12
817 PH6 ------> FMC_SDNE1
818 PH7 ------> FMC_SDCKE1
819 PD8 ------> FMC_D13
820 PD9 ------> FMC_D14
821 PD10 ------> FMC_D15
822 PD14 ------> FMC_D0
823 PD15 ------> FMC_D1
824 PG2 ------> FMC_A12
825 PG4 ------> FMC_BA0
826 PG5 ------> FMC_BA1
827 PG8 ------> FMC_SDCLK
828 PD0 ------> FMC_D2
829 PD1 ------> FMC_D3
830 PG15 ------> FMC_SDNCAS
831 PE0 ------> FMC_NBL0
832 PE1 ------> FMC_NBL1
833 */
834 HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
835 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
836 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
837
838 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0);
839
840 HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4
841 |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15);
842
843 HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
844 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
845 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
846
847 HAL_GPIO_DeInit(GPIOH, GPIO_PIN_6|GPIO_PIN_7);
848
849 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14
850 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
851
852 }
853
854 void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){
855 HAL_FMC_MspDeInit();
856 }
857
858 /* USER CODE BEGIN 1 */
859
860 /* USER CODE END 1 */
861
862 /**
863 * @}
864 */
865
866 /**
867 * @}
868 */
869
870 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/