|
28 | 28 | void
|
29 | 29 | __modm_initialize_platform(void)
|
30 | 30 | {
|
| 31 | + |
31 | 32 | // Enable SYSCFG
|
32 |
| -%% if target.family in ["c0", "g0"] |
33 |
| - RCC->APBENR2 |= RCC_APBENR2_SYSCFGEN; __DSB(); |
34 |
| -%% elif target.family == "f0" |
35 |
| - RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN; __DSB(); |
36 |
| -%% elif target.family == "f1" |
37 |
| - RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; __DSB(); |
38 |
| -%% elif target.family == "h7" |
39 |
| - RCC->APB4ENR |= RCC_APB4ENR_SYSCFGEN; __DSB(); |
40 |
| -%% elif target.family == "u5" |
41 |
| - RCC->APB3ENR |= RCC_APB3ENR_SYSCFGEN; __DSB(); |
42 |
| -%% else |
43 |
| - RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; __DSB(); |
44 |
| -%% endif |
| 33 | + {{regs.set("RCC", "APB\d?ENR\d?", "SYSCFG.*?EN|AFIOEN")}} |
45 | 34 |
|
46 | 35 | // Enable power to backup domain
|
47 |
| -%% if target.family == "f1" |
48 |
| - RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN; __DSB(); |
49 |
| -%% elif target.family in ["f0", "f2", "f3", "f4", "f7", "l0", "l1"] |
50 |
| - RCC->APB1ENR |= RCC_APB1ENR_PWREN; __DSB(); |
51 |
| -%% elif target.family in ["c0", "g0", "u0"] |
52 |
| - RCC->APBENR1 |= RCC_APBENR1_PWREN; __DSB(); |
53 |
| -%% elif target.family in ["g4", "l4", "l5"] |
54 |
| - RCC->APB1ENR1 |= RCC_APB1ENR1_PWREN; __DSB(); |
55 |
| -%% elif target.family == "u5" |
56 |
| - RCC->AHB3ENR |= RCC_AHB3ENR_PWREN; __DSB(); |
57 |
| -%% endif |
| 36 | + {{regs.set("RCC", "A[HP]B\d?ENR\d?", "(?:PWR|BKP)EN")}} __DSB(); |
| 37 | + {{regs.set("PWR", ".*?", "DBP")}} |
58 | 38 |
|
59 |
| -%% if target.family in ["f0", "f1", "f2", "f3", "f4", "l0", "l1"] |
60 |
| - PWR->CR |= PWR_CR_DBP; |
61 |
| -%% elif target.family in ["f7", "g0", "g4", "h7", "l4", "l5", "u0", "wb", "wl"] |
62 |
| - PWR->CR1 |= PWR_CR1_DBP; |
63 |
| -%% elif target.family == "h5" |
64 |
| - PWR->DBPCR |= PWR_DBPCR_DBP; |
65 |
| -%% elif target.family in ["u5", "wba"] |
66 |
| - PWR->DBPR |= PWR_DBPR_DBP; |
67 |
| -%% endif |
| 39 | + // Enable internal memories |
| 40 | + {{regs.set("RCC", "A[HP]B\d?ENR\d?", "(?:BKPS?|DTCM|CCMDATA)RAM\d?EN")}} |
68 | 41 |
|
69 |
| -%% if target.family == "f4" |
70 |
| - // Only the more powerful F4 targets have CCM or Backup SRAM |
71 |
| -#ifdef RCC_AHB1ENR_CCMDATARAMEN |
72 |
| - // Enable Core Coupled Memory (CCM) and backup SRAM (BKPSRAM) |
73 |
| - RCC->AHB1ENR |= RCC_AHB1ENR_CCMDATARAMEN | RCC_AHB1ENR_BKPSRAMEN; |
74 |
| -#endif |
75 |
| -%% elif target.family == "f7" |
| 42 | +%% if regs.search("RCC_DCKCFGR2_.*?") |
76 | 43 | // Reset from DFU settings to reset values.
|
77 | 44 | RCC->DCKCFGR2 = 0;
|
78 |
| - // Enable Data Tighly Coupled Memory (DTCM) and backup SRAM (BKPSRAM) |
79 |
| - RCC->AHB1ENR |= RCC_AHB1ENR_DTCMRAMEN | RCC_AHB1ENR_BKPSRAMEN; |
80 |
| -%% elif target.family == "h7" |
81 |
| - // Enable all SRAMs |
82 |
| - %% if target.name[0].isnumeric() |
83 |
| - RCC->AHB2ENR |= RCC_AHB2ENR_SRAM1EN | RCC_AHB2ENR_SRAM2EN; |
84 |
| - %% else |
85 |
| - RCC->AHB2ENR |= RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN; |
86 |
| - %% endif |
87 |
| - RCC->AHB4ENR |= RCC_AHB4ENR_BKPRAMEN; |
88 |
| -%% elif target.family in ["g4", "l4", "l5"] |
89 |
| -#ifdef PWR_CR2_IOSV |
90 |
| - // Enable VDDIO2 |
91 |
| - PWR->CR2 |= PWR_CR2_IOSV; |
92 |
| -#endif |
93 |
| -%% elif target.family == "u5" |
94 |
| - // Enable power for VDDIO2 and USB |
95 |
| - PWR->SVMCR |= PWR_SVMCR_ASV | PWR_SVMCR_IO2SV | PWR_SVMCR_USV; |
96 |
| - // Enable Backup SRAM (BKPSRAM) |
97 |
| - RCC->AHB1ENR |= RCC_AHB1ENR_BKPSRAMEN; |
98 | 45 | %% endif
|
99 | 46 |
|
| 47 | + // Enable VDDIO voltages |
| 48 | + {{regs.set("PWR|RCC", "CR2|SVMCR", ".*?SV")}} |
| 49 | + |
100 | 50 | %% if vector_table_location == "ram"
|
101 | 51 | __DSB();
|
102 | 52 | // Remap SRAM to 0x0 for vector table relocation without VTOR register
|
|
0 commit comments