Mercurial > public > ostc4
comparison OtherSources/stm32f4xx_hal_msp_hw2.c @ 5:e65d01b6a17e
MOVE files for other applications
author | JeanDo |
---|---|
date | Fri, 15 Dec 2017 01:45:20 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:89a87ddc2e47 | 5:e65d01b6a17e |
---|---|
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 if(htim_base->Instance==TIM7) | |
496 { | |
497 __TIM7_CLK_ENABLE(); | |
498 | |
499 HAL_NVIC_SetPriority(TIM7_IRQn, 2, 0); | |
500 HAL_NVIC_EnableIRQ(TIM7_IRQn); | |
501 } | |
502 } | |
503 | |
504 void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) | |
505 { | |
506 | |
507 if(htim_pwm->Instance==TIM2) | |
508 { | |
509 /* USER CODE BEGIN TIM2_MspDeInit 0 */ | |
510 | |
511 /* USER CODE END TIM2_MspDeInit 0 */ | |
512 /* Peripheral clock disable */ | |
513 __TIM2_CLK_DISABLE(); | |
514 | |
515 /**TIM2 GPIO Configuration | |
516 PA15 ------> TIM2_CH1 | |
517 */ | |
518 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15); | |
519 | |
520 /* USER CODE BEGIN TIM2_MspDeInit 1 */ | |
521 | |
522 /* USER CODE END TIM2_MspDeInit 1 */ | |
523 } | |
524 | |
525 } | |
526 | |
527 void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) | |
528 { | |
529 | |
530 if(htim_base->Instance==TIM3) | |
531 { | |
532 /* USER CODE BEGIN TIM3_MspDeInit 0 */ | |
533 | |
534 /* USER CODE END TIM3_MspDeInit 0 */ | |
535 /* Peripheral clock disable */ | |
536 __TIM3_CLK_DISABLE(); | |
537 | |
538 /**TIM3 GPIO Configuration | |
539 PC7 ------> TIM3_CH2 | |
540 */ | |
541 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7); | |
542 | |
543 /* USER CODE BEGIN TIM3_MspDeInit 1 */ | |
544 | |
545 /* USER CODE END TIM3_MspDeInit 1 */ | |
546 } | |
547 | |
548 } | |
549 | |
550 void HAL_UART_MspInit(UART_HandleTypeDef* huart) | |
551 { | |
552 | |
553 GPIO_InitTypeDef GPIO_InitStruct; | |
554 if(huart->Instance==USART1) | |
555 { | |
556 /* USER CODE BEGIN USART1_MspInit 0 */ | |
557 __GPIOA_CLK_ENABLE(); | |
558 | |
559 /* USER CODE END USART1_MspInit 0 */ | |
560 /* Peripheral clock enable */ | |
561 __USART1_CLK_ENABLE(); | |
562 | |
563 /**USART1 GPIO Configuration | |
564 PA9 ------> USART1_TX | |
565 PA10 ------> USART1_RX | |
566 PA11 ------> USART1_CTS | |
567 PA12 ------> USART1_RTS | |
568 */ | |
569 #ifdef USARTx_CTS_PIN | |
570 GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; | |
571 #else | |
572 GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; | |
573 #endif | |
574 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
575 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
576 GPIO_InitStruct.Speed = GPIO_SPEED_FAST;//GPIO_SPEED_LOW; | |
577 GPIO_InitStruct.Alternate = GPIO_AF7_USART1; | |
578 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | |
579 | |
580 HAL_NVIC_SetPriority(USART1_IRQn, 0, 1); | |
581 HAL_NVIC_EnableIRQ(USART1_IRQn); | |
582 } | |
583 #ifdef USART_IR_HUD | |
584 else if(huart->Instance==USART_IR_HUD) /* USART2 */ | |
585 { | |
586 USART_IR_HUD_CLK_ENABLE(); | |
587 USART_IR_HUD_TX_GPIO_CLK_ENABLE(); | |
588 USART_IR_HUD_RX_GPIO_CLK_ENABLE(); | |
589 | |
590 /**USART2 GPIO Configuration | |
591 PD5 ------> USART2_TX | |
592 PD6 ------> USART2_RX | |
593 */ | |
594 | |
595 GPIO_InitStruct.Pin = USART_IR_HUD_TX_PIN; | |
596 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
597 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
598 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
599 GPIO_InitStruct.Alternate = USART_IR_HUD_TX_AF; | |
600 HAL_GPIO_Init(USART_IR_HUD_TX_GPIO_PORT, &GPIO_InitStruct); | |
601 | |
602 GPIO_InitStruct.Pin = USART_IR_HUD_RX_PIN; | |
603 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
604 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
605 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
606 GPIO_InitStruct.Alternate = USART_IR_HUD_RX_AF; | |
607 HAL_GPIO_Init(USART_IR_HUD_RX_GPIO_PORT, &GPIO_InitStruct); | |
608 | |
609 HAL_NVIC_SetPriority(USART_IR_HUD_IRQn, 0, 1); | |
610 HAL_NVIC_EnableIRQ(USART_IR_HUD_IRQn); | |
611 } | |
612 #endif | |
613 else if(huart->Instance==USART3) | |
614 { | |
615 /* USER CODE BEGIN USART3_MspInit 0 */ | |
616 | |
617 /* USER CODE END USART3_MspInit 0 */ | |
618 /* Peripheral clock enable */ | |
619 __USART3_CLK_ENABLE(); | |
620 | |
621 /**USART3 GPIO Configuration | |
622 PC10 ------> USART3_TX | |
623 PC11 ------> USART3_RX | |
624 */ | |
625 GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11; | |
626 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
627 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
628 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
629 GPIO_InitStruct.Alternate = GPIO_AF7_USART3; | |
630 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | |
631 | |
632 /* USER CODE BEGIN USART3_MspInit 1 */ | |
633 | |
634 /* USER CODE END USART3_MspInit 1 */ | |
635 } | |
636 | |
637 } | |
638 | |
639 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) | |
640 { | |
641 | |
642 if(huart->Instance==USART1) | |
643 { | |
644 /* USER CODE BEGIN USART1_MspDeInit 0 */ | |
645 | |
646 /* USER CODE END USART1_MspDeInit 0 */ | |
647 /* Peripheral clock disable */ | |
648 HAL_NVIC_DisableIRQ(USART1_IRQn); | |
649 __USART1_CLK_DISABLE(); | |
650 | |
651 /**USART1 GPIO Configuration | |
652 PA9 ------> USART1_TX | |
653 PA10 ------> USART1_RX | |
654 */ | |
655 #ifdef USARTx_CTS_PIN | |
656 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12); | |
657 #else | |
658 HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); | |
659 #endif | |
660 | |
661 /* USER CODE BEGIN USART1_MspDeInit 1 */ | |
662 | |
663 /* USER CODE END USART1_MspDeInit 1 */ | |
664 } | |
665 else if(huart->Instance==USART2) | |
666 { | |
667 /* USER CODE BEGIN USART2_MspDeInit 0 */ | |
668 | |
669 /* USER CODE END USART2_MspDeInit 0 */ | |
670 /* Peripheral clock disable */ | |
671 __USART2_CLK_DISABLE(); | |
672 | |
673 /**USART2 GPIO Configuration | |
674 PD5 ------> USART2_TX | |
675 PD6 ------> USART2_RX | |
676 */ | |
677 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_5|GPIO_PIN_6); | |
678 | |
679 /* USER CODE BEGIN USART2_MspDeInit 1 */ | |
680 | |
681 /* USER CODE END USART2_MspDeInit 1 */ | |
682 } | |
683 else if(huart->Instance==USART3) | |
684 { | |
685 /* USER CODE BEGIN USART3_MspDeInit 0 */ | |
686 | |
687 /* USER CODE END USART3_MspDeInit 0 */ | |
688 /* Peripheral clock disable */ | |
689 __USART3_CLK_DISABLE(); | |
690 | |
691 /**USART3 GPIO Configuration | |
692 PC10 ------> USART3_TX | |
693 PC11 ------> USART3_RX | |
694 */ | |
695 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11); | |
696 | |
697 /* USER CODE BEGIN USART3_MspDeInit 1 */ | |
698 | |
699 /* USER CODE END USART3_MspDeInit 1 */ | |
700 } | |
701 | |
702 } | |
703 | |
704 static int FMC_Initialized = 0; | |
705 | |
706 static void HAL_FMC_MspInit(void){ | |
707 GPIO_InitTypeDef GPIO_InitStruct; | |
708 if (FMC_Initialized) { | |
709 return; | |
710 } | |
711 FMC_Initialized = 1; | |
712 /* Peripheral clock enable */ | |
713 /* by christian */ | |
714 __GPIOC_CLK_ENABLE(); | |
715 __GPIOD_CLK_ENABLE(); | |
716 __GPIOE_CLK_ENABLE(); | |
717 __GPIOF_CLK_ENABLE(); | |
718 __GPIOG_CLK_ENABLE(); | |
719 __GPIOH_CLK_ENABLE(); | |
720 | |
721 __FMC_CLK_ENABLE(); | |
722 | |
723 /** FMC GPIO Configuration | |
724 PF0 ------> FMC_A0 | |
725 PF1 ------> FMC_A1 | |
726 PF2 ------> FMC_A2 | |
727 PF3 ------> FMC_A3 | |
728 PF4 ------> FMC_A4 | |
729 PF5 ------> FMC_A5 | |
730 PC0 ------> FMC_SDNWE | |
731 PF11 ------> FMC_SDNRAS | |
732 PF12 ------> FMC_A6 | |
733 PF13 ------> FMC_A7 | |
734 PF14 ------> FMC_A8 | |
735 PF15 ------> FMC_A9 | |
736 PG0 ------> FMC_A10 | |
737 PG1 ------> FMC_A11 | |
738 PE7 ------> FMC_D4 | |
739 PE8 ------> FMC_D5 | |
740 PE9 ------> FMC_D6 | |
741 PE10 ------> FMC_D7 | |
742 PE11 ------> FMC_D8 | |
743 PE12 ------> FMC_D9 | |
744 PE13 ------> FMC_D10 | |
745 PE14 ------> FMC_D11 | |
746 PE15 ------> FMC_D12 | |
747 PH6 ------> FMC_SDNE1 neu | |
748 PH7 ------> FMC_SDCKE1 neu | |
749 PD8 ------> FMC_D13 | |
750 PD9 ------> FMC_D14 | |
751 PD10 ------> FMC_D15 | |
752 PD14 ------> FMC_D0 | |
753 PD15 ------> FMC_D1 | |
754 PG2 ------> FMC_A12 | |
755 PG4 ------> FMC_BA0 | |
756 PG5 ------> FMC_BA1 | |
757 PG8 ------> FMC_SDCLK | |
758 PD0 ------> FMC_D2 | |
759 PD1 ------> FMC_D3 | |
760 PG15 ------> FMC_SDNCAS | |
761 PE0 ------> FMC_NBL0 | |
762 PE1 ------> FMC_NBL1 | |
763 */ | |
764 | |
765 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | |
766 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
767 GPIO_InitStruct.Speed = GPIO_SPEED_FAST; | |
768 GPIO_InitStruct.Alternate = GPIO_AF12_FMC; | |
769 | |
770 | |
771 GPIO_InitStruct.Pin = GPIO_PIN_0; | |
772 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | |
773 | |
774 GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 | |
775 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; | |
776 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); | |
777 | |
778 GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 | |
779 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 | |
780 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; | |
781 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); | |
782 | |
783 GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 | |
784 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 | |
785 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; | |
786 HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); | |
787 | |
788 GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4 | |
789 |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15; | |
790 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); | |
791 | |
792 GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; | |
793 HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); | |
794 | |
795 | |
796 } | |
797 | |
798 void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ | |
799 HAL_FMC_MspInit(); | |
800 } | |
801 | |
802 static int FMC_DeInitialized = 0; | |
803 | |
804 static void HAL_FMC_MspDeInit(void){ | |
805 if (FMC_DeInitialized) { | |
806 return; | |
807 } | |
808 FMC_DeInitialized = 1; | |
809 /* Peripheral clock enable */ | |
810 __FMC_CLK_DISABLE(); | |
811 | |
812 /** FMC GPIO Configuration | |
813 PF0 ------> FMC_A0 | |
814 PF1 ------> FMC_A1 | |
815 PF2 ------> FMC_A2 | |
816 PF3 ------> FMC_A3 | |
817 PF4 ------> FMC_A4 | |
818 PF5 ------> FMC_A5 | |
819 PC0 ------> FMC_SDNWE | |
820 PF11 ------> FMC_SDNRAS | |
821 PF12 ------> FMC_A6 | |
822 PF13 ------> FMC_A7 | |
823 PF14 ------> FMC_A8 | |
824 PF15 ------> FMC_A9 | |
825 PG0 ------> FMC_A10 | |
826 PG1 ------> FMC_A11 | |
827 PE7 ------> FMC_D4 | |
828 PE8 ------> FMC_D5 | |
829 PE9 ------> FMC_D6 | |
830 PE10 ------> FMC_D7 | |
831 PE11 ------> FMC_D8 | |
832 PE12 ------> FMC_D9 | |
833 PE13 ------> FMC_D10 | |
834 PE14 ------> FMC_D11 | |
835 PE15 ------> FMC_D12 | |
836 PH6 ------> FMC_SDNE1 | |
837 PH7 ------> FMC_SDCKE1 | |
838 PD8 ------> FMC_D13 | |
839 PD9 ------> FMC_D14 | |
840 PD10 ------> FMC_D15 | |
841 PD14 ------> FMC_D0 | |
842 PD15 ------> FMC_D1 | |
843 PG2 ------> FMC_A12 | |
844 PG4 ------> FMC_BA0 | |
845 PG5 ------> FMC_BA1 | |
846 PG8 ------> FMC_SDCLK | |
847 PD0 ------> FMC_D2 | |
848 PD1 ------> FMC_D3 | |
849 PG15 ------> FMC_SDNCAS | |
850 PE0 ------> FMC_NBL0 | |
851 PE1 ------> FMC_NBL1 | |
852 */ | |
853 HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 | |
854 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 | |
855 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); | |
856 | |
857 HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); | |
858 | |
859 HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4 | |
860 |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_15); | |
861 | |
862 HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 | |
863 |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 | |
864 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); | |
865 | |
866 HAL_GPIO_DeInit(GPIOH, GPIO_PIN_6|GPIO_PIN_7); | |
867 | |
868 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 | |
869 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); | |
870 | |
871 } | |
872 | |
873 void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ | |
874 HAL_FMC_MspDeInit(); | |
875 } | |
876 | |
877 /* USER CODE BEGIN 1 */ | |
878 | |
879 /* USER CODE END 1 */ | |
880 | |
881 /** | |
882 * @} | |
883 */ | |
884 | |
885 /** | |
886 * @} | |
887 */ | |
888 | |
889 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |