|
1 | 1 | /* |
2 | 2 | * Copyright (c) 2016, Sascha Schade |
3 | 3 | * Copyright (c) 2016-2017, Fabian Greif |
4 | | - * Copyright (c) 2016-2017, 2019, 2024, Niklas Hauser |
| 4 | + * Copyright (c) 2016-2017, 2019, 2024, 2025, Niklas Hauser |
5 | 5 | * Copyright (c) 2021, Raphael Lehmann |
6 | 6 | * Copyright (c) 2021, Christopher Durand |
7 | 7 | * |
|
28 | 28 | void |
29 | 29 | __modm_initialize_platform(void) |
30 | 30 | { |
| 31 | +%% if regs.set("RCC", "APB\d?ENR\d?", "SYSCFG.*?EN|AFIOEN") |
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(); |
| 33 | + {{regs.result}} |
44 | 34 | %% endif |
45 | | - |
| 35 | +%% if regs.set("RCC", "A[HP]B\d?ENR\d?", "(?:PWR|BKP)EN") |
46 | 36 | // 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(); |
| 37 | + {{regs.result}} __DSB(); |
57 | 38 | %% endif |
58 | | - |
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; |
| 39 | +%% if regs.set("PWR", ".*?", "DBP") |
| 40 | + // Enable access to backup domain |
| 41 | + {{regs.result}} |
67 | 42 | %% endif |
68 | | - |
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" |
| 43 | +%% if regs.set("RCC", "A[HP]B\d?ENR\d?", "(?:BKPS?|DTCM|CCMDATA)RAM\d?EN") |
| 44 | + // Enable internal memories |
| 45 | + {{regs.result}} |
| 46 | +%% endif |
| 47 | +%% if regs.set("PWR|RCC", "CR2|SVMCR", ".*?SV") |
| 48 | + // Enable VDDIO voltages |
| 49 | + {{regs.result}} |
| 50 | +%% endif |
| 51 | +%% if regs.search("RCC_DCKCFGR2_.*?") |
76 | 52 | // Reset from DFU settings to reset values. |
77 | 53 | 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 | 54 | %% endif |
99 | | - |
100 | 55 | %% if vector_table_location == "ram" |
101 | 56 | __DSB(); |
102 | 57 | // Remap SRAM to 0x0 for vector table relocation without VTOR register |
|
0 commit comments