libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
h7/rcc.h
Go to the documentation of this file.
1/** @defgroup rcc_defines RCC Defines
2@brief <b>Defined Constants and Types for the STM32H7xx Reset and Clock
3Control</b>
4@ingroup STM32H7xx_defines
5@version 1.0.0
6LGPL License Terms @ref lgpl_license
7 */
8/*
9 * This file is part of the libopencm3 project.
10 *
11 * Copyright (C) 2019 Brian Viele <vielster@allocor.tech>
12 *
13 * This library is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library. If not, see <http://www.gnu.org/licenses/>.
25 */
26
27#ifndef LIBOPENCM3_RCC_H
28#define LIBOPENCM3_RCC_H
29
32
33/**@{*/
34
35/** @defgroup rcc_registers RCC Registers
36@{*/
37#define RCC_CR MMIO32(RCC_BASE + 0x000)
38#define RCC_ICSCR MMIO32(RCC_BASE + 0x004) /* Y-devices only */
39#define RCC_HSICFGR MMIO32(RCC_BASE + 0x004) /* V-devices only */
40#define RCC_CRRCR MMIO32(RCC_BASE + 0x008)
41#define RCC_CSICFGR MMIO32(RCC_BASE + 0x00C) /* V-devices only */
42#define RCC_CFGR MMIO32(RCC_BASE + 0x010)
43#define RCC_D1CFGR MMIO32(RCC_BASE + 0x018)
44#define RCC_D2CFGR MMIO32(RCC_BASE + 0x01C)
45#define RCC_D3CFGR MMIO32(RCC_BASE + 0x020)
46#define RCC_PLLCKSELR MMIO32(RCC_BASE + 0x028)
47#define RCC_PLLCFGR MMIO32(RCC_BASE + 0x02C)
48/* PLLs are 1-based, so reference macros to 1..3, using index 0 will give undefined behavior. */
49#define RCC_PLLDIVR(n) MMIO32(RCC_BASE + 0x030 + (0x08 * ((n) - 1)))
50#define RCC_PLLFRACR(n) MMIO32(RCC_BASE + 0x030 + (0x08 * ((n) - 1)))
51#define RCC_PLL1DIVR RCC_PLLDIVR(1)
52#define RCC_PLL1FRACR RCC_PLLFRACR(1)
53#define RCC_PLL2DIVR RCC_PLLDIVR(2)
54#define RCC_PLL2FRACR RCC_PLLFRACR(2)
55#define RCC_PLL3DIVR RCC_PLLDIVR(3)
56#define RCC_PLL3FRACR RCC_PLLFRACR(3)
57#define RCC_D1CCIPR MMIO32(RCC_BASE + 0x04C)
58#define RCC_D2CCIP1R MMIO32(RCC_BASE + 0x050)
59#define RCC_D2CCIP2R MMIO32(RCC_BASE + 0x054)
60#define RCC_D3CCIPR MMIO32(RCC_BASE + 0x058)
61#define RCC_AHB1RSTR MMIO32(RCC_BASE + 0x080)
62#define RCC_AHB2RSTR MMIO32(RCC_BASE + 0x084)
63#define RCC_AHB3RSTR MMIO32(RCC_BASE + 0x07C)
64#define RCC_AHB4RSTR MMIO32(RCC_BASE + 0x088)
65#define RCC_APB1LRSTR MMIO32(RCC_BASE + 0x090)
66#define RCC_APB1HRSTR MMIO32(RCC_BASE + 0x094)
67#define RCC_APB2RSTR MMIO32(RCC_BASE + 0x098)
68#define RCC_APB3RSTR MMIO32(RCC_BASE + 0x08C)
69#define RCC_APB4RSTR MMIO32(RCC_BASE + 0x09C)
70#define RCC_AHB1ENR MMIO32(RCC_BASE + 0x0D8)
71#define RCC_AHB2ENR MMIO32(RCC_BASE + 0x0DC)
72#define RCC_AHB3ENR MMIO32(RCC_BASE + 0x0D4)
73#define RCC_AHB4ENR MMIO32(RCC_BASE + 0x0E0)
74#define RCC_APB1LENR MMIO32(RCC_BASE + 0x0E8)
75#define RCC_APB1HENR MMIO32(RCC_BASE + 0x0EC)
76#define RCC_APB2ENR MMIO32(RCC_BASE + 0x0F0)
77#define RCC_APB3ENR MMIO32(RCC_BASE + 0x0E4)
78#define RCC_APB4ENR MMIO32(RCC_BASE + 0x0F4)
79#define RCC_AHB1LPENR MMIO32(RCC_BASE + 0x100)
80#define RCC_AHB2LPENR MMIO32(RCC_BASE + 0x104)
81#define RCC_AHB4LPENR MMIO32(RCC_BASE + 0x108)
82#define RCC_APB1LLPENR MMIO32(RCC_BASE + 0x110)
83#define RCC_APB1HLPENR MMIO32(RCC_BASE + 0x114)
84#define RCC_APB2LPENR MMIO32(RCC_BASE + 0x118)
85#define RCC_APB3LPENR MMIO32(RCC_BASE + 0x10C)
86#define RCC_APB4LPENR MMIO32(RCC_BASE + 0x11C)
87#define RCC_BDCR MMIO32(RCC_BASE + 0x70)
88#define RCC_CSR MMIO32(RCC_BASE + 0x74)
89#define RCC_SSCGR MMIO32(RCC_BASE + 0x80)
90#define RCC_PLLI2SCFGR MMIO32(RCC_BASE + 0x84)
91#define RCC_PLLSAICFGR MMIO32(RCC_BASE + 0x88)
92#define RCC_DCKCFGR1 MMIO32(RCC_BASE + 0x8C)
93#define RCC_DCKCFGR2 MMIO32(RCC_BASE + 0x90)
94/**@}*/
95
96/** @defgroup rcc_cr_values RCC_CR Values
97 * @ingroup rcc_registers
98@{*/
99#define RCC_CR_PLL3RDY BIT29
100#define RCC_CR_PLL3ON BIT28
101#define RCC_CR_PLL2RDY BIT27
102#define RCC_CR_PLL2ON BIT26
103#define RCC_CR_PLL1RDY BIT25
104#define RCC_CR_PLL1ON BIT24
105#define RCC_CR_HSECSSON BIT19
106#define RCC_CR_HSEBYP BIT18
107#define RCC_CR_HSERDY BIT17
108#define RCC_CR_HSEON BIT16
109#define RCC_CR_D2CKRDY BIT15
110#define RCC_CR_D1CKRDY BIT14
111#define RCC_CR_HSI48RDY BIT13
112#define RCC_CR_HSI48ON BIT12
113#define RCC_CR_CSIKERON BIT9
114#define RCC_CR_CSIRDY BIT8
115#define RCC_CR_CSION BIT7
116#define RCC_CR_HSIDIVF BIT5
117#define RCC_CR_HSIDIV_MASK (0x03)
118#define RCC_CR_HSIDIV_SHIFT 3
119#define RCC_CR_HSIDIV(n) (((n) & RCC_CR_HSIDIV_MASK) << RCC_CR_HSIDIV_MASK)
120#define RCC_CR_HSIRDY BIT2
121#define RCC_CR_HSIKERON BIT1
122#define RCC_CR_HSION BIT0
123/**@}*/
124
125
126/** @defgroup rcc_cfgr_values RCC_CFGR Values
127 * @ingroup rcc_registers
128@{*/
129/* MCO2: Microcontroller clock output 2 */
130#define RCC_CFGR_MCO2_MASK 0x7
131#define RCC_CFGR_MCO2_SHIFT 29
132#define RCC_CFGR_MCO2_SYSCLK 0x0
133#define RCC_CFGR_MCO2_PLL2 0x1
134#define RCC_CFGR_MCO2_HSE 0x2
135#define RCC_CFGR_MCO2_PLL1 0x3
136#define RCC_CFGR_MCO2_CSI 0x4
137#define RCC_CFGR_MCO2_LSI 0x5
138
139/* MCO1/2PRE: MCO Prescalers */
140#define RCC_CFGR_MCOPRE_MASK 0xf
141#define RCC_CFGR_MCO2PRE_SHIFT 25
142#define RCC_CFGR_MCO1PRE_SHIFT 18
143#define RCC_CFGR_MCOPRE_DIV_NONE 0x0
144#define RCC_CFGR_MCOPRE_DIV_BYP 0x1
145#define RCC_CFGR_MCOPRE_DIV_2 0x2
146#define RCC_CFGR_MCOPRE_DIV_3 0x3
147#define RCC_CFGR_MCOPRE_DIV_4 0x4
148/* Note: MCOPRE_DIV can go from 1 - 15 */
149
150/* MCO1: Microcontroller clock output 1 */
151#define RCC_CFGR_MCO1_MASK 0x7
152#define RCC_CFGR_MCO1_SHIFT 22
153#define RCC_CFGR_MCO1_HSI 0x0
154#define RCC_CFGR_MCO1_LSE 0x1
155#define RCC_CFGR_MCO1_HSE 0x2
156#define RCC_CFGR_MCO1_PLL1 0x3
157#define RCC_CFGR_MCO1_HSI48 0x4
158#define RCC_CFGR_MCO_SHIFT RCC_CFGR_MCO1_SHIFT
159#define RCC_CFGR_MCO_MASK RCC_CFGR_MCO1_MASK
160
161/* RTCPRE: HSE division factor for RTC clock */
162#define RCC_CFGR_RTCPRE_SHIFT 8
163#define RCC_CFGR_RTCPRE_MASK 0x3f
164
165/* SWS: System clock switch status */
166#define RCC_CFGR_SWS_SHIFT 3
167#define RCC_CFGR_SWS_MASK 0x7
168#define RCC_CFGR_SWS_HSI 0x0
169#define RCC_CFGR_SWS_CSI 0x1
170#define RCC_CFGR_SWS_HSE 0x2
171#define RCC_CFGR_SWS_PLL1 0x3
172
173/* SW: System clock switch */
174#define RCC_CFGR_SW_SHIFT 0
175#define RCC_CFGR_SW_MASK 0x7
176#define RCC_CFGR_SW_HSI 0x0
177#define RCC_CFGR_SW_CSI 0x1
178#define RCC_CFGR_SW_HSE 0x2
179#define RCC_CFGR_SW_PLL1 0x3
180/**@}*/
181
182/** @defgroup rcc_d1cfgr_values RCC_D1CFGR Values
183 * @ingroup rcc_registers
184 * @{*/
185#define RCC_D1CFGR_D1CPRE_BYP 0x0
186#define RCC_D1CFGR_D1CPRE_DIV2 0x8
187#define RCC_D1CFGR_D1CPRE_DIV4 0x9
188#define RCC_D1CFGR_D1CPRE_DIV8 0xA
189#define RCC_D1CFGR_D1CPRE_DIV16 0xB
190#define RCC_D1CFGR_D1CPRE_DIV64 0xC
191#define RCC_D1CFGR_D1CPRE_DIV128 0xD
192#define RCC_D1CFGR_D1CPRE_DIV256 0xE
193#define RCC_D1CFGR_D1CPRE_DIV512 0xF
194#define RCC_D1CFGR_D1PPRE_BYP 0x0
195#define RCC_D1CFGR_D1PPRE_DIV2 0x4
196#define RCC_D1CFGR_D1PPRE_DIV4 0x5
197#define RCC_D1CFGR_D1PPRE_DIV8 0x6
198#define RCC_D1CFGR_D1PPRE_DIV16 0x7
199#define RCC_D1CFGR_D1HPRE_BYP 0x0
200#define RCC_D1CFGR_D1HPRE_DIV2 0x8
201#define RCC_D1CFGR_D1HPRE_DIV4 0x9
202#define RCC_D1CFGR_D1HPRE_DIV8 0xA
203#define RCC_D1CFGR_D1HPRE_DIV16 0xB
204#define RCC_D1CFGR_D1HPRE_DIV64 0xC
205#define RCC_D1CFGR_D1HPRE_DIV128 0xD
206#define RCC_D1CFGR_D1HPRE_DIV256 0xE
207#define RCC_D1CFGR_D1HPRE_DIV512 0xF
208
209#define RCC_D1CFGR_D1CPRE_SHIFT 8
210#define RCC_D1CFGR_D1PPRE_SHIFT 4
211#define RCC_D1CFGR_D1CPRE(cpre) (cpre << RCC_D1CFGR_D1CPRE_SHIFT)
212#define RCC_D1CFGR_D1PPRE(ppre) (ppre << RCC_D1CFGR_D1PPRE_SHIFT)
213#define RCC_D1CFGR_D1HPRE(hpre) (hpre)
214/**@}*/
215
216/** @defgroup rcc_d2cfgr_values RCC_D2CFGR Values
217 * @ingroup rcc_registers
218 * @{*/
219#define RCC_D2CFGR_D2PPRE_BYP 0x0
220#define RCC_D2CFGR_D2PPRE_DIV2 0x4
221#define RCC_D2CFGR_D2PPRE_DIV4 0x5
222#define RCC_D2CFGR_D2PPRE_DIV8 0x6
223#define RCC_D2CFGR_D2PPRE_DIV16 0x7
224
225#define RCC_D2CFGR_D2PPRE2_SHIFT 8
226#define RCC_D2CFGR_D2PPRE1_SHIFT 4
227#define RCC_D2CFGR_D2PPRE2(ppre) (ppre << RCC_D2CFGR_D2PPRE2_SHIFT)
228#define RCC_D2CFGR_D2PPRE1(ppre) (ppre << RCC_D2CFGR_D2PPRE1_SHIFT)
229/**@}*/
230
231/** @defgroup rcc_d3cfgr_values RCC_D3CFGR Values
232 * @ingroup rcc_registers
233 * @{*/
234#define RCC_D3CFGR_D3PPRE_BYP 0x0
235#define RCC_D3CFGR_D3PPRE_DIV2 0x4
236#define RCC_D3CFGR_D3PPRE_DIV4 0x5
237#define RCC_D3CFGR_D3PPRE_DIV8 0x6
238#define RCC_D3CFGR_D3PPRE_DIV16 0x7
239#define RCC_D3CFGR_D3PPRE_SHIFT 4
240#define RCC_D3CFGR_D3PPRE(ppre) (ppre << RCC_D3CFGR_D3PPRE_SHIFT)
241/**@}*/
242
243/** @defgroup rcc_pllckselr_values RCC_PLLCKSELR Values
244 * @ingroup rcc_registers
245 * @{*/
246#define RCC_PLLCKSELR_PLLSRC_HSI 0x0
247#define RCC_PLLCKSELR_PLLSRC_CSI 0x1
248#define RCC_PLLCKSELR_PLLSRC_HSE 0x2
249#define RCC_PLLCKSELR_PLLSRC_NONE 0x3
250#define RCC_PLLCKSELR_DIVM_DIS 0
251#define RCC_PLLCKSELR_DIVM_BYP 1
252#define RCC_PLLCKSELR_DIVM_MASK 0x3f
253
254#define RCC_PLLCKSELR_DIVM3_SHIFT 20
255#define RCC_PLLCKSELR_DIVM2_SHIFT 12
256#define RCC_PLLCKSELR_DIVM1_SHIFT 4
257
258#define RCC_PLLCKSELR_DIVM3(n) ((n) << RCC_PLLCKSELR_DIVM3_SHIFT)
259#define RCC_PLLCKSELR_DIVM2(n) ((n) << RCC_PLLCKSELR_DIVM2_SHIFT)
260#define RCC_PLLCKSELR_DIVM1(n) ((n) << RCC_PLLCKSELR_DIVM1_SHIFT)
261/**@}*/
262
263/** @defgroup rcc_pllcfgr_values RCC_PLLCFGR Values
264 * @ingroup rcc_registers
265 * @{*/
266#define RCC_PLLCFGR_PLLRGE_1_2MHZ 0
267#define RCC_PLLCFGR_PLLRGE_2_4MHZ 1
268#define RCC_PLLCFGR_PLLRGE_4_8MHZ 2
269#define RCC_PLLCFGR_PLLRGE_8_16MHZ 3
270
271#define RCC_PLLCFGR_DIVR3EN BIT24
272#define RCC_PLLCFGR_DIVQ3EN BIT23
273#define RCC_PLLCFGR_DIVP3EN BIT22
274#define RCC_PLLCFGR_DIVR2EN BIT21
275#define RCC_PLLCFGR_DIVQ2EN BIT20
276#define RCC_PLLCFGR_DIVP2EN BIT19
277#define RCC_PLLCFGR_DIVR1EN BIT18
278#define RCC_PLLCFGR_DIVQ1EN BIT17
279#define RCC_PLLCFGR_DIVP1EN BIT16
280#define RCC_PLLCFGR_PLL3RGE_SHIFT 10
281#define RCC_PLLCFGR_PLL3VCO_WIDE 0 /* 192 - 836MHz base output. */
282#define RCC_PLLCFGR_PLL3VCO_MED BIT9 /* 150 - 420MHz base output. */
283#define RCC_PLLCFGR_PLL3FRACEN BIT8
284#define RCC_PLLCFGR_PLL2RGE_SHIFT 6
285#define RCC_PLLCFGR_PLL2VCO_WIDE 0 /* 192 - 836MHz base output. */
286#define RCC_PLLCFGR_PLL2VCO_MED BIT5 /* 150 - 420MHz base output. */
287#define RCC_PLLCFGR_PLL2FRACEN BIT4
288#define RCC_PLLCFGR_PLL1RGE_SHIFT 2
289#define RCC_PLLCFGR_PLL1VCO_WIDE 0 /* 192 - 836MHz base output. */
290#define RCC_PLLCFGR_PLL1VCO_MED BIT1 /* 150 - 420MHz base output. */
291#define RCC_PLLCFGR_PLL1FRACEN BIT0
292/**@}*/
293
294/** @defgroup rcc_plldivr_values RCC_PLLnDIVR Values
295 * @ingroup rcc_registers
296 * @{*/
297#define RCC_PLLNDIVR_DIVR_SHIFT 24
298#define RCC_PLLNDIVR_DIVQ_SHIFT 16
299#define RCC_PLLNDIVR_DIVP_SHIFT 9
300#define RCC_PLLNDIVR_DIVN_SHIFT 0
301
302/* Need to preserve reserved bits, so give easy mask shortcut. */
303#define RCC_PLLNDIVR_DIVR(n) (((n) - 1) << RCC_PLLNDIVR_DIVR_SHIFT)
304#define RCC_PLLNDIVR_DIVQ(n) (((n) - 1) << RCC_PLLNDIVR_DIVQ_SHIFT)
305#define RCC_PLLNDIVR_DIVP(n) (((n) - 1) << RCC_PLLNDIVR_DIVP_SHIFT)
306#define RCC_PLLNDIVR_DIVN(n) (((n) - 1) << RCC_PLLNDIVR_DIVN_SHIFT)
307/**@}*/
308
309/** @defgroup rcc_bdcr_values RCC_BDCR Values
310 * @ingroup rcc_registers
311@{*/
312#define RCC_BDCR_BDRST (1 << 16)
313#define RCC_BDCR_RTCEN (1 << 15)
314#define RCC_BDCR_RTCSEL_MASK 0x3
315#define RCC_BDCR_RTCSEL_SHIFT 8
316#define RCC_BDCR_RTCSEL_NONE 0
317#define RCC_BDCR_RTCSEL_LSE 1
318#define RCC_BDCR_RTCSEL_LSI 2
319#define RCC_BDCR_RTCSEL_HSE 3
320#define RCC_BDCR_LSEDRV_MASK 0x3
321#define RCC_BDCR_LSEDRV_SHIFT 3
322#define RCC_BDCR_LSEDRV_LOW 0
323#define RCC_BDCR_LSEDRV_MEDH 1 /* good job st */
324#define RCC_BDCR_LSEDRV_MEDL 2
325#define RCC_BDCR_LSEDRV_HIGH 3
326#define RCC_BDCR_LSEBYP (1 << 2)
327#define RCC_BDCR_LSERDY (1 << 1)
328#define RCC_BDCR_LSEON (1 << 0)
329/**@}*/
330
331/** @defgroup rcc_csr_values RCC_CSR Values.
332 * @ingroup rcc_registers
333@{*/
334#define RCC_CSR_LSIRDY (1 << 1)
335#define RCC_CSR_LSION (1 << 0)
336/**@}*/
337
338/** @defgroup rcc_d1ccipr_values RCC_D1CCIP1R Values
339 * @ingroup rcc_registers
340 * @{*/
341#define RCC_D1CCIPR_CKPERSEL_HSI 0
342#define RCC_D1CCIPR_CKPERSEL_CSI 1
343#define RCC_D1CCIPR_CKPERSEL_HSE 2
344#define RCC_D1CCIPR_CKPERSEL_DISABLE 3
345/**@}*/
346#define RCC_D1CCIPR_CKPERSEL_SHIFT 28
347#define RCC_D1CCIPR_CKPERSEL_MASK 3
348
349#define RCC_D2CCIP1R_SWPSEL_SHIFT 31
350#define RCC_D2CCIP1R_FDCANSEL_SHIFT 28
351#define RCC_D2CCIP1R_FDCANSEL_MASK 0x3
352#define RCC_D2CCIP1R_DFSDM1SEL_SHIFT 24
353#define RCC_D2CCIP1R_SPDIFSEL_SHIFT 20
354#define RCC_D2CCIP1R_SPI45SEL_SHIFT 16
355#define RCC_D2CCIP1R_SPI45SEL_MASK 0x7
356#define RCC_D2CCIP1R_SPI123SEL_SHIFT 12
357#define RCC_D2CCIP1R_SPI123SEL_MASK 0x7
358#define RCC_D2CCIP1R_SAI23SEL_SHIFT 6
359#define RCC_D2CCIP1R_SAISEL_MASK 0x7
360
361/** @defgroup rcc_d2ccip1r_values RCC_D2CCIP1R Values
362 * @ingroup rcc_registers
363 * @{*/
364#define RCC_D2CCIP1R_SWPSEL_PCLK 0x0
365#define RCC_D2CCIP1R_SWPSEL_HSI 0x1
366#define RCC_D2CCIP1R_FDCANSEL_HSE 0x0
367#define RCC_D2CCIP1R_FDCANSEL_PLL1Q 0x1
368#define RCC_D2CCIP1R_FDCANSEL_PLL2Q 0x2
369#define RCC_D2CCIP1R_DFSDM1SEL_PCLK2 0x0
370#define RCC_D2CCIP1R_DFSDM1SEL_SYSCLK 0x1
371#define RCC_D2CCIP1R_SPDIFSEL_PLL1Q 0x0
372#define RCC_D2CCIP1R_SPDIFSEL_PLL2R 0x1
373#define RCC_D2CCIP1R_SPDIFSEL_PLL3R 0x2
374#define RCC_D2CCIP1R_SPDIFSEL_HSI 0x3
375#define RCC_D2CCIP1R_SPI45SEL_APB4 0x0
376#define RCC_D2CCIP1R_SPI45SEL_PLL2Q 0x1
377#define RCC_D2CCIP1R_SPI45SEL_PLL3Q 0x2
378#define RCC_D2CCIP1R_SPI45SEL_HSI 0x3
379#define RCC_D2CCIP1R_SPI45SEL_CSI 0x4
380#define RCC_D2CCIP1R_SPI45SEL_HSE 0x5
381#define RCC_D2CCIP1R_SPI123SEL_PLL1Q 0x0
382#define RCC_D2CCIP1R_SPI123SEL_PLL2P 0x1
383#define RCC_D2CCIP1R_SPI123SEL_PLL3P 0x2
384#define RCC_D2CCIP1R_SPI123SEL_I2SCKIN 0x3
385#define RCC_D2CCIP1R_SPI123SEL_PERCK 0x4
386#define RCC_D2CCIP1R_SAISEL_PLL1Q 0x0
387#define RCC_D2CCIP1R_SAISEL_PLL2P 0x1
388#define RCC_D2CCIP1R_SAISEL_PLL3P 0x2
389#define RCC_D2CCIP1R_SAISEL_I2SCKIN 0x3
390#define RCC_D2CCIP1R_SAISEL_PERCK 0x4
391/**@}*/
392
393#define RCC_D2CCIP2R_LPTIM1SEL_SHIFT 28
394#define RCC_D2CCIP2R_CECSEL_SHIFT 22
395#define RCC_D2CCIP2R_USBSEL_SHIFT 20
396#define RCC_D2CCIP2R_I2C123SEL_SHIFT 12
397#define RCC_D2CCIP2R_RNGSEL_MASK 0x3
398#define RCC_D2CCIP2R_RNGSEL_SHIFT 8
399#define RCC_D2CCIP2R_USART16SEL_SHIFT 3
400#define RCC_D2CCIP2R_USART234578SEL_SHIFT 0
401#define RCC_D2CCIP2R_USARTSEL_MASK 7
402
403/** @defgroup rcc_d2ccip2r_values RCC_D2CCIP2R Values
404 * @ingroup rcc_registers
405 * @{*/
406#define RCC_D2CCIP2R_RNGSEL_HSI48 0
407#define RCC_D2CCIP2R_RNGSEL_PLL1Q 1
408#define RCC_D2CCIP2R_RNGSEL_LSE 2
409#define RCC_D2CCIP2R_RNGSEL_LSI 3
410#define RCC_D2CCIP2R_USART16SEL_PCLK2 0
411#define RCC_D2CCIP2R_USART234578SEL_PCLK1 0
412#define RCC_D2CCIP2R_USARTSEL_PCLK 0
413#define RCC_D2CCIP2R_USARTSEL_PLL2Q 1
414#define RCC_D2CCIP2R_USARTSEL_PLL3Q 2
415#define RCC_D2CCIP2R_USARTSEL_HSI 3
416#define RCC_D2CCIP2R_USARTSEL_CSI 4
417#define RCC_D2CCIP2R_USARTSEL_LSE 5
418/**@}*/
419
420
421#define RCC_HSI_BASE_FREQUENCY 64000000UL
422
423/** Enumerations for core system/bus clocks for user/driver/system access to base bus clocks
424 * not directly associated with a peripheral. */
431 RCC_AHBCLK, /* AHB1,2,4 all share base HCLK. */
432 RCC_APB1CLK, /* Note: APB1 and PCLK1 in manual */
433 RCC_APB2CLK, /* Note: APB2 and PCLK2 in manual */
434 RCC_APB3CLK, /* Note: APB3 and PCLK3 in manual */
435 RCC_APB4CLK, /* Note: APB4 and PCLK4 in manual */
436};
437
443 RCC_LSI
445
446/** PLL Configuration structure. */
448 enum rcc_osc sysclock_source; /**< SYSCLK source input selection. */
449 uint8_t pll_source; /**< RCC_PLLCKSELR_PLLSRC_xxx value. */
450 uint32_t hse_frequency; /**< User specified HSE frequency, 0 if none. */
451 struct pll_config {
452 uint8_t divm; /**< Pre-divider value for each PLL. 0-64 integers. */
453 uint16_t divn; /**< Multiplier, 0-512 integer. */
454 uint8_t divp; /**< Post divider for PLLP clock. */
455 uint8_t divq; /**< Post divider for PLLQ clock. */
456 uint8_t divr; /**< Post divider for PLLR clock. */
457 } pll1, pll2, pll3; /**< PLL1-PLL3 configurations. */
458 uint8_t core_pre; /**< Core prescaler note: domain 1. */
459 uint8_t hpre; /**< HCLK3 prescaler note: domain 1. */
460 uint8_t ppre1; /**< APB1 Peripheral prescaler note: domain 2. */
461 uint8_t ppre2; /**< APB2 Peripheral prescaler note: domain 2. */
462 uint8_t ppre3; /**< APB3 Peripheral prescaler note: domain 1. */
463 uint8_t ppre4; /**< APB4 Peripheral prescaler note: domain 3. */
464 uint8_t flash_waitstates; /**< Latency Value to set for flahs. */
465 enum pwr_vos_scale voltage_scale; /**< LDO/SMPS Voltage scale used for this frequency. */
466 enum pwr_sys_mode power_mode; /**< LDO/SMPS configuration for device. */
467 uint8_t smps_level; /**< If using SMPS, voltage level to set. */
468};
469
470#define _REG_BIT(base, bit) (((base) << 5) + (bit))
471
473 /* AHB1 peripherals */
474 RCC_DMA1 = _REG_BIT(0xD8, 0),
475 RCC_DMA2 = _REG_BIT(0xD8, 1),
476 RCC_ADC12 = _REG_BIT(0xD8, 5),
478 RCC_ETH1TX = _REG_BIT(0xD8, 16),
479 RCC_ETH1RX = _REG_BIT(0xD8, 17),
484
485 /* AHB2 peripherals */
486 RCC_DCMI = _REG_BIT(0xDC, 0),
487 RCC_CRYP = _REG_BIT(0xDC, 4),
488 RCC_HASH = _REG_BIT(0xDC, 5),
489 RCC_RNG = _REG_BIT(0xDC, 6),
491 RCC_SRAM1 = _REG_BIT(0xDC, 29),
492 RCC_SRAM2 = _REG_BIT(0xDC, 30),
493 RCC_SRAM3 = _REG_BIT(0xDC, 31),
494
495 /* AHB3 peripherals */
496 RCC_MDMA = _REG_BIT(0xD4, 0),
497 RCC_DMA2D = _REG_BIT(0xD4, 4),
499 RCC_FMC = _REG_BIT(0xD4, 12),
500 RCC_QSPI = _REG_BIT(0xD4, 14),
501 RCC_SDMMC1 = _REG_BIT(0xD4, 16),
502
503 /* AHB4 peripherals*/
504 RCC_GPIOA = _REG_BIT(0xE0, 0),
505 RCC_GPIOB = _REG_BIT(0xE0, 1),
506 RCC_GPIOC = _REG_BIT(0xE0, 2),
507 RCC_GPIOD = _REG_BIT(0xE0, 3),
508 RCC_GPIOE = _REG_BIT(0xE0, 4),
509 RCC_GPIOF = _REG_BIT(0xE0, 5),
510 RCC_GPIOG = _REG_BIT(0xE0, 6),
511 RCC_GPIOH = _REG_BIT(0xE0, 7),
512 RCC_GPIOI = _REG_BIT(0xE0, 8),
513 RCC_GPIOJ = _REG_BIT(0xE0, 9),
514 RCC_GPIOK = _REG_BIT(0xE0, 10),
515 RCC_CRC = _REG_BIT(0xE0, 19),
516 RCC_BDMA = _REG_BIT(0xE0, 21),
517 RCC_ADC3 = _REG_BIT(0xE0, 24),
518 RCC_HSEM = _REG_BIT(0xE0, 25),
520
521 /* APB1L peripherals*/
522 RCC_TIM2 = _REG_BIT(0xE8, 0),
523 RCC_TIM3 = _REG_BIT(0xE8, 1),
524 RCC_TIM4 = _REG_BIT(0xE8, 2),
525 RCC_TIM5 = _REG_BIT(0xE8, 3),
526 RCC_TIM6 = _REG_BIT(0xE8, 4),
527 RCC_TIM7 = _REG_BIT(0xE8, 5),
528 RCC_TIM12 = _REG_BIT(0xE8, 6),
529 RCC_TIM13 = _REG_BIT(0xE8, 7),
530 RCC_TIM14 = _REG_BIT(0xE8, 8),
532 RCC_SPI2 = _REG_BIT(0xE8, 14),
533 RCC_SPI3 = _REG_BIT(0xE8, 15),
535 RCC_USART2 = _REG_BIT(0xE8, 17),
536 RCC_USART3 = _REG_BIT(0xE8, 18),
537 RCC_UART4 = _REG_BIT(0xE8, 19),
538 RCC_UART5 = _REG_BIT(0xE8, 20),
539 RCC_I2C1 = _REG_BIT(0xE8, 21),
540 RCC_I2C2 = _REG_BIT(0xE8, 22),
541 RCC_I2C3 = _REG_BIT(0xE8, 23),
542 RCC_CEC = _REG_BIT(0xE8, 27),
543 RCC_DAC = _REG_BIT(0xE8, 29),
544 RCC_UART7 = _REG_BIT(0xE8, 30),
545 RCC_UART8 = _REG_BIT(0xE8, 31),
546
547 /* APB1H peripherals*/
548 RCC_CRS = _REG_BIT(0xEC, 1),
549 RCC_SWP = _REG_BIT(0xEC, 2),
550 RCC_OPAMP = _REG_BIT(0xEC, 4),
551 RCC_MDIO = _REG_BIT(0xEC, 5),
552 RCC_FDCAN = _REG_BIT(0xEC, 8),
553
554 /* APB2 peripherals */
555 RCC_TIM1 = _REG_BIT(0xF0, 0),
556 RCC_TIM8 = _REG_BIT(0xF0, 1),
559 RCC_SPI1 = _REG_BIT(0xF0, 12),
560 RCC_SPI4 = _REG_BIT(0xF0, 13),
561 RCC_TIM15 = _REG_BIT(0xF0, 16),
562 RCC_TIM16 = _REG_BIT(0xF0, 17),
563 RCC_TIM17 = _REG_BIT(0xF0, 18),
564 RCC_SPI5 = _REG_BIT(0xF0, 20),
565 RCC_SAI1 = _REG_BIT(0xF0, 22),
566 RCC_SAI2 = _REG_BIT(0xF0, 23),
567 RCC_SAI3 = _REG_BIT(0xF0, 24),
568 RCC_DFSDM = _REG_BIT(0xF0, 28),
569 RCC_HRTIM = _REG_BIT(0xF0, 29),
570
571 /* APB3 peripherals */
574
575 /* APB4 peripherals */
578 RCC_SPI6 = _REG_BIT(0xF4, 5),
579 RCC_I2C4 = _REG_BIT(0xF4, 7),
581 RCC_LPTIM3 = _REG_BIT(0xF4, 10),
582 RCC_LPTIM4 = _REG_BIT(0xF4, 11),
583 RCC_LPTIM5 = _REG_BIT(0xF4, 12),
584 RCC_COMP12 = _REG_BIT(0xF4, 14),
585 RCC_VREF = _REG_BIT(0xF4, 15),
586 RCC_RTCAPB = _REG_BIT(0xF4, 16),
587 RCC_SAI4 = _REG_BIT(0xF4, 21),
588};
589
591 /* AHB1 peripherals */
592 RST_DMA1 = _REG_BIT(0x80, 0),
593 RST_DMA2 = _REG_BIT(0x80, 1),
594 RST_ADC12 = _REG_BIT(0x80, 5),
598
599 /* AHB2 peripherals */
600 RST_DCMI = _REG_BIT(0xDC, 0),
601 RST_CRYP = _REG_BIT(0xDC, 4),
602 RST_HASH = _REG_BIT(0xDC, 5),
603 RST_RNG = _REG_BIT(0xDC, 6),
605
606 /* AHB3 peripherals */
607 RST_MDMA = _REG_BIT(0x7C, 0),
608 RST_DMA2D = _REG_BIT(0x7C, 4),
610 RST_FMC = _REG_BIT(0x7C, 12),
611 RST_QSPI = _REG_BIT(0x7C, 14),
612 RST_SDMMC1 = _REG_BIT(0x7C, 16),
613
614 /* AHB4 peripherals*/
615 RST_GPIOA = _REG_BIT(0x88, 0),
616 RST_GPIOB = _REG_BIT(0x88, 1),
617 RST_GPIOC = _REG_BIT(0x88, 2),
618 RST_GPIOD = _REG_BIT(0x88, 3),
619 RST_GPIOE = _REG_BIT(0x88, 4),
620 RST_GPIOF = _REG_BIT(0x88, 5),
621 RST_GPIOG = _REG_BIT(0x88, 6),
622 RST_GPIOH = _REG_BIT(0x88, 7),
623 RST_GPIOI = _REG_BIT(0x88, 8),
624 RST_GPIOJ = _REG_BIT(0x88, 9),
625 RST_GPIOK = _REG_BIT(0x88, 10),
626 RST_CRC = _REG_BIT(0x88, 19),
627 RST_BDMA = _REG_BIT(0x88, 21),
628 RST_ADC3 = _REG_BIT(0x88, 24),
629 RST_HSEM = _REG_BIT(0x88, 25),
630
631 /* APB1L peripherals*/
632 RST_TIM2 = _REG_BIT(0x90, 0),
633 RST_TIM3 = _REG_BIT(0x90, 1),
634 RST_TIM4 = _REG_BIT(0x90, 2),
635 RST_TIM5 = _REG_BIT(0x90, 3),
636 RST_TIM6 = _REG_BIT(0x90, 4),
637 RST_TIM7 = _REG_BIT(0x90, 5),
638 RST_TIM12 = _REG_BIT(0x90, 6),
639 RST_TIM13 = _REG_BIT(0x90, 7),
640 RST_TIM14 = _REG_BIT(0x90, 8),
642 RST_SPI2 = _REG_BIT(0x90, 14),
643 RST_SPI3 = _REG_BIT(0x90, 15),
645 RST_USART2 = _REG_BIT(0x90, 17),
646 RST_USART3 = _REG_BIT(0x90, 18),
647 RST_UART4 = _REG_BIT(0x90, 19),
648 RST_UART5 = _REG_BIT(0x90, 20),
649 RST_I2C1 = _REG_BIT(0x90, 21),
650 RST_I2C2 = _REG_BIT(0x90, 22),
651 RST_I2C3 = _REG_BIT(0x90, 23),
652 RST_CEC = _REG_BIT(0x90, 27),
653 RST_DAC = _REG_BIT(0x90, 29),
654 RST_UART7 = _REG_BIT(0x90, 30),
655 RST_UART8 = _REG_BIT(0x90, 31),
656
657 /* APB1H peripherals*/
658 RST_CRS = _REG_BIT(0x94, 1),
659 RST_SWP = _REG_BIT(0x94, 2),
660 RST_OPAMP = _REG_BIT(0x94, 4),
661 RST_MDIO = _REG_BIT(0x94, 5),
662 RST_FDCAN = _REG_BIT(0x94, 8),
663
664 /* APB2 peripherals */
665 RST_TIM1 = _REG_BIT(0x98, 0),
666 RST_TIM8 = _REG_BIT(0x98, 1),
669 RST_SPI1 = _REG_BIT(0x98, 12),
670 RST_SPI4 = _REG_BIT(0x98, 13),
671 RST_TIM15 = _REG_BIT(0x98, 16),
672 RST_TIM16 = _REG_BIT(0x98, 17),
673 RST_TIM17 = _REG_BIT(0x98, 18),
674 RST_SPI5 = _REG_BIT(0x98, 20),
675 RST_SAI1 = _REG_BIT(0x98, 22),
676 RST_SAI2 = _REG_BIT(0x98, 23),
677 RST_SAI3 = _REG_BIT(0x98, 24),
678 RST_DFSDM = _REG_BIT(0x98, 28),
679 RST_HRTIM = _REG_BIT(0x98, 29),
680
681 /* APB3 peripherals */
683
684 /* APB4 peripherals */
687 RST_SPI6 = _REG_BIT(0x9C, 5),
688 RST_I2C4 = _REG_BIT(0x9C, 7),
690 RST_LPTIM3 = _REG_BIT(0x9C, 10),
691 RST_LPTIM4 = _REG_BIT(0x9C, 11),
692 RST_LPTIM5 = _REG_BIT(0x9C, 12),
693 RST_COMP12 = _REG_BIT(0x9C, 14),
694 RST_VREF = _REG_BIT(0x9C, 15),
695 RST_SAI4 = _REG_BIT(0x9C, 21),
696};
697
698#undef _REG_BIT
699/**@}*/
700
701
702/** @defgroup rcc_file RCC peripheral API
703 *
704 * @ingroup peripheral_apis
705 * @{
706 */
708
710
711/**
712 * Setup the base PLLs and clock domains for the STM32H7. This function will
713 * utilize the users input parameters to configure all 3 PLLs, as well as the
714 * core clock domains (namely SYSCLK, CPU, HCLK, AHB, PCLK1-4) with the
715 * specified dividers. Given the dividers, the RCC module will track the
716 * the configured frequency for each of these clock domains.
717 *
718 * Note: If clock sources, configs, divider, etc. are modified outside of
719 * this module, the frequency tracking may be undefined.
720 * Note: Clock tree is fairly complex, see RM0433 Section 7
721 * for details.
722 * @param[in] config Input config structure defining desired setup.
723 */
724void rcc_clock_setup_pll(const struct rcc_pll_config *config);
725
726/**
727 * Get the clock rate (in Hz) of the specified clock source. There are
728 * numerous clock sources and configurations on the H7, so rates for each
729 * configured peripheral clock are aimed to be discoverd/calculated by this
730 * module such that the user does not need to know how the MCU is configured
731 * in order to utilize a peripheral clock.
732 * @param[in] source Clock source desired to be fetched.
733 * @return Clock rate in Hz for the specified clock. 0 if undefined or error.
734 */
735uint32_t rcc_get_bus_clk_freq(enum rcc_clock_source source);
736
737/**
738 * Get the peripheral clock speed for the USART at base specified.
739 * @param usart Base address of USART to get clock frequency for (e.g. USART1_BASE).
740 */
741uint32_t rcc_get_usart_clk_freq(uint32_t usart);
742
743/**
744 * Get the peripheral clock speed for the Timer at base specified.
745 * @param timer Base address of TIMER to get clock frequency for (e.g. TIM1_BASE).
746 */
747uint32_t rcc_get_timer_clk_freq(uint32_t timer);
748
749/**
750 * Get the peripheral clock speed for the I2C device at base specified.
751 * @param i2c Base address of I2C to get clock frequency for (e.g. I2C1_BASE).
752 */
753uint32_t rcc_get_i2c_clk_freq(uint32_t i2c);
754
755/**
756 * Get the peripheral clock speed for the SPI device at base specified.
757 * @param spi Base address of SPI device to get clock frequency for (e.g. SPI1_BASE).
758 */
759uint32_t rcc_get_spi_clk_freq(uint32_t spi);
760
761/**
762 * Get the peripheral clock speed for the FDCAN device at base specified.
763 * @param fdcan Base address of FDCAN to get clock frequency for (e.g. FDCAN1_BASE).
764 */
765uint32_t rcc_get_fdcan_clk_freq(uint32_t fdcan);
766
767/**
768 * Set the clksel value for the specified peripheral. This code will determine
769 * the appropriate register, shift and mask values to apply to the selection to
770 * and set the values appropriately.
771 *
772 * Peripheral specific clksels functions are also available,
773 * eg rcc_set_<periph>_clksel. These provide the same functionality, you only
774 * need one of them. for instance @ref rcc_set_fdcan_clksel or
775 * @ref rcc_set_spi123_clksel
776 * @param[in] periph Base address of the peripheral to set the clock sel for
777 * @param[in] clksel Raw, unshifted selection value for the clock, depending
778 * on peripheral, see @ref rcc_d1ccipr_values or @ref rcc_d2ccip1r_values or
779 * @ref rcc_d2ccip2r_values
780 */
781void rcc_set_peripheral_clk_sel(uint32_t periph, uint32_t clksel);
782
783/**
784 * Set the clock select for the FDCAN devices.
785 * @param[in] clksel Clock source to configure for, @ref rcc_d2ccip1r_values
786 * appropriate for the FDCAN peripherals, eg RCC_D2CCIP1R_FDCANSEL_XXX
787 * @sa rcc_set_peripheral_clk_sel for equivalent generic functionality
788 */
789void rcc_set_fdcan_clksel(uint8_t clksel);
790
791/**
792 * Set the clock select for the SPI 1/2/3 devices.
793 * @param[in] clksel Clock source to configure for, @ref rcc_d2ccip1r_values
794 * appropriate for the SPI1/2/3 peripherals, eg RCC_D2CCIP1R_SPI123_XXX
795 * @sa rcc_set_peripheral_clk_sel for equivalent generic functionality
796 */
797void rcc_set_spi123_clksel(uint8_t clksel);
798
799/**
800 * Set the clock select for the SPI 4/5 devices.
801 * @param[in] clksel Clock source to configure for. @ref rcc_d2ccip1r_values
802 * @sa rcc_set_peripheral_clk_sel for equivalent generic functionality
803 */
804void rcc_set_spi45_clksel(uint8_t clksel);
805
806/**
807 * Set the clock select for the RNG device.
808 * @param[in] clksel Clock source to configure for. @ref rcc_d2ccip2r_values
809 * @sa rcc_set_peripheral_clk_sel for equivalent generic functionality
810 */
811void rcc_set_rng_clksel(uint8_t clksel);
812
814/**@}*/
815
816#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
pwr_vos_scale
Definition: h7/pwr.h:200
pwr_sys_mode
Definition: h7/pwr.h:183
rcc_periph_rst
Definition: h7/rcc.h:590
rcc_periph_clken
Definition: h7/rcc.h:472
rcc_osc
Definition: h7/rcc.h:438
#define _REG_BIT(base, bit)
Definition: h7/rcc.h:470
rcc_clock_source
Enumerations for core system/bus clocks for user/driver/system access to base bus clocks not directly...
Definition: h7/rcc.h:425
@ RST_SDMMC2
Definition: h7/rcc.h:604
@ RST_BDMA
Definition: h7/rcc.h:627
@ RST_SPI4
Definition: h7/rcc.h:670
@ RST_CRS
Definition: h7/rcc.h:658
@ RST_DMA2
Definition: h7/rcc.h:593
@ RST_QSPI
Definition: h7/rcc.h:611
@ RST_DMA1
Definition: h7/rcc.h:592
@ RST_LPTIM2
Definition: h7/rcc.h:689
@ RST_USB1OTGRST
Definition: h7/rcc.h:596
@ RST_SPI1
Definition: h7/rcc.h:669
@ RST_I2C3
Definition: h7/rcc.h:651
@ RST_SPI6
Definition: h7/rcc.h:687
@ RST_CEC
Definition: h7/rcc.h:652
@ RST_HSEM
Definition: h7/rcc.h:629
@ RST_USART6
Definition: h7/rcc.h:668
@ RST_MDIO
Definition: h7/rcc.h:661
@ RST_ADC12
Definition: h7/rcc.h:594
@ RST_GPIOI
Definition: h7/rcc.h:623
@ RST_FDCAN
Definition: h7/rcc.h:662
@ RST_GPIOG
Definition: h7/rcc.h:621
@ RST_ADC3
Definition: h7/rcc.h:628
@ RST_JPGDEC
Definition: h7/rcc.h:609
@ RST_COMP12
Definition: h7/rcc.h:693
@ RST_DMA2D
Definition: h7/rcc.h:608
@ RST_TIM16
Definition: h7/rcc.h:672
@ RST_SAI1
Definition: h7/rcc.h:675
@ RST_RNG
Definition: h7/rcc.h:603
@ RST_LPTIM5
Definition: h7/rcc.h:692
@ RST_TIM14
Definition: h7/rcc.h:640
@ RST_GPIOF
Definition: h7/rcc.h:620
@ RST_UART7
Definition: h7/rcc.h:654
@ RST_OPAMP
Definition: h7/rcc.h:660
@ RST_SPI2
Definition: h7/rcc.h:642
@ RST_GPIOH
Definition: h7/rcc.h:622
@ RST_MDMA
Definition: h7/rcc.h:607
@ RST_UART4
Definition: h7/rcc.h:647
@ RST_TIM8
Definition: h7/rcc.h:666
@ RST_TIM15
Definition: h7/rcc.h:671
@ RST_TIM3
Definition: h7/rcc.h:633
@ RST_ETH1MAC
Definition: h7/rcc.h:595
@ RST_TIM17
Definition: h7/rcc.h:673
@ RST_TIM12
Definition: h7/rcc.h:638
@ RST_DCMI
Definition: h7/rcc.h:600
@ RST_LPTIM1
Definition: h7/rcc.h:641
@ RST_GPIOA
Definition: h7/rcc.h:615
@ RST_GPIOC
Definition: h7/rcc.h:617
@ RST_TIM6
Definition: h7/rcc.h:636
@ RST_GPIOB
Definition: h7/rcc.h:616
@ RST_TIM1
Definition: h7/rcc.h:665
@ RST_SAI3
Definition: h7/rcc.h:677
@ RST_SPI3
Definition: h7/rcc.h:643
@ RST_CRYP
Definition: h7/rcc.h:601
@ RST_USART3
Definition: h7/rcc.h:646
@ RST_DAC
Definition: h7/rcc.h:653
@ RST_TIM13
Definition: h7/rcc.h:639
@ RST_TIM7
Definition: h7/rcc.h:637
@ RST_HRTIM
Definition: h7/rcc.h:679
@ RST_SPI5
Definition: h7/rcc.h:674
@ RST_TIM2
Definition: h7/rcc.h:632
@ RST_CRC
Definition: h7/rcc.h:626
@ RST_SWP
Definition: h7/rcc.h:659
@ RST_GPIOD
Definition: h7/rcc.h:618
@ RST_I2C4
Definition: h7/rcc.h:688
@ RST_GPIOK
Definition: h7/rcc.h:625
@ RST_GPIOJ
Definition: h7/rcc.h:624
@ RST_DFSDM
Definition: h7/rcc.h:678
@ RST_SDMMC1
Definition: h7/rcc.h:612
@ RST_TIM4
Definition: h7/rcc.h:634
@ RST_TIM5
Definition: h7/rcc.h:635
@ RST_SYSCFG
Definition: h7/rcc.h:685
@ RST_UART5
Definition: h7/rcc.h:648
@ RST_GPIOE
Definition: h7/rcc.h:619
@ RST_HASH
Definition: h7/rcc.h:602
@ RST_I2C2
Definition: h7/rcc.h:650
@ RST_SPDIFRX
Definition: h7/rcc.h:644
@ RST_UART8
Definition: h7/rcc.h:655
@ RST_LPTIM4
Definition: h7/rcc.h:691
@ RST_USART1
Definition: h7/rcc.h:667
@ RST_SAI2
Definition: h7/rcc.h:676
@ RST_USB2OTGRST
Definition: h7/rcc.h:597
@ RST_VREF
Definition: h7/rcc.h:694
@ RST_I2C1
Definition: h7/rcc.h:649
@ RST_LPUART1
Definition: h7/rcc.h:686
@ RST_LTDCRST
Definition: h7/rcc.h:682
@ RST_FMC
Definition: h7/rcc.h:610
@ RST_SAI4
Definition: h7/rcc.h:695
@ RST_USART2
Definition: h7/rcc.h:645
@ RST_LPTIM3
Definition: h7/rcc.h:690
@ RCC_TIM8
Definition: h7/rcc.h:556
@ RCC_MDIO
Definition: h7/rcc.h:551
@ RCC_CRS
Definition: h7/rcc.h:548
@ RCC_SAI1
Definition: h7/rcc.h:565
@ RCC_UART5
Definition: h7/rcc.h:538
@ RCC_RNG
Definition: h7/rcc.h:489
@ RCC_GPIOJ
Definition: h7/rcc.h:513
@ RCC_FMC
Definition: h7/rcc.h:499
@ RCC_SPDIFRX
Definition: h7/rcc.h:534
@ RCC_COMP12
Definition: h7/rcc.h:584
@ RCC_SPI2
Definition: h7/rcc.h:532
@ RCC_TIM3
Definition: h7/rcc.h:523
@ RCC_SRAM3
Definition: h7/rcc.h:493
@ RCC_SRAM2
Definition: h7/rcc.h:492
@ RCC_TIM1
Definition: h7/rcc.h:555
@ RCC_ETH1MAC
Definition: h7/rcc.h:477
@ RCC_ETH1RX
Definition: h7/rcc.h:479
@ RCC_USB1OTGHSULPIEN
Definition: h7/rcc.h:482
@ RCC_OPAMP
Definition: h7/rcc.h:550
@ RCC_SDMMC2
Definition: h7/rcc.h:490
@ RCC_GPIOA
Definition: h7/rcc.h:504
@ RCC_CEC
Definition: h7/rcc.h:542
@ RCC_SPI6
Definition: h7/rcc.h:578
@ RCC_TIM17
Definition: h7/rcc.h:563
@ RCC_LPTIM3
Definition: h7/rcc.h:581
@ RCC_SDMMC1
Definition: h7/rcc.h:501
@ RCC_SAI3
Definition: h7/rcc.h:567
@ RCC_SAI4
Definition: h7/rcc.h:587
@ RCC_SAI2
Definition: h7/rcc.h:566
@ RCC_FDCAN
Definition: h7/rcc.h:552
@ RCC_GPIOK
Definition: h7/rcc.h:514
@ RCC_TIM2
Definition: h7/rcc.h:522
@ RCC_ETH1TX
Definition: h7/rcc.h:478
@ RCC_BKPSRAM
Definition: h7/rcc.h:519
@ RCC_QSPI
Definition: h7/rcc.h:500
@ RCC_SWP
Definition: h7/rcc.h:549
@ RCC_USB2OTGHSULPIEN
Definition: h7/rcc.h:480
@ RCC_GPIOG
Definition: h7/rcc.h:510
@ RCC_UART8
Definition: h7/rcc.h:545
@ RCC_GPIOH
Definition: h7/rcc.h:511
@ RCC_CRC
Definition: h7/rcc.h:515
@ RCC_HRTIM
Definition: h7/rcc.h:569
@ RCC_RTCAPB
Definition: h7/rcc.h:586
@ RCC_TIM14
Definition: h7/rcc.h:530
@ RCC_USART1
Definition: h7/rcc.h:557
@ RCC_USB2OTGHSEN
Definition: h7/rcc.h:483
@ RCC_TIM4
Definition: h7/rcc.h:524
@ RCC_I2C1
Definition: h7/rcc.h:539
@ RCC_DMA2D
Definition: h7/rcc.h:497
@ RCC_LPTIM5
Definition: h7/rcc.h:583
@ RCC_TIM13
Definition: h7/rcc.h:529
@ RCC_ADC12
Definition: h7/rcc.h:476
@ RCC_BDMA
Definition: h7/rcc.h:516
@ RCC_I2C4
Definition: h7/rcc.h:579
@ RCC_DCMI
Definition: h7/rcc.h:486
@ RCC_WWDG1EN
Definition: h7/rcc.h:573
@ RCC_LTDCEN
Definition: h7/rcc.h:572
@ RCC_USART2
Definition: h7/rcc.h:535
@ RCC_TIM16
Definition: h7/rcc.h:562
@ RCC_ADC3
Definition: h7/rcc.h:517
@ RCC_TIM12
Definition: h7/rcc.h:528
@ RCC_LPTIM4
Definition: h7/rcc.h:582
@ RCC_USART3
Definition: h7/rcc.h:536
@ RCC_TIM5
Definition: h7/rcc.h:525
@ RCC_SPI1
Definition: h7/rcc.h:559
@ RCC_SRAM1
Definition: h7/rcc.h:491
@ RCC_SYSCFG
Definition: h7/rcc.h:576
@ RCC_HASH
Definition: h7/rcc.h:488
@ RCC_LPTIM2
Definition: h7/rcc.h:580
@ RCC_UART7
Definition: h7/rcc.h:544
@ RCC_I2C2
Definition: h7/rcc.h:540
@ RCC_GPIOB
Definition: h7/rcc.h:505
@ RCC_TIM7
Definition: h7/rcc.h:527
@ RCC_SPI5
Definition: h7/rcc.h:564
@ RCC_LPTIM1
Definition: h7/rcc.h:531
@ RCC_VREF
Definition: h7/rcc.h:585
@ RCC_GPIOF
Definition: h7/rcc.h:509
@ RCC_GPIOC
Definition: h7/rcc.h:506
@ RCC_CRYP
Definition: h7/rcc.h:487
@ RCC_TIM6
Definition: h7/rcc.h:526
@ RCC_UART4
Definition: h7/rcc.h:537
@ RCC_DMA1
Definition: h7/rcc.h:474
@ RCC_GPIOI
Definition: h7/rcc.h:512
@ RCC_SPI3
Definition: h7/rcc.h:533
@ RCC_DAC
Definition: h7/rcc.h:543
@ RCC_GPIOD
Definition: h7/rcc.h:507
@ RCC_TIM15
Definition: h7/rcc.h:561
@ RCC_USB1OTGHSEN
Definition: h7/rcc.h:481
@ RCC_I2C3
Definition: h7/rcc.h:541
@ RCC_MDMA
Definition: h7/rcc.h:496
@ RCC_GPIOE
Definition: h7/rcc.h:508
@ RCC_HSEM
Definition: h7/rcc.h:518
@ RCC_USART6
Definition: h7/rcc.h:558
@ RCC_DMA2
Definition: h7/rcc.h:475
@ RCC_JPGDEC
Definition: h7/rcc.h:498
@ RCC_SPI4
Definition: h7/rcc.h:560
@ RCC_DFSDM
Definition: h7/rcc.h:568
@ RCC_LPUART1
Definition: h7/rcc.h:577
@ RCC_HSI
Definition: h7/rcc.h:441
@ RCC_LSI
Definition: h7/rcc.h:443
@ RCC_PLL
Definition: h7/rcc.h:439
@ RCC_LSE
Definition: h7/rcc.h:442
@ RCC_HSE
Definition: h7/rcc.h:440
@ RCC_APB1CLK
Definition: h7/rcc.h:432
@ RCC_SYSCLK
Definition: h7/rcc.h:427
@ RCC_APB4CLK
Definition: h7/rcc.h:435
@ RCC_APB3CLK
Definition: h7/rcc.h:434
@ RCC_SYSTICKCLK
Definition: h7/rcc.h:429
@ RCC_PERCLK
Definition: h7/rcc.h:428
@ RCC_APB2CLK
Definition: h7/rcc.h:433
@ RCC_HCLK3
Definition: h7/rcc.h:430
@ RCC_CPUCLK
Definition: h7/rcc.h:426
@ RCC_AHBCLK
Definition: h7/rcc.h:431
uint32_t rcc_get_fdcan_clk_freq(uint32_t fdcan)
Get the peripheral clock speed for the FDCAN device at base specified.
Definition: rcc.c:355
void rcc_clock_setup_pll(const struct rcc_pll_config *config)
Setup the base PLLs and clock domains for the STM32H7.
Definition: rcc.c:181
uint32_t rcc_get_bus_clk_freq(enum rcc_clock_source source)
Get the clock rate (in Hz) of the specified clock source.
Definition: rcc.c:234
uint32_t rcc_get_spi_clk_freq(uint32_t spi)
Get the peripheral clock speed for the SPI device at base specified.
Definition: rcc.c:320
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
Get the peripheral clock speed for the Timer at base specified.
Definition: rcc.c:297
void rcc_set_rng_clksel(uint8_t clksel)
Set the clock select for the RNG device.
Definition: rcc.c:432
uint32_t rcc_get_usart_clk_freq(uint32_t usart)
Get the peripheral clock speed for the USART at base specified.
Definition: rcc.c:268
void rcc_set_fdcan_clksel(uint8_t clksel)
Set the clock select for the FDCAN devices.
Definition: rcc.c:427
void rcc_set_spi123_clksel(uint8_t clksel)
Set the clock select for the SPI 1/2/3 devices.
Definition: rcc.c:437
uint32_t rcc_get_i2c_clk_freq(uint32_t i2c)
Get the peripheral clock speed for the I2C device at base specified.
Definition: rcc.c:309
void rcc_set_peripheral_clk_sel(uint32_t periph, uint32_t clksel)
Set the clksel value for the specified peripheral.
Definition: rcc.c:370
void rcc_set_spi45_clksel(uint8_t clksel)
Set the clock select for the SPI 4/5 devices.
Definition: rcc.c:442
uint8_t divr
Post divider for PLLR clock.
Definition: h7/rcc.h:456
uint8_t divq
Post divider for PLLQ clock.
Definition: h7/rcc.h:455
uint16_t divn
Multiplier, 0-512 integer.
Definition: h7/rcc.h:453
uint8_t divp
Post divider for PLLP clock.
Definition: h7/rcc.h:454
uint8_t divm
Pre-divider value for each PLL.
Definition: h7/rcc.h:452
PLL Configuration structure.
Definition: h7/rcc.h:447
uint8_t ppre3
APB3 Peripheral prescaler note: domain 1.
Definition: h7/rcc.h:462
uint8_t core_pre
Core prescaler note: domain 1.
Definition: h7/rcc.h:458
struct rcc_pll_config::pll_config pll1
uint8_t ppre1
APB1 Peripheral prescaler note: domain 2.
Definition: h7/rcc.h:460
struct rcc_pll_config::pll_config pll2
uint8_t smps_level
If using SMPS, voltage level to set.
Definition: h7/rcc.h:467
uint8_t ppre2
APB2 Peripheral prescaler note: domain 2.
Definition: h7/rcc.h:461
uint8_t hpre
HCLK3 prescaler note: domain 1.
Definition: h7/rcc.h:459
uint8_t ppre4
APB4 Peripheral prescaler note: domain 3.
Definition: h7/rcc.h:463
enum rcc_osc sysclock_source
SYSCLK source input selection.
Definition: h7/rcc.h:448
uint8_t flash_waitstates
Latency Value to set for flahs.
Definition: h7/rcc.h:464
enum pwr_vos_scale voltage_scale
LDO/SMPS Voltage scale used for this frequency.
Definition: h7/rcc.h:465
uint32_t hse_frequency
User specified HSE frequency, 0 if none.
Definition: h7/rcc.h:450
struct rcc_pll_config::pll_config pll3
PLL1-PLL3 configurations.
uint8_t pll_source
RCC_PLLCKSELR_PLLSRC_xxx value.
Definition: h7/rcc.h:449
enum pwr_sys_mode power_mode
LDO/SMPS configuration for device.
Definition: h7/rcc.h:466