21#ifndef PERIPH_CPU_COMMON_H
22#define PERIPH_CPU_COMMON_H
37#define STM32_BOOTLOADER_ADDR
45#define CPUID_LEN (12U)
51#define CPUID_ADDR (UID_BASE)
57#if defined(CPU_FAM_STM32F0) || defined (CPU_FAM_STM32F1) || \
58 defined(CPU_FAM_STM32F3)
59#define CLOCK_LSI (40000U)
60#elif defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
61#define CLOCK_LSI (37000U)
62#elif defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) || \
63 defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32L4) || \
64 defined(CPU_FAM_STM32WB) || defined(CPU_FAM_STM32G4) || \
65 defined(CPU_FAM_STM32G0) || defined(CPU_FAM_STM32L5) || \
66 defined(CPU_FAM_STM32U5) || defined(CPU_FAM_STM32MP1) || \
67 defined(CPU_FAM_STM32WL) || defined(CPU_FAM_STM32C0)
68#define CLOCK_LSI (32000U)
70#error "error: LSI clock speed not defined for your target CPU"
74#if defined(CPU_FAM_STM32G4) || \
75 defined(CPU_FAM_STM32L4) || \
76 defined(CPU_FAM_STM32L5) || \
77 defined(CPU_FAM_STM32U5) || \
78 defined(CPU_FAM_STM32WB) || \
79 defined(CPU_FAM_STM32WL)
80 #define APB1_PERIPH_EN RCC->APB1ENR1
81 #define APB12_PERIPH_EN RCC->APB1ENR2
82#elif defined(CPU_FAM_STM32C0) || \
83 defined(CPU_FAM_STM32G0)
84 #define APB1_PERIPH_EN RCC->APBENR1
85 #define APB12_PERIPH_EN RCC->APBENR2
86#elif defined(CPU_FAM_STM32MP1)
87 #define APB1_PERIPH_EN RCC->MC_APB1ENSETR
88 #define APB1_PERIPH_DIS RCC->MC_APB1ENCLRR
89#elif defined(APB1PERIPH_BASE) || \
90 defined(CPU_FAM_STM32F0) || \
91 defined(CPU_FAM_STM32L0)
92 #define APB1_PERIPH_EN RCC->APB1ENR
96#if defined(CPU_FAM_STM32MP1)
97 #define APB2_PERIPH_EN RCC->MC_APB2ENSETR
98 #define APB2_PERIPH_DIS RCC->MC_APB2ENCLRR
99#elif defined(APB2PERIPH_BASE) || \
100 defined(CPU_FAM_STM32F0) || \
101 defined(CPU_FAM_STM32L0)
102 #define APB2_PERIPH_EN RCC->APB2ENR
106#if defined(CPU_FAM_STM32WB)
108 #undef APB3_PERIPH_EN
109#elif defined(APB3PERIPH_BASE) || \
110 defined(APB3PERIPH_BASE_S)
111 #define APB3_PERIPH_EN RCC->APB3ENR
115#if defined(AHBPERIPH_BASE) || \
116 defined(CPU_FAM_STM32F3)
117 #define AHB_PERIPH_EN RCC->AHBENR
118#elif defined(CPU_FAM_STM32MP1)
120 #undef AHB1_PERIPH_EN
121 #undef AHB1_PERIPH_DIS
122#elif defined(AHB1PERIPH_BASE)
123 #define AHB1_PERIPH_EN RCC->AHB1ENR
127#if defined(CPU_FAM_STM32F0) || \
128 defined(CPU_FAM_STM32F3)
130 #undef AHB2_PERIPH_EN
131#elif defined(CPU_FAM_STM32U5)
132 #define AHB2_PERIPH_EN RCC->AHB2ENR1
133 #define AHB22_PERIPH_EN RCC->AHB2ENR2
134#elif defined(CPU_FAM_STM32F4) && defined(RCC_AHB2_SUPPORT)
135 #define AHB2_PERIPH_EN RCC->AHB2ENR
136#elif defined(CPU_FAM_STM32MP1)
137 #define AHB2_PERIPH_EN RCC->MC_AHB2ENSETR
138 #define AHB2_PERIPH_DIS RCC->MC_AHB2ENCLRR
139#elif defined(AHB2PERIPH_BASE)
140 #define AHB2_PERIPH_EN RCC->AHB2ENR
144#if defined(CPU_FAM_STM32F3)
146 #undef AHB3_PERIPH_EN
147#elif defined(CPU_FAM_STM32F4) && defined(RCC_AHB3_SUPPORT)
148 #define AHB3_PERIPH_EN RCC->AHB3ENR
149#elif defined(CPU_FAM_STM32MP1)
150 #define AHB3_PERIPH_EN RCC->MC_AHB3ENSETR
151 #define AHB3_PERIPH_DIS RCC->MC_AHB3ENCLRR
152#elif defined(AHB3PERIPH_BASE) || \
153 defined(AHB3PERIPH_BASE_S) || \
154 defined(CPU_FAM_STM32F2) || \
155 defined(CPU_FAM_STM32F7) || \
156 defined(CPU_FAM_STM32G4) || \
157 defined(CPU_FAM_STM32L4)
158 #define AHB3_PERIPH_EN RCC->AHB3ENR
162#if defined(CPU_FAM_STM32MP1)
163 #define AHB4_PERIPH_EN RCC->MC_AHB4ENSETR
164 #define AHB4_PERIPH_DIS RCC->MC_AHB4ENCLRR
165#elif defined(AHB4PERIPH_BASE)
167 #define AHB4_PERIPH_EN RCC->AHB3ENR
171#if defined(IOPPERIPH_BASE) || \
172 defined(RCC_IOPENR_GPIOAEN) || \
173 defined(RCC_IOPENR_IOPAEN)
174 #define IOP_PERIPH_EN RCC->IOPENR
181#if defined(APB1_PERIPH_EN)
184#if defined(APB12_PERIPH_EN)
187#if defined(APB2_PERIPH_EN)
190#if defined(APB3_PERIPH_EN)
193#if defined(AHB_PERIPH_EN)
196#if defined(AHB1_PERIPH_EN)
199#if defined(AHB2_PERIPH_EN)
202#if defined(AHB22_PERIPH_EN)
205#if defined(AHB3_PERIPH_EN)
208#if defined(AHB4_PERIPH_EN)
211#if defined(IOP_PERIPH_EN)
@ APB1
Advanced Peripheral Bus 1
@ AHB
Advanced High-performance Bus.
@ APB2
Advanced Peripheral Bus 2
uint32_t periph_apb_clk(bus_t bus)
Get the actual bus clock frequency for the APB buses.
void periph_lpclk_en(bus_t bus, uint32_t mask)
Enable the given peripheral clock in low power mode.
void periph_clk_en(bus_t bus, uint32_t mask)
Enable the given peripheral clock.
void periph_clk_dis(bus_t bus, uint32_t mask)
Disable the given peripheral clock.
uint32_t periph_timer_clk(bus_t bus)
Get the actual timer clock frequency.
void periph_lpclk_dis(bus_t bus, uint32_t mask)
Disable the given peripheral clock in low power mode.
bus_t
CPU specific LSI clock speed.
@ BUS_NUMOF
number of buses