Skip to content

Commit c897e04

Browse files
authored
Merge pull request #11384 from jeromecoutant/PR_H747_CM7
ST DISCO-H747I introduction
2 parents 0e04d74 + 535dbe8 commit c897e04

File tree

18 files changed

+34465
-1
lines changed

18 files changed

+34465
-1
lines changed

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_DISCO_H747I/PeripheralPins.c

Lines changed: 563 additions & 0 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_DISCO_H747I/PinNames.h

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/*
2+
******************************************************************************
3+
* @attention
4+
*
5+
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
6+
* All rights reserved.</center></h2>
7+
*
8+
* This software component is licensed by ST under BSD 3-Clause license,
9+
* the "License"; You may not use this file except in compliance with the
10+
* License. You may obtain a copy of the License at:
11+
* opensource.org/licenses/BSD-3-Clause
12+
*
13+
******************************************************************************
14+
*/
15+
16+
/**
17+
* This file configures the system clock as follows:
18+
*--------------------------------------------------------------------
19+
* System clock source | 1- USE_PLL_HSE_EXTC (external 8 MHz clock)
20+
* | 2- USE_PLL_HSE_XTAL (external 8 MHz xtal)
21+
* | 3- USE_PLL_HSI (internal 64 MHz clock)
22+
*--------------------------------------------------------------------
23+
* SYSCLK(MHz) | 400
24+
* AHBCLK (MHz) | 200
25+
* APB1CLK (MHz) | 100
26+
* APB2CLK (MHz) | 100
27+
* APB3CLK (MHz) | 100
28+
* APB4CLK (MHz) | 100
29+
* USB capable (48 MHz) | YES
30+
*--------------------------------------------------------------------
31+
**/
32+
33+
#include "stm32h7xx.h"
34+
#include "nvic_addr.h"
35+
#include "mbed_error.h"
36+
37+
/*!< Uncomment the following line if you need to relocate your vector Table in
38+
Internal SRAM. */
39+
/* #define VECT_TAB_SRAM */
40+
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
41+
This value must be a multiple of 0x200. */
42+
43+
// clock source is selected with CLOCK_SOURCE in json config
44+
#define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO)
45+
#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default)
46+
#define USE_PLL_HSI 0x2 // Use HSI internal clock
47+
48+
#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) )
49+
uint8_t SetSysClock_PLL_HSE(uint8_t bypass);
50+
#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */
51+
52+
#if ((CLOCK_SOURCE) & USE_PLL_HSI)
53+
uint8_t SetSysClock_PLL_HSI(void);
54+
#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */
55+
56+
/**
57+
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
58+
* AHB/APBx prescalers and Flash settings
59+
* @note This function should be called only once the RCC clock configuration
60+
* is reset to the default reset state (done in SystemInit() function).
61+
* @param None
62+
* @retval None
63+
*/
64+
65+
void SetSysClock(void)
66+
{
67+
68+
#if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC)
69+
/* 1- Try to start with HSE and external clock (MCO from STLink PCB part) */
70+
if (SetSysClock_PLL_HSE(1) == 0)
71+
#endif
72+
{
73+
#if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL)
74+
/* 2- If fail try to start with HSE and external xtal */
75+
if (SetSysClock_PLL_HSE(0) == 0)
76+
#endif
77+
{
78+
#if ((CLOCK_SOURCE) & USE_PLL_HSI)
79+
/* 3- If fail start with HSI clock */
80+
if (SetSysClock_PLL_HSI() == 0)
81+
#endif
82+
{
83+
error("SetSysClock failed\n");
84+
}
85+
}
86+
}
87+
}
88+
89+
#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) )
90+
/******************************************************************************/
91+
/* PLL (clocked by HSE) used as System clock source */
92+
/******************************************************************************/
93+
uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
94+
{
95+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
96+
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
97+
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
98+
99+
HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY);
100+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
101+
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
102+
103+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
104+
if (bypass) {
105+
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
106+
} else {
107+
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
108+
}
109+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
110+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
111+
RCC_OscInitStruct.PLL.PLLM = 5; // 5 MHz
112+
RCC_OscInitStruct.PLL.PLLN = 192; // 960 MHz
113+
RCC_OscInitStruct.PLL.PLLP = 2; // PLLCLK = SYSCLK = 480 MHz
114+
RCC_OscInitStruct.PLL.PLLQ = 116; // PLL1Q used for FDCAN = 10 MHz
115+
RCC_OscInitStruct.PLL.PLLR = 2;
116+
RCC_OscInitStruct.PLL.PLLFRACN = 0;
117+
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
118+
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
119+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
120+
return 0; // FAIL
121+
}
122+
123+
/* Select PLL as system clock source and configure bus clocks dividers */
124+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |
125+
RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 |
126+
RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_D3PCLK1;
127+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
128+
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
129+
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
130+
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
131+
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
132+
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
133+
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
134+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
135+
return 0; // FAIL
136+
}
137+
138+
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USART3 | RCC_PERIPHCLK_USB;
139+
PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
140+
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
141+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
142+
return 0; // FAIL
143+
}
144+
145+
__HAL_RCC_CSI_ENABLE() ;
146+
147+
__HAL_RCC_SYSCFG_CLK_ENABLE() ;
148+
149+
HAL_EnableCompensationCell();
150+
151+
return 1; // OK
152+
}
153+
#endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */
154+
155+
#if ((CLOCK_SOURCE) & USE_PLL_HSI)
156+
/******************************************************************************/
157+
/* PLL (clocked by HSI) used as System clock source */
158+
/******************************************************************************/
159+
uint8_t SetSysClock_PLL_HSI(void)
160+
{
161+
RCC_ClkInitTypeDef RCC_ClkInitStruct;
162+
RCC_OscInitTypeDef RCC_OscInitStruct;
163+
164+
/*!< Supply configuration update enable */
165+
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
166+
/* The voltage scaling allows optimizing the power consumption when the device is
167+
clocked below the maximum system frequency, to update the voltage scaling value
168+
regarding system frequency refer to product datasheet. */
169+
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
170+
while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
171+
172+
// Enable HSI oscillator and activate PLL with HSI as source
173+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_CSI;
174+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
175+
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
176+
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
177+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
178+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
179+
RCC_OscInitStruct.PLL.PLLM = 8;
180+
RCC_OscInitStruct.PLL.PLLN = 100;
181+
RCC_OscInitStruct.PLL.PLLP = 2;
182+
RCC_OscInitStruct.PLL.PLLQ = 2;
183+
RCC_OscInitStruct.PLL.PLLR = 2;
184+
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
185+
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
186+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
187+
return 0; // FAIL
188+
}
189+
190+
/* Select PLL as system clock source and configure bus clocks dividers */
191+
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
192+
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
193+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
194+
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
195+
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
196+
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
197+
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
198+
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
199+
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
200+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
201+
return 0; // FAIL
202+
}
203+
204+
return 1; // OK
205+
}
206+
#endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */

0 commit comments

Comments
 (0)