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