48 #include "stm32h7xx.h"
51 #if !defined (HSE_VALUE)
52 #define HSE_VALUE ((uint32_t)25000000)
55 #if !defined (CSI_VALUE)
56 #define CSI_VALUE ((uint32_t)4000000)
59 #if !defined (HSI_VALUE)
60 #define HSI_VALUE ((uint32_t)64000000)
87 #define VECT_TAB_OFFSET 0x00000000UL
116 const uint8_t
D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
125 #if defined (DATA_IN_ExtSDRAM)
126 static void SystemInit_ExtMemCtl(
void);
147 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
148 SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2)));
161 RCC->CFGR = 0x00000000;
164 RCC->CR &= 0xEAF6ED7FU;
167 RCC->D1CFGR = 0x00000000;
170 RCC->D2CFGR = 0x00000000;
173 RCC->D3CFGR = 0x00000000;
176 RCC->PLLCKSELR = 0x00000000;
179 RCC->PLLCFGR = 0x00000000;
181 RCC->PLL1DIVR = 0x00000000;
183 RCC->PLL1FRACR = 0x00000000;
186 RCC->PLL2DIVR = 0x00000000;
190 RCC->PLL2FRACR = 0x00000000;
192 RCC->PLL3DIVR = 0x00000000;
195 RCC->PLL3FRACR = 0x00000000;
198 RCC->CR &= 0xFFFBFFFFU;
201 RCC->CIER = 0x00000000;
207 if((
DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U)
211 *((
__IO uint32_t*)0x51008108) = 0x00000001U;
222 #if defined (DATA_IN_ExtSDRAM)
223 SystemInit_ExtMemCtl();
248 #error Please #define CORE_CM4 or CORE_CM7
293 uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp;
294 uint32_t common_system_clock;
295 float_t fracn1, pllvco;
330 pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(
RCC->PLL1DIVR &
RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
335 pllvco = ((float_t)
CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(
RCC->PLL1DIVR &
RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
339 pllvco = ((float_t)
HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(
RCC->PLL1DIVR &
RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
343 pllvco = ((float_t)
CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(
RCC->PLL1DIVR &
RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
347 common_system_clock = (uint32_t)(float_t)(pllvco/(float_t)pllp);
351 common_system_clock = 0U;
364 common_system_clock >>= tmp;
369 #if defined(DUAL_CORE) && defined(CORE_CM4)
375 #if defined (DATA_IN_ExtSDRAM)
384 void SystemInit_ExtMemCtl(
void)
386 __IO uint32_t tmp = 0;
387 register uint32_t tmpreg = 0, timeout = 0xFFFF;
388 register __IO uint32_t index;
392 RCC->AHB4ENR |= 0x000001F8;
398 GPIOD->AFR[0] = 0x000000CC;
399 GPIOD->AFR[1] = 0xCC000CCC;
401 GPIOD->MODER = 0xAFEAFFFA;
403 GPIOD->OSPEEDR = 0xF03F000F;
405 GPIOD->OTYPER = 0x00000000;
407 GPIOD->PUPDR = 0x50150005;
410 GPIOE->AFR[0] = 0xC00000CC;
411 GPIOE->AFR[1] = 0xCCCCCCCC;
413 GPIOE->MODER = 0xAAAABFFA;
415 GPIOE->OSPEEDR = 0xFFFFC00F;
417 GPIOE->OTYPER = 0x00000000;
419 GPIOE->PUPDR = 0x55554005;
422 GPIOF->AFR[0] = 0x00CCCCCC;
423 GPIOF->AFR[1] = 0xCCCCC000;
425 GPIOF->MODER = 0xAABFFAAA;
427 GPIOF->OSPEEDR = 0xFFC00FFF;
429 GPIOF->OTYPER = 0x00000000;
431 GPIOF->PUPDR = 0x55400555;
434 GPIOG->AFR[0] = 0x00CCCCCC;
435 GPIOG->AFR[1] = 0xC000000C;
437 GPIOG->MODER = 0xBFFEFAAA;
439 GPIOG->OSPEEDR = 0xC0030FFF;
441 GPIOG->OTYPER = 0x00000000;
443 GPIOG->PUPDR = 0x40010555;
446 GPIOH->AFR[0] = 0xCCC00000;
447 GPIOH->AFR[1] = 0xCCCCCCCC;
449 GPIOH->MODER = 0xAAAAABFF;
451 GPIOH->OSPEEDR = 0xFFFFFC00;
453 GPIOH->OTYPER = 0x00000000;
455 GPIOH->PUPDR = 0x55555400;
458 GPIOI->AFR[0] = 0xCCCCCCCC;
459 GPIOI->AFR[1] = 0x00000CC0;
461 GPIOI->MODER = 0xFFEBAAAA;
463 GPIOI->OSPEEDR = 0x003CFFFF;
465 GPIOI->OTYPER = 0x00000000;
467 GPIOI->PUPDR = 0x00145555;
500 while((tmpreg != 0) && (timeout-- > 0))
506 for (index = 0; index<1000; index++);
511 while((tmpreg != 0) && (timeout-- > 0))
518 while((tmpreg != 0) && (timeout-- > 0))
525 while((tmpreg != 0) && (timeout-- > 0))