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