STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
stm32h7xx_hal_msp.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file stm32h7xx_hal_msp.c
5 * @brief This file provides code for the MSP Initialization
6 * and de-Initialization codes.
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2026 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19/* USER CODE END Header */
20/* Includes ------------------------------------------------------------------*/
21#include "main.h"
22/* USER CODE BEGIN Includes */
23
24/* USER CODE END Includes */
25
26/* Private typedef -----------------------------------------------------------*/
27/* USER CODE BEGIN TD */
28
29/* USER CODE END TD */
30
31/* Private define ------------------------------------------------------------*/
32/* USER CODE BEGIN Define */
33
34/* USER CODE END Define */
35
36/* Private macro -------------------------------------------------------------*/
37/* USER CODE BEGIN Macro */
38
39/* USER CODE END Macro */
40
41/* Private variables ---------------------------------------------------------*/
42/* USER CODE BEGIN PV */
43
44/* USER CODE END PV */
45
46/* Private function prototypes -----------------------------------------------*/
47/* USER CODE BEGIN PFP */
48
49/* USER CODE END PFP */
50
51/* External functions --------------------------------------------------------*/
52/* USER CODE BEGIN ExternalFunctions */
53
54/* USER CODE END ExternalFunctions */
55
56/* USER CODE BEGIN 0 */
57
58/* USER CODE END 0 */
59
61 /**
62 * Initializes the Global MSP.
63 */
64void HAL_MspInit(void)
65{
66
67 /* USER CODE BEGIN MspInit 0 */
68
69 /* USER CODE END MspInit 0 */
70
72
73 /* System interrupt init*/
74 /* PendSV_IRQn interrupt configuration */
76
77 /* USER CODE BEGIN MspInit 1 */
78
79 /* USER CODE END MspInit 1 */
80}
81
82/**
83 * @brief ADC MSP Initialization
84 * This function configures the hardware resources used in this example
85 * @param hadc: ADC handle pointer
86 * @retval None
87 */
89{
90 GPIO_InitTypeDef GPIO_InitStruct = {0};
91 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
92 if(hadc->Instance==ADC1)
93 {
94 /* USER CODE BEGIN ADC1_MspInit 0 */
95
96 /* USER CODE END ADC1_MspInit 0 */
97
98 /** Initializes the peripherals clock
99 */
100 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC;
101 PeriphClkInitStruct.PLL2.PLL2M = 32;
102 PeriphClkInitStruct.PLL2.PLL2N = 129;
103 PeriphClkInitStruct.PLL2.PLL2P = 2;
104 PeriphClkInitStruct.PLL2.PLL2Q = 2;
105 PeriphClkInitStruct.PLL2.PLL2R = 2;
106 PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_1;
107 PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
108 PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
109 PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2;
110 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
111 {
113 }
114
115 /* Peripheral clock enable */
117
120 /**ADC1 GPIO Configuration
121 PC0 ------> ADC1_INP10
122 PC1 ------> ADC1_INP11
123 PA0 ------> ADC1_INP16
124 PA1 ------> ADC1_INP17
125 PA2 ------> ADC1_INP14
126 PA3 ------> ADC1_INP15
127 PA4 ------> ADC1_INP18
128 */
130 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
131 GPIO_InitStruct.Pull = GPIO_NOPULL;
132 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
133
136 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
137 GPIO_InitStruct.Pull = GPIO_NOPULL;
138 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
139
140 /* USER CODE BEGIN ADC1_MspInit 1 */
141
142 /* USER CODE END ADC1_MspInit 1 */
143
144 }
145
146}
147
148/**
149 * @brief ADC MSP De-Initialization
150 * This function freeze the hardware resources used in this example
151 * @param hadc: ADC handle pointer
152 * @retval None
153 */
155{
156 if(hadc->Instance==ADC1)
157 {
158 /* USER CODE BEGIN ADC1_MspDeInit 0 */
159
160 /* USER CODE END ADC1_MspDeInit 0 */
161 /* Peripheral clock disable */
163
164 /**ADC1 GPIO Configuration
165 PC0 ------> ADC1_INP10
166 PC1 ------> ADC1_INP11
167 PA0 ------> ADC1_INP16
168 PA1 ------> ADC1_INP17
169 PA2 ------> ADC1_INP14
170 PA3 ------> ADC1_INP15
171 PA4 ------> ADC1_INP18
172 */
174
177
178 /* USER CODE BEGIN ADC1_MspDeInit 1 */
179
180 /* USER CODE END ADC1_MspDeInit 1 */
181 }
182
183}
184
185/**
186 * @brief I2C MSP Initialization
187 * This function configures the hardware resources used in this example
188 * @param hi2c: I2C handle pointer
189 * @retval None
190 */
192{
193 GPIO_InitTypeDef GPIO_InitStruct = {0};
194 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
195 if(hi2c->Instance==I2C4)
196 {
197 /* USER CODE BEGIN I2C4_MspInit 0 */
198
199 /* USER CODE END I2C4_MspInit 0 */
200
201 /** Initializes the peripherals clock
202 */
203 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C4;
204 PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_D3PCLK1;
205 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
206 {
208 }
209
211 /**I2C4 GPIO Configuration
212 PD12 ------> I2C4_SCL
213 PD13 ------> I2C4_SDA
214 */
215 GPIO_InitStruct.Pin = SPARE_I2C_SCL_Pin|SPARE_I2C_SDA_Pin;
216 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
217 GPIO_InitStruct.Pull = GPIO_NOPULL;
218 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
219 GPIO_InitStruct.Alternate = GPIO_AF4_I2C4;
220 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
221
222 /* Peripheral clock enable */
224 /* USER CODE BEGIN I2C4_MspInit 1 */
225
226 /* USER CODE END I2C4_MspInit 1 */
227
228 }
229
230}
231
232/**
233 * @brief I2C MSP De-Initialization
234 * This function freeze the hardware resources used in this example
235 * @param hi2c: I2C handle pointer
236 * @retval None
237 */
239{
240 if(hi2c->Instance==I2C4)
241 {
242 /* USER CODE BEGIN I2C4_MspDeInit 0 */
243
244 /* USER CODE END I2C4_MspDeInit 0 */
245 /* Peripheral clock disable */
247
248 /**I2C4 GPIO Configuration
249 PD12 ------> I2C4_SCL
250 PD13 ------> I2C4_SDA
251 */
253
255
256 /* USER CODE BEGIN I2C4_MspDeInit 1 */
257
258 /* USER CODE END I2C4_MspDeInit 1 */
259 }
260
261}
262
263/**
264 * @brief RTC MSP Initialization
265 * This function configures the hardware resources used in this example
266 * @param hrtc: RTC handle pointer
267 * @retval None
268 */
270{
271 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
272 if(hrtc->Instance==RTC)
273 {
274 /* USER CODE BEGIN RTC_MspInit 0 */
275
276 /* USER CODE END RTC_MspInit 0 */
277
278 /** Initializes the peripherals clock
279 */
280 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
281 PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
282 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
283 {
285 }
286
287 /* Peripheral clock enable */
289 /* RTC interrupt Init */
292 /* USER CODE BEGIN RTC_MspInit 1 */
293
294 /* USER CODE END RTC_MspInit 1 */
295
296 }
297
298}
299
300/**
301 * @brief RTC MSP De-Initialization
302 * This function freeze the hardware resources used in this example
303 * @param hrtc: RTC handle pointer
304 * @retval None
305 */
307{
308 if(hrtc->Instance==RTC)
309 {
310 /* USER CODE BEGIN RTC_MspDeInit 0 */
311
312 /* USER CODE END RTC_MspDeInit 0 */
313 /* Peripheral clock disable */
315
316 /* RTC interrupt DeInit */
318 /* USER CODE BEGIN RTC_MspDeInit 1 */
319
320 /* USER CODE END RTC_MspDeInit 1 */
321 }
322
323}
324
325/**
326 * @brief MMC MSP Initialization
327 * This function configures the hardware resources used in this example
328 * @param hmmc: MMC handle pointer
329 * @retval None
330 */
331void HAL_MMC_MspInit(MMC_HandleTypeDef* hmmc)
332{
333 GPIO_InitTypeDef GPIO_InitStruct = {0};
334 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
335 if(hmmc->Instance==SDMMC1)
336 {
337 /* USER CODE BEGIN SDMMC1_MspInit 0 */
338
339 /* USER CODE END SDMMC1_MspInit 0 */
340
341 /** Initializes the peripherals clock
342 */
343 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SDMMC;
344 PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL;
345 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
346 {
348 }
349
350 /* Peripheral clock enable */
352
355 /**SDMMC1 GPIO Configuration
356 PC8 ------> SDMMC1_D0
357 PC9 ------> SDMMC1_D1
358 PC10 ------> SDMMC1_D2
359 PC11 ------> SDMMC1_D3
360 PC12 ------> SDMMC1_CK
361 PD2 ------> SDMMC1_CMD
362 */
365 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
366 GPIO_InitStruct.Pull = GPIO_NOPULL;
367 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
368 GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
369 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
370
371 GPIO_InitStruct.Pin = EMMC_CMD_Pin;
372 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
373 GPIO_InitStruct.Pull = GPIO_NOPULL;
374 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
375 GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;
376 HAL_GPIO_Init(EMMC_CMD_GPIO_Port, &GPIO_InitStruct);
377
378 /* SDMMC1 interrupt Init */
381 /* USER CODE BEGIN SDMMC1_MspInit 1 */
382
383 /* USER CODE END SDMMC1_MspInit 1 */
384
385 }
386
387}
388
389/**
390 * @brief MMC MSP De-Initialization
391 * This function freeze the hardware resources used in this example
392 * @param hmmc: MMC handle pointer
393 * @retval None
394 */
395void HAL_MMC_MspDeInit(MMC_HandleTypeDef* hmmc)
396{
397 if(hmmc->Instance==SDMMC1)
398 {
399 /* USER CODE BEGIN SDMMC1_MspDeInit 0 */
400
401 /* USER CODE END SDMMC1_MspDeInit 0 */
402 /* Peripheral clock disable */
404
405 /**SDMMC1 GPIO Configuration
406 PC8 ------> SDMMC1_D0
407 PC9 ------> SDMMC1_D1
408 PC10 ------> SDMMC1_D2
409 PC11 ------> SDMMC1_D3
410 PC12 ------> SDMMC1_CK
411 PD2 ------> SDMMC1_CMD
412 */
414 |EMMC_CLK_Pin);
415
417
418 /* SDMMC1 interrupt DeInit */
420 /* USER CODE BEGIN SDMMC1_MspDeInit 1 */
421
422 /* USER CODE END SDMMC1_MspDeInit 1 */
423 }
424
425}
426
427/**
428 * @brief SPI MSP Initialization
429 * This function configures the hardware resources used in this example
430 * @param hspi: SPI handle pointer
431 * @retval None
432 */
434{
435 GPIO_InitTypeDef GPIO_InitStruct = {0};
436 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
437 if(hspi->Instance==SPI1)
438 {
439 /* USER CODE BEGIN SPI1_MspInit 0 */
440
441 /* USER CODE END SPI1_MspInit 0 */
442
443 /** Initializes the peripherals clock
444 */
445 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI1;
446 PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
447 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
448 {
450 }
451
452 /* Peripheral clock enable */
454
456 /**SPI1 GPIO Configuration
457 PA5 ------> SPI1_SCK
458 PA6 ------> SPI1_MISO
459 PA7 ------> SPI1_MOSI
460 */
462 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
463 GPIO_InitStruct.Pull = GPIO_NOPULL;
464 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
465 GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
466 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
467
468 /* USER CODE BEGIN SPI1_MspInit 1 */
469
470 /* USER CODE END SPI1_MspInit 1 */
471 }
472 else if(hspi->Instance==SPI2)
473 {
474 /* USER CODE BEGIN SPI2_MspInit 0 */
475
476 /* USER CODE END SPI2_MspInit 0 */
477
478 /** Initializes the peripherals clock
479 */
480 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI2;
481 PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
482 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
483 {
485 }
486
487 /* Peripheral clock enable */
489
492 /**SPI2 GPIO Configuration
493 PC2_C ------> SPI2_MISO
494 PC3_C ------> SPI2_MOSI
495 PB10 ------> SPI2_SCK
496 */
497 GPIO_InitStruct.Pin = ETH_SPI2_MISO_Pin|ETH_SPI2_MOSI_Pin;
498 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
499 GPIO_InitStruct.Pull = GPIO_NOPULL;
500 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
501 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
502 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
503
504 GPIO_InitStruct.Pin = ETH_CLK_Pin;
505 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
506 GPIO_InitStruct.Pull = GPIO_NOPULL;
507 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
508 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
509 HAL_GPIO_Init(ETH_CLK_GPIO_Port, &GPIO_InitStruct);
510
511 /* USER CODE BEGIN SPI2_MspInit 1 */
512
513 /* USER CODE END SPI2_MspInit 1 */
514 }
515 else if(hspi->Instance==SPI3)
516 {
517 /* USER CODE BEGIN SPI3_MspInit 0 */
518
519 /* USER CODE END SPI3_MspInit 0 */
520
521 /** Initializes the peripherals clock
522 */
523 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI3;
524 PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
525 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
526 {
528 }
529
530 /* Peripheral clock enable */
532
534 /**SPI3 GPIO Configuration
535 PB3(JTDO/TRACESWO) ------> SPI3_SCK
536 PB4(NJTRST) ------> SPI3_MISO
537 PB5 ------> SPI3_MOSI
538 */
539 GPIO_InitStruct.Pin = SENSOR_CLK_Pin|SENSOR_MISO_Pin;
540 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
541 GPIO_InitStruct.Pull = GPIO_NOPULL;
542 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
543 GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
544 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
545
546 GPIO_InitStruct.Pin = SENSOR_MOSI_Pin;
547 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
548 GPIO_InitStruct.Pull = GPIO_NOPULL;
549 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
550 GPIO_InitStruct.Alternate = GPIO_AF7_SPI3;
551 HAL_GPIO_Init(SENSOR_MOSI_GPIO_Port, &GPIO_InitStruct);
552
553 /* USER CODE BEGIN SPI3_MspInit 1 */
554
555 /* USER CODE END SPI3_MspInit 1 */
556 }
557 else if(hspi->Instance==SPI4)
558 {
559 /* USER CODE BEGIN SPI4_MspInit 0 */
560
561 /* USER CODE END SPI4_MspInit 0 */
562
563 /** Initializes the peripherals clock
564 */
565 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI4;
566 PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_D2PCLK1;
567 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
568 {
570 }
571
572 /* Peripheral clock enable */
574
576 /**SPI4 GPIO Configuration
577 PE2 ------> SPI4_SCK
578 PE5 ------> SPI4_MISO
579 PE6 ------> SPI4_MOSI
580 */
581 GPIO_InitStruct.Pin = NAND_SPI4_CLK_Pin|NAND_SPI4_MOSI_Pin;
582 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
583 GPIO_InitStruct.Pull = GPIO_NOPULL;
584 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
585 GPIO_InitStruct.Alternate = GPIO_AF5_SPI4;
586 HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
587
588 GPIO_InitStruct.Pin = NAND_SPI4_MISO_Pin;
589 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
590 GPIO_InitStruct.Pull = GPIO_PULLUP;
591 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
592 GPIO_InitStruct.Alternate = GPIO_AF5_SPI4;
593 HAL_GPIO_Init(NAND_SPI4_MISO_GPIO_Port, &GPIO_InitStruct);
594
595 /* USER CODE BEGIN SPI4_MspInit 1 */
596
597 /* USER CODE END SPI4_MspInit 1 */
598 }
599
600}
601
602/**
603 * @brief SPI MSP De-Initialization
604 * This function freeze the hardware resources used in this example
605 * @param hspi: SPI handle pointer
606 * @retval None
607 */
609{
610 if(hspi->Instance==SPI1)
611 {
612 /* USER CODE BEGIN SPI1_MspDeInit 0 */
613
614 /* USER CODE END SPI1_MspDeInit 0 */
615 /* Peripheral clock disable */
617
618 /**SPI1 GPIO Configuration
619 PA5 ------> SPI1_SCK
620 PA6 ------> SPI1_MISO
621 PA7 ------> SPI1_MOSI
622 */
624
625 /* USER CODE BEGIN SPI1_MspDeInit 1 */
626
627 /* USER CODE END SPI1_MspDeInit 1 */
628 }
629 else if(hspi->Instance==SPI2)
630 {
631 /* USER CODE BEGIN SPI2_MspDeInit 0 */
632
633 /* USER CODE END SPI2_MspDeInit 0 */
634 /* Peripheral clock disable */
636
637 /**SPI2 GPIO Configuration
638 PC2_C ------> SPI2_MISO
639 PC3_C ------> SPI2_MOSI
640 PB10 ------> SPI2_SCK
641 */
643
645
646 /* USER CODE BEGIN SPI2_MspDeInit 1 */
647
648 /* USER CODE END SPI2_MspDeInit 1 */
649 }
650 else if(hspi->Instance==SPI3)
651 {
652 /* USER CODE BEGIN SPI3_MspDeInit 0 */
653
654 /* USER CODE END SPI3_MspDeInit 0 */
655 /* Peripheral clock disable */
657
658 /**SPI3 GPIO Configuration
659 PB3(JTDO/TRACESWO) ------> SPI3_SCK
660 PB4(NJTRST) ------> SPI3_MISO
661 PB5 ------> SPI3_MOSI
662 */
664
665 /* USER CODE BEGIN SPI3_MspDeInit 1 */
666
667 /* USER CODE END SPI3_MspDeInit 1 */
668 }
669 else if(hspi->Instance==SPI4)
670 {
671 /* USER CODE BEGIN SPI4_MspDeInit 0 */
672
673 /* USER CODE END SPI4_MspDeInit 0 */
674 /* Peripheral clock disable */
676
677 /**SPI4 GPIO Configuration
678 PE2 ------> SPI4_SCK
679 PE5 ------> SPI4_MISO
680 PE6 ------> SPI4_MOSI
681 */
683
684 /* USER CODE BEGIN SPI4_MspDeInit 1 */
685
686 /* USER CODE END SPI4_MspDeInit 1 */
687 }
688
689}
690
691/**
692 * @brief TIM_PWM MSP Initialization
693 * This function configures the hardware resources used in this example
694 * @param htim_pwm: TIM_PWM handle pointer
695 * @retval None
696 */
698{
699 if(htim_pwm->Instance==TIM1)
700 {
701 /* USER CODE BEGIN TIM1_MspInit 0 */
702
703 /* USER CODE END TIM1_MspInit 0 */
704 /* Peripheral clock enable */
706 /* USER CODE BEGIN TIM1_MspInit 1 */
707
708 /* USER CODE END TIM1_MspInit 1 */
709 }
710 else if(htim_pwm->Instance==TIM3)
711 {
712 /* USER CODE BEGIN TIM3_MspInit 0 */
713
714 /* USER CODE END TIM3_MspInit 0 */
715 /* Peripheral clock enable */
717 /* USER CODE BEGIN TIM3_MspInit 1 */
718
719 /* USER CODE END TIM3_MspInit 1 */
720 }
721
722}
723
724/**
725 * @brief TIM_Base MSP Initialization
726 * This function configures the hardware resources used in this example
727 * @param htim_base: TIM_Base handle pointer
728 * @retval None
729 */
731{
732 GPIO_InitTypeDef GPIO_InitStruct = {0};
733 if(htim_base->Instance==TIM2)
734 {
735 /* USER CODE BEGIN TIM2_MspInit 0 */
736
737 /* USER CODE END TIM2_MspInit 0 */
738 /* Peripheral clock enable */
740
742 /**TIM2 GPIO Configuration
743 PB11 ------> TIM2_CH4
744 */
745 GPIO_InitStruct.Pin = TIMEPULSE_Pin;
746 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
747 GPIO_InitStruct.Pull = GPIO_NOPULL;
748 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
749 GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
750 HAL_GPIO_Init(TIMEPULSE_GPIO_Port, &GPIO_InitStruct);
751
752 /* TIM2 interrupt Init */
755 /* USER CODE BEGIN TIM2_MspInit 1 */
756
757 /* USER CODE END TIM2_MspInit 1 */
758
759 }
760
761}
762
764{
765 GPIO_InitTypeDef GPIO_InitStruct = {0};
766 if(htim->Instance==TIM1)
767 {
768 /* USER CODE BEGIN TIM1_MspPostInit 0 */
769
770 /* USER CODE END TIM1_MspPostInit 0 */
772 /**TIM1 GPIO Configuration
773 PB14 ------> TIM1_CH2N
774 */
775 GPIO_InitStruct.Pin = GPIO_PIN_14;
776 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
777 GPIO_InitStruct.Pull = GPIO_NOPULL;
778 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
779 GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
780 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
781
782 /* USER CODE BEGIN TIM1_MspPostInit 1 */
783
784 /* USER CODE END TIM1_MspPostInit 1 */
785 }
786 else if(htim->Instance==TIM3)
787 {
788 /* USER CODE BEGIN TIM3_MspPostInit 0 */
789
790 /* USER CODE END TIM3_MspPostInit 0 */
791
793 /**TIM3 GPIO Configuration
794 PC6 ------> TIM3_CH1
795 PC7 ------> TIM3_CH2
796 */
797 GPIO_InitStruct.Pin = PWM1_Pin|PWM2_Pin;
798 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
799 GPIO_InitStruct.Pull = GPIO_NOPULL;
800 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
801 GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
802 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
803
804 /* USER CODE BEGIN TIM3_MspPostInit 1 */
805
806 /* USER CODE END TIM3_MspPostInit 1 */
807 }
808
809}
810/**
811 * @brief TIM_PWM MSP De-Initialization
812 * This function freeze the hardware resources used in this example
813 * @param htim_pwm: TIM_PWM handle pointer
814 * @retval None
815 */
817{
818 if(htim_pwm->Instance==TIM1)
819 {
820 /* USER CODE BEGIN TIM1_MspDeInit 0 */
821
822 /* USER CODE END TIM1_MspDeInit 0 */
823 /* Peripheral clock disable */
825 /* USER CODE BEGIN TIM1_MspDeInit 1 */
826
827 /* USER CODE END TIM1_MspDeInit 1 */
828 }
829 else if(htim_pwm->Instance==TIM3)
830 {
831 /* USER CODE BEGIN TIM3_MspDeInit 0 */
832
833 /* USER CODE END TIM3_MspDeInit 0 */
834 /* Peripheral clock disable */
836 /* USER CODE BEGIN TIM3_MspDeInit 1 */
837
838 /* USER CODE END TIM3_MspDeInit 1 */
839 }
840
841}
842
843/**
844 * @brief TIM_Base MSP De-Initialization
845 * This function freeze the hardware resources used in this example
846 * @param htim_base: TIM_Base handle pointer
847 * @retval None
848 */
850{
851 if(htim_base->Instance==TIM2)
852 {
853 /* USER CODE BEGIN TIM2_MspDeInit 0 */
854
855 /* USER CODE END TIM2_MspDeInit 0 */
856 /* Peripheral clock disable */
858
859 /**TIM2 GPIO Configuration
860 PB11 ------> TIM2_CH4
861 */
863
864 /* TIM2 interrupt DeInit */
866 /* USER CODE BEGIN TIM2_MspDeInit 1 */
867
868 /* USER CODE END TIM2_MspDeInit 1 */
869 }
870
871}
872
873/**
874 * @brief UART MSP Initialization
875 * This function configures the hardware resources used in this example
876 * @param huart: UART handle pointer
877 * @retval None
878 */
880{
881 GPIO_InitTypeDef GPIO_InitStruct = {0};
882 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
883 if(huart->Instance==UART9)
884 {
885 /* USER CODE BEGIN UART9_MspInit 0 */
886
887 /* USER CODE END UART9_MspInit 0 */
888
889 /** Initializes the peripherals clock
890 */
891 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART9;
893 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
894 {
896 }
897
898 /* Peripheral clock enable */
899 __HAL_RCC_UART9_CLK_ENABLE();
900
902 /**UART9 GPIO Configuration
903 PD14 ------> UART9_RX
904 PD15 ------> UART9_TX
905 */
906 GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
907 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
908 GPIO_InitStruct.Pull = GPIO_NOPULL;
909 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
910 GPIO_InitStruct.Alternate = GPIO_AF11_UART9;
911 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
912
913 /* UART9 interrupt Init */
916 /* USER CODE BEGIN UART9_MspInit 1 */
917
918 /* USER CODE END UART9_MspInit 1 */
919
920 }
921
922}
923
924/**
925 * @brief UART MSP De-Initialization
926 * This function freeze the hardware resources used in this example
927 * @param huart: UART handle pointer
928 * @retval None
929 */
931{
932 if(huart->Instance==UART9)
933 {
934 /* USER CODE BEGIN UART9_MspDeInit 0 */
935
936 /* USER CODE END UART9_MspDeInit 0 */
937 /* Peripheral clock disable */
938 __HAL_RCC_UART9_CLK_DISABLE();
939
940 /**UART9 GPIO Configuration
941 PD14 ------> UART9_RX
942 PD15 ------> UART9_TX
943 */
945
946 /* UART9 interrupt DeInit */
948 /* USER CODE BEGIN UART9_MspDeInit 1 */
949
950 /* USER CODE END UART9_MspDeInit 1 */
951 }
952
953}
954
955/* USER CODE BEGIN 1 */
956
957/* USER CODE END 1 */
#define NAND_SPI4_MISO_Pin
Definition main.h:69
#define SPARE_I2C_SDA_Pin
Definition main.h:135
#define ETH_SPI2_MISO_Pin
Definition main.h:83
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition main.c:1145
#define PWM2_Pin
Definition main.h:139
#define EXT_SENSE_ADC_Pin
Definition main.h:89
#define NAND_SPI4_CLK_Pin
Definition main.h:63
#define NAND_SPI4_MISO_GPIO_Port
Definition main.h:70
#define SENSOR_MOSI_Pin
Definition main.h:185
#define SENSOR_MISO_Pin
Definition main.h:183
#define EMMC_D2_Pin
Definition main.h:157
#define RADIO_CLK_Pin
Definition main.h:97
#define SPARE_I2C_SDA_GPIO_Port
Definition main.h:136
#define SENSOR_MOSI_GPIO_Port
Definition main.h:186
#define RADIO_MOSI_Pin
Definition main.h:101
#define EMMC_D1_Pin
Definition main.h:143
#define PYRO_1_CONT_ADC_Pin
Definition main.h:91
#define EXT_SENSE_ADC_2_Pin
Definition main.h:95
#define EMMC_CLK_Pin
Definition main.h:161
#define ETH_CLK_GPIO_Port
Definition main.h:126
#define EMMC_CMD_Pin
Definition main.h:168
#define EMMC_D0_Pin
Definition main.h:141
#define EMMC_CMD_GPIO_Port
Definition main.h:169
#define SPARE_I2C_SCL_GPIO_Port
Definition main.h:134
#define NAND_SPI4_MOSI_Pin
Definition main.h:71
#define ALT_CURR_SENSE_ADC_Pin
Definition main.h:79
#define PYRO_2_CONT_ADC_Pin
Definition main.h:93
#define RADIO_MISO_Pin
Definition main.h:99
#define VBAT_ADC_Pin
Definition main.h:87
#define TIMEPULSE_GPIO_Port
Definition main.h:128
#define ETH_CLK_Pin
Definition main.h:125
#define PWM1_Pin
Definition main.h:137
#define SPARE_I2C_SCL_Pin
Definition main.h:133
#define SENSOR_CLK_Pin
Definition main.h:181
#define ETH_SPI2_MOSI_Pin
Definition main.h:85
#define EMMC_D3_Pin
Definition main.h:159
#define CURR_SENSE_ADC_Pin
Definition main.h:81
#define TIMEPULSE_Pin
Definition main.h:127
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
ADC MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
ADC MSP Initialization This function configures the hardware resources used in this example.
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
#define GPIO_AF5_SPI2
#define GPIO_AF1_TIM1
AF 1 selection.
#define GPIO_AF7_SPI3
#define GPIO_AF2_TIM3
AF 2 selection.
#define GPIO_AF1_TIM2
#define GPIO_AF4_I2C4
#define GPIO_AF12_SDMMC1
#define GPIO_AF6_SPI3
#define GPIO_AF5_SPI4
#define GPIO_AF5_SPI1
AF 5 selection.
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, const GPIO_InitTypeDef *GPIO_Init)
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
#define GPIO_MODE_AF_OD
Alternate Function Open Drain Mode.
#define GPIO_MODE_AF_PP
Alternate Function Push Pull Mode.
#define GPIO_MODE_ANALOG
Analog Mode.
#define GPIO_PIN_14
#define GPIO_PIN_15
#define GPIO_NOPULL
No Pull-up or Pull-down activation.
#define GPIO_PULLUP
Pull-up activation.
#define GPIO_SPEED_FREQ_VERY_HIGH
High speed.
#define GPIO_SPEED_FREQ_LOW
Low speed.
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
I2C MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
I2C MSP Initialization This function configures the hardware resources used in this example.
struct __I2C_HandleTypeDef I2C_HandleTypeDef
#define SDMMC1
#define SPI4
#define GPIOC
#define TIM1
#define TIM2
#define RTC
#define TIM3
#define GPIOB
#define I2C4
#define UART9
#define GPIOD
#define ADC1
#define SPI3
#define GPIOA
#define SPI1
#define GPIOE
#define SPI2
@ PendSV_IRQn
14 Cortex-M Pend SV Interrupt
Definition stm32h723xx.h:58
@ RTC_WKUP_IRQn
RTC Wakeup interrupt through the EXTI line.
Definition stm32h723xx.h:64
@ UART9_IRQn
UART9 global Interrupt.
@ TIM2_IRQn
TIM2 global Interrupt.
Definition stm32h723xx.h:89
@ SDMMC1_IRQn
SDMMC1 global Interrupt.
#define RCC_ADCCLKSOURCE_PLL2
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
#define RCC_I2C4CLKSOURCE_D3PCLK1
#define RCC_PERIPHCLK_SPI1
#define RCC_PERIPHCLK_I2C4
#define RCC_PERIPHCLK_SPI4
#define RCC_PERIPHCLK_SPI3
#define RCC_PERIPHCLK_ADC
#define RCC_PERIPHCLK_SPI2
#define RCC_PERIPHCLK_RTC
#define RCC_PERIPHCLK_SDMMC
#define RCC_SDMMCCLKSOURCE_PLL
#define RCC_SPI123CLKSOURCE_PLL
#define RCC_USART16910CLKSOURCE_D2PCLK2
#define __HAL_RCC_SPI2_CLK_ENABLE()
#define __HAL_RCC_SPI3_CLK_ENABLE()
#define __HAL_RCC_GPIOA_CLK_ENABLE()
Enable or disable the AHB4 peripheral clock.
#define __HAL_RCC_SPI4_CLK_ENABLE()
#define __HAL_RCC_GPIOE_CLK_ENABLE()
#define __HAL_RCC_TIM2_CLK_ENABLE()
Enable or disable the APB1 peripheral clock.
#define __HAL_RCC_GPIOB_CLK_ENABLE()
#define __HAL_RCC_GPIOC_CLK_ENABLE()
#define __HAL_RCC_SDMMC1_CLK_ENABLE()
#define __HAL_RCC_GPIOD_CLK_ENABLE()
#define __HAL_RCC_SPI4_CLK_DISABLE()
#define __HAL_RCC_SPI1_CLK_ENABLE()
#define __HAL_RCC_TIM3_CLK_DISABLE()
#define __HAL_RCC_TIM1_CLK_DISABLE()
#define __HAL_RCC_RTC_DISABLE()
#define __HAL_RCC_RTC_ENABLE()
Macros to enable or disable the the RTC clock.
#define __HAL_RCC_ADC12_CLK_ENABLE()
#define __HAL_RCC_SDMMC1_CLK_DISABLE()
#define __HAL_RCC_SPI2_CLK_DISABLE()
#define __HAL_RCC_TIM2_CLK_DISABLE()
#define __HAL_RCC_TIM1_CLK_ENABLE()
Enable or disable the APB2 peripheral clock.
#define __HAL_RCC_SPI3_CLK_DISABLE()
#define __HAL_RCC_I2C4_CLK_DISABLE()
#define __HAL_RCC_I2C4_CLK_ENABLE()
#define __HAL_RCC_ADC12_CLK_DISABLE()
#define __HAL_RCC_SPI1_CLK_DISABLE()
#define __HAL_RCC_TIM3_CLK_ENABLE()
#define __HAL_RCC_SYSCFG_CLK_ENABLE()
Enable or disable the APB4 peripheral clock.
#define RCC_PLL2VCIRANGE_1
Clock range frequency between 2 and 4 MHz.
#define RCC_PLL2VCOWIDE
#define RCC_RTCCLKSOURCE_LSI
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
RTC MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
RTC MSP Initialization This function configures the hardware resources used in this example.
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
SPI MSP Initialization This function configures the hardware resources used in this example.
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi)
SPI MSP De-Initialization This function freeze the hardware resources used in this example.
struct __SPI_HandleTypeDef SPI_HandleTypeDef
SPI handle Structure definition.
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim_base)
TIM_Base MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim_base)
TIM_Base MSP Initialization This function configures the hardware resources used in this example.
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim_pwm)
TIM_PWM MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim_pwm)
TIM_PWM MSP Initialization This function configures the hardware resources used in this example.
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
UART MSP Initialization This function configures the hardware resources used in this example.
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
UART MSP De-Initialization This function freeze the hardware resources used in this example.
struct __UART_HandleTypeDef UART_HandleTypeDef
UART handle Structure definition.
RTC_HandleTypeDef hrtc
Definition main.c:52
@ HAL_OK
void HAL_MMC_MspInit(MMC_HandleTypeDef *hmmc)
MMC MSP Initialization This function configures the hardware resources used in this example.
void HAL_MMC_MspDeInit(MMC_HandleTypeDef *hmmc)
MMC MSP De-Initialization This function freeze the hardware resources used in this example.
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim)
void HAL_MspInit(void)
Initializes the Global MSP.
ADC handle Structure definition.
ADC_TypeDef * Instance
Register base address.
GPIO Init structure definition.
uint32_t Mode
Specifies the operating mode for the selected pins.
uint32_t Alternate
Peripheral to be connected to the selected pins.
uint32_t Pull
Specifies the Pull-up or Pull-Down activation for the selected pins.
uint32_t Pin
Specifies the GPIO pins to be configured.
uint32_t Speed
Specifies the speed for the selected pins.
uint32_t PLL2R
PLL2R: Division factor for peripheral clocks.
uint32_t PLL2M
PLL2M: Division factor for PLL2 VCO input clock.
uint32_t PLL2RGE
PLL2RGE: PLL2 clock Input range This parameter must be a value of RCC PLL2 VCI Range.
uint32_t PLL2N
PLL2N: Multiplication factor for PLL2 VCO output clock.
uint32_t PLL2FRACN
PLL2FRACN: Specifies Fractional Part Of The Multiplication Factor for PLL2 VCO It should be a value b...
uint32_t PLL2VCOSEL
PLL2VCOSEL: PLL2 clock Output range This parameter must be a value of RCC PLL2 VCO Range.
uint32_t PLL2P
PLL2P: Division factor for system clock.
uint32_t PLL2Q
PLL2Q: Division factor for peripheral clocks.
RCC extended clocks structure definition.
uint32_t Spi123ClockSelection
Specifies SPI1/2/3 clock source This parameter can be a value of SPI1/2/3 Clock Source.
uint32_t Usart16ClockSelection
Specifies USART1/6 clock source This parameter can be a value of RCCEx USART1/6 Clock Source.
uint64_t PeriphClockSelection
The Extended Clock to be configured.
uint32_t I2c4ClockSelection
Specifies I2C4 clock source This parameter can be a value of RCCEx I2C4 Clock Source.
uint32_t SdmmcClockSelection
Specifies SDMMC clock source This parameter can be a value of RCCEx SDMMC Clock Source.
RCC_PLL2InitTypeDef PLL2
PLL2structure parameters.
uint32_t AdcClockSelection
Specifies ADC interface clock source This parameter can be a value of RCCEx ADC Clock Source.
uint32_t RTCClockSelection
Specifies RTC Clock clock source This parameter can be a value of RCC RTC Clock Source.
uint32_t Spi45ClockSelection
Specifies SPI4/5 clock source This parameter can be a value of SPI4/5 Clock Source.
RTC Handle Structure definition.
TIM Time Base Handle Structure definition.
TIM_TypeDef * Instance
Register base address.
I2C_TypeDef * Instance
I2C registers base address.
SPI_TypeDef * Instance
SPI registers base address.
USART_TypeDef * Instance
UART registers base address.